narou2html.py

小説テキスト html コンバーター

Rev.1.0 (2026-08-26)
Generated by ChatGPT
Supervised by Lyuka

概要

主に小説家になろうで使われるルビの表記と、会話や和歌を含むテキストを html に変換するツールです。 python2.7 用です。

narou2html.py

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

ダウンロード

変換例

原文

━━

まばらに桜が咲いている公園を抜けて展望台へ行く。

「わぁ、綺麗…」

対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった|権中納言《ごんちゅうなごん》|匡房《まさふさ》の歌がまさにぴったりだ。

  たかさこの尾上の桜咲きにけり 外山の霞立たすもあらなむ

(本当に綺麗…また一緒にこの景色見れるといいなぁ…)

変換後

<hr class="story-divider">

<p>まばらに桜が咲いている公園を抜けて展望台へ行く。</p>

<div class="dialogue">「わぁ、綺麗…」</div>

<p>対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった<ruby>権中納言<rt>ごんちゅうなごん</rt></ruby><ruby>匡房<rt>まさふさ</rt></ruby>の歌がまさにぴったりだ。</p>

<div class="waka">  たかさこの尾上の桜咲きにけり 外山の霞立たすもあらなむ</div>

<div class="monologue">(本当に綺麗…また一緒にこの景色見れるといいなぁ…)</div>

css

.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;
tory-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;
}

ブラウザ表示


まばらに桜が咲いている公園を抜けて展望台へ行く。

「わぁ、綺麗…」

対岸の嵐山に丸く、白く、ほのかに紅く、山桜が咲いている。途中にあった権中納言ごんちゅうなごん匡房まさふさの歌がまさにぴったりだ。

  たかさこの尾上の桜咲きにけり 外山の霞立たすもあらなむ
(本当に綺麗…また一緒にこの景色見れるといいなぁ…)