小説テキスト html コンバーター
SYNOPSIS
narou2html.py [-i shift_jis|utf-8|euc]
[-e shift_jis|utf-8|euc]
[-br]
[readfile.txt [writefile.html]]
DESCRIPTION
Convert Narou-style novel text to HTML.
Input and output are decoded/encoded according to the
specified character encodings. Internally, all processing
is performed as Unicode.
Input line endings are normalized to LF.
OPTIONS
-i ENCODING
Input encoding.
shift_jis
utf-8
euc
Default: shift_jis
-e ENCODING
Output encoding.
shift_jis
utf-8
euc
Default: utf-8
-br
In normal paragraphs, use ¥¥ as an explicit
line-break marker instead of actual line endings.
Without -br:
actual line endings -> <br>
With -br:
¥¥ -> <br>
Dialogue and monologue line endings are converted
to <br> regardless of this option.
-h
Show this help.
EXAMPLES
# Standard input -> standard output
narou2html.py
# novel.txt -> standard output
narou2html.py novel.txt
# novel.txt -> novel.html
narou2html.py novel.txt novel.html
# Shift_JIS input -> UTF-8 output
narou2html.py -i shift_jis -e utf-8 novel.txt novel.html
# UTF-8 input -> Shift_JIS output
narou2html.py -i utf-8 -e shift_jis novel.txt novel.html
# EUC-JP input -> UTF-8 output
narou2html.py -i euc -e utf-8 novel.txt novel.html
# Use ¥¥ as explicit line-break markers
narou2html.py -br novel.txt novel.html
小説家になろうで使われているルビの表記
|漢字《かんじ》を、HTML の
<ruby> 要素に変換します。
空行がブロックやパラグラフの区切りになります。
前後が空行で2つの太横罫線━━は story-divider になります。
全角カギ括弧「会話」は dialogueになります。
全角丸括弧(モノローグ)は monologue となります。
先頭が全角スペース2つで始まる行 和歌は waka となります。
また、分かち書きの和歌などは、2つずつ重ねた波括弧で囲んだ箇所を
{{分かち書きの 和歌}}
の waka として扱います。内部の空白文字は保持されます。
(夏澤ひかり「春は過ぐとも」より引用)
まばらに桜が咲いている公園を抜けて展望台へ行く。 「わぁ、綺麗…」 対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった|権中納言《ごんちゅうなごん》|匡房《まさふさ》の歌がまさにぴったりだ。 たかさこの尾上の桜咲きにけり 外山の霞立たすもあらなむ (本当に綺麗…また一緒にこの景色見れるといいなぁ…) ━━ 車内販売のコーヒーと生八ツ橋、リアルで大好きだったのになぁ…寂しいなぁ… {{ 奥山に紅葉踏み分け なく鹿の声聞くときぞ 秋は悲しき }}
<p>まばらに桜が咲いている公園を抜けて展望台へ行く。</p> <div class="dialogue">「わぁ、綺麗…」</div> <p>対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった<ruby>権中納言<rt>ごんちゅうなごん</rt></ruby><ruby>匡房<rt>まさふさ</rt></ruby>の歌がまさにぴったりだ。</p> <div class="waka">たかさこの尾上の桜咲きにけり 外山の霞立たすもあらなむ</div> <div class="monologue">(本当に綺麗…また一緒にこの景色見れるといいなぁ…)</div> <hr class="story-divider"> <p>車内販売のコーヒーと生八ツ橋、リアルで大好きだったのになぁ…寂しいなぁ…</p> <div class="waka">奥山に紅葉踏み分け なく鹿の声聞くときぞ 秋は悲しき</div>
.story-divider {
width: 50%;
border: none;
border-top: 1px dashed #888;
margin-left: 1.5em;
}
.dialogue,
.monologue {
margin-left: 2em;
margin-top: 1em;
margin-bottom: 1em;
}
.waka {
white-space: pre-wrap;
margin: 1.5em 0 1.5em 2em;
font-family: "Yu Mincho", "Hiragino Mincho ProN", "YuMincho", serif;
font-size: 1.05em;
font-weight: bold;
line-height: 1.0;
color: #421;
}
まばらに桜が咲いている公園を抜けて展望台へ行く。
対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった権中納言匡房の歌がまさにぴったりだ。
車内販売のコーヒーと生八ツ橋、リアルで大好きだったのになぁ…寂しいなぁ…