Coder Social home page Coder Social logo

aozora2html's Introduction

aozorahack slack

aozorahack全般に関するissue/wiki用リポジトリです(いわゆるメタリポジトリ)。

「Code for 青空文庫」アイデアソン #1 (https://atnd.org/events/66230 ) の開催をきっかけとしてaozorahackというgithub organizationを作成しました。青空文庫とその周辺に関する技術的な情報や、コード・ドキュメント置き場として活用できればと思っています。

このリポジトリ、aozorahack/aozorahackは、aozorahackに関する情報や意見質問の集約用のリポジトリです。お気軽にご利用ください(ただ、意見や質問をいただいても返答がないこともあります。ご了承ください)。

Issues

slack

https://aozorahack.slack.com/ を作成しました。メインのやりとりはgithubで実施しますが、ブレストや雑談はslackでもできればと思っています。参加希望者は https://aozoraslackin.herokuapp.com/ からJoinしてください。

Projects

新しくプロジェクトを作りたい人は、新規プロジェクト(リポジトリ)を作るにはをご覧ください。

現在活動中のプロジェクトは以下になります。

アイデアソンで提案された「オープンソースの文書入力・校正システムを作る件について」のプロジェクトです。

  • aozoraflow - 作品をgitで管理する際の運用規約とサポートツール
  • aozora-parser.js - 青空文庫テキストのパーサ
  • hinagata - 作品パッケージの雛形
  • aozora.json - 作品メタデータのフォーマット

青空文庫の技術的な「仕様」をまとめて文書化するためのレポジトリ。今後作るものの仕様ではなく、既存の青空文庫がどうなっているかが中心です。

アイデアソンの資料置き場です。

Resources

aozora2html's People

Contributors

gemmaro avatar ksato9700 avatar kurema avatar takahashim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aozora2html's Issues

LaTeX出力

現在XHTML出力が可能ですが、こちらに加えてLaTeXへの出力ができると、印刷して読む用途に便利だと思います。
(このプログラムの名前が aozora2html のため、やや範囲を外れているきらいはあるかもしれません。)

出力されるLaTeX文書ファイルやコマンドラインオプションなどについての、大まかな仕様案は次の通りです:

  • 出力されるLaTeX文書ファイル
    • 文字コード:UTF-8
    • LaTeX処理系:LuaLaTeX(ないしupLaTeX)
    • 文書クラス: jlreq
      • 文書クラスのオプション
        • tate
        • book
  • コマンドラインオプション
    • --output-format FORMAT を追加
      • FORMAT には xhtml (初期値)、 latex を指定することができる
    • --use-jisx0213, --use-unicode--output-format latex は併用不可

なお、初期値で --output-format xhtml が使用されるため、従来のコマンドの動作は変化しません。

予想される作業工程は次の通りです:

  1. sample/chukiichiran_kinyurei.{txt,html} を参考に sample/chukiichiran_kinyurei.tex を編集して作成
  2. sample/chukiichiran_kinyurei.txt--output-format latex 指定で変換した結果が sample/chukiichiran_kinyurei.tex と等しくなるようなテストを追加 ...a
  3. 各種ユニットテストを追加 ...b
  4. a, b のテストが通るように実装を行う

縦書き対応に関して

aozora2htmlの出力を縦書き表示できると良いと思うのですが、どのようにしたら良いかのご相談です。

世の中には幾つか縦書き対応のビューアーがあるようですが、Flashの実装はマルチプラットフォームを考えた場合はあまり良い選択肢ではないように思います。「青空縦書きリーダー」というのはCSSベースのようですが、ChromeのExtensionなのでブラウザを選んでしまいます。

Web上の記事 (e.g. https://app.codegrid.net/entry/vertical-script-1 )を読むと昨今のブラウザでは縦書きの対応がそこそこされてきているようなので、aozora2htmlが吐き出すHTMLでもCSSで縦書き対応できたら良いのかなと思いました。

ただ、本質的にはHTMLの生成とCSSの指定は別だと思うので、例えば、aozora2htmlでは外からCSSを指定・追加出来るようにしていただくことで良いのかもしれません。その場合、縦書きCSSの方は別のプロジェクトとしてaozorahackに追加ですかね。

ご意見頂けると助かります。よろしくお願い致します。

1つの注記で複数の指示があるものが壊れる

[#ここから4字下げ、罫囲み]
東海道、関《せき》
江戸へ百六里二丁
京へ十九里半
[#ここで字下げ、罫囲み終わり]

といったような記述がある場合、終わりのところで、

エラー(958行目):字下げを閉じようとしましたが、字下げ中ではありません. 
処理を停止します

といって終了してしまうようでした。

sampleについて

sample323行目[#ここから○字下げ]が漢数字「〇」ではなく丸印「○」になっています。
変換結果は以下のように無効なclassとstyleになっています。

<div class="jisage_" style="margin-left: em">

意図したものかもしれませんが、変換結果は変だと思います。

他に変換結果の改行コードに"\n"が混ざっています。
プルリクエストを参照してください。

RuboCopのバージョンについて

このリポジトリには既に .rubocop.yml がありますが、RuboCop v1.22.0 では警告及びエラーが出ます(実行結果は末尾)。
aozora2html.gemspec ファイルに rubocopmeowcop が追記されていると、 $ bundle install から $ bundle exec rubocop として検査できるようになります。
つきまして適切なRuboCopとMeowCopのバージョンがわかりましたら、追記いただけますと幸いです。

想定される変更は以下:

  • aozora2html.gemspec へのRuboCop, MeowCopの追加
  • .rubocop.yml の更新
    • $ bundle exec rubocop --auto-gen-config が利用できる場合、 .rubocop-todo.yml の追加も考えられます
  • GitHub ActionsでのRuboCopにしたがった検査の追加
    • .github/workflows/ruby.yml への追記、または別のワークフローを追加

実行結果:

aozora2html on  master via 💎 v2.7.4 
❯ rubocop            
.rubocop.yml:59: `Style/Encoding` is concealed by line 129
.rubocop.yml:28: `Layout/SpaceBeforeBlockBraces` is concealed by line 220
.rubocop.yml:46: `Style/ClassAndModuleChildren` is concealed by line 226
.rubocop.yml: Style/MethodName has the wrong namespace - should be Naming
.rubocop.yml: Style/VariableName has the wrong namespace - should be Naming
.rubocop.yml: Style/VariableNumber has the wrong namespace - should be Naming
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
Error: The `Layout/AlignParameters` cop has been renamed to `Layout/ParameterAlignment`.
(obsolete configuration found in .rubocop.yml, please update it)
The `Layout/TrailingBlankLines` cop has been renamed to `Layout/TrailingEmptyLines`.
(obsolete configuration found in .rubocop.yml, please update it)
The `Lint/StringConversionInInterpolation` cop has been renamed to `Lint/RedundantStringCoercion`.
(obsolete configuration found in .rubocop.yml, please update it)
The `Style/UnneededPercentQ` cop has been renamed to `Style/RedundantPercentQ`.
(obsolete configuration found in .rubocop.yml, please update it)
`Performance` cops have been extracted to the `rubocop-performance` gem.
(obsolete configuration found in .rubocop.yml, please update it)

aozora2html on  master via 💎 v2.7.4 
❯ rubocop -v  
1.22.0

外字が含まれていると傍点が反映されない

--use-jisx0213 --use-unicode オプションでも変換できない外字が含まれる文字列に傍点が指定されていた場合、注記が傍点のものだと認識されないようです。

久生十蘭 ノンシャラン道中記 謝肉祭の支那服 ――地中海避寒地の巻―― より

というのは、※[#「てへん+夸」、37-下-12][#「※[#「てへん+夸」、37-下-12]」に傍点]門は崩れ
というのは、※<span class="notes">[#「てへん+夸」、37-下-12]</span><span class="notes">[#「※<span class="notes">[#「てへん+夸」、37-下-12]</span>」に傍点]</span>門は崩れ

ルビは以下のように組まれているので、傍点も <em> で囲まれるといいはず
花のいろ/\ より

<ruby><rb>芙※</rb><rp></rp><rt>はなはちす</rt><rp></rp></ruby><span class="notes">[#「※」は「くさかんむり+渠」、128-2]</span>

undefined method エラーが出る

PowerShell 7.2.2、ruby 3.1.3p185、aozora2html 3.0.0、rubyzip 2.3.2(双方最新版です)にて、Web上のzipフォルダを変換しようとすると以下のエラーが出ます。

> aozora2html https://www.aozora.gr.jp/cards/000051/files/1441_ruby.zip web_1441.html

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aozora2html-3.0.0/lib/aozora2html/zip.rb:11:in `block in unzip': undefined method `extract' for nil:NilClass (NoMethodError)

        entry.extract(textfilename)
             ^^^^^^^^
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rubyzip-2.3.2/lib/zip/file.rb:125:in `open'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aozora2html-3.0.0/lib/aozora2html/zip.rb:9:in `unzip'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aozora2html-3.0.0/bin/aozora2html:66:in `block in <top (required)>'
        from C:/Ruby31-x64/lib/ruby/3.1.0/tmpdir.rb:96:in `mktmpdir'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aozora2html-3.0.0/bin/aozora2html:42:in `<top (required)>'
        from C:/Ruby31-x64/bin/aozora2html:32:in `load'
        from C:/Ruby31-x64/bin/aozora2html:32:in `<main>'

Windows環境で動作しない

起きたこと

コマンドプロンプト上で実行すると

エラー(1行目):改行コードを、「CR+LF」にあらためてください.
処理を停止します

と表示され、変換されない。
秀丸を用いて改行コードを調べるとCRLFになっている。

検証環境

OS : Windows7 Professional SP1
ruby : 2.2.3(http://rubyinstaller.org/downloads/ のインストーラを用いた)
青空注記ファイル:http://www.aozora.gr.jp/cards/000050/card48385.html
aozora2htmlはgemからインストールした

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.