Skip to content

Commit

Permalink
improve index logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Dec 31, 2016
2 parents 533b56c + f9e79d6 commit b85e827
Show file tree
Hide file tree
Showing 49 changed files with 1,783 additions and 253 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ Gemfile.lock


# IntelliJ # IntelliJ
.idea .idea

# Editor
#*#
*~
#.bak
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Lint/BlockAlignment:
Lint/EndAlignment: Lint/EndAlignment:
Enabled: AlignWith Enabled: AlignWith


Lint/EmptyWhen:
Enabled: false

Performance/ReverseEach: Performance/ReverseEach:
Enabled: true Enabled: true


Expand Down Expand Up @@ -67,6 +70,24 @@ Style/NumericPredicate:
Style/TernaryParentheses: Style/TernaryParentheses:
Enabled: false Enabled: false


Style/VariableNumber:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

MultilineMethodCallBraceLayout:
Enabled: false

Style/SafeNavigation:
Enabled: false

Style/EmptyMethod:
Enabled: false

Style/HashSyntax:
Enabled: false

##################### Metrics ################################## ##################### Metrics ##################################


Metrics/ClassLength: Metrics/ClassLength:
Expand Down Expand Up @@ -94,3 +115,12 @@ Metrics/AbcSize:
Exclude: Exclude:
- "bin/review-*" - "bin/review-*"
- "test/**/*" - "test/**/*"

### shoud be < 25
Metrics/BlockLength:
CountComments: false # count full line comments?
Max: 50
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'test/**/*.rb'
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ before_install:
- gem update bundler - gem update bundler


rvm: rvm:
- 2.0.0 - 2.0
- 2.1.* - 2.1
- 2.2.* - 2.2
- 2.3.1 - 2.3.3
- 2.4.0
## - ruby-head ## - ruby-head


addons: addons:
Expand Down
8 changes: 2 additions & 6 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ rescue LoadError
end end


require 'rubygems' require 'rubygems'
require 'rake/testtask'
require 'rake/clean' require 'rake/clean'


task :default => [:test, :rubocop] task :default => [:test, :rubocop]
Expand All @@ -20,11 +19,8 @@ task :rubocop do
end end
end end


Rake::TestTask.new("test") do |t| task :test do
t.libs << "test" ruby("test/run_test.rb")
t.test_files = Dir.glob("test/**/test_*.rb")
t.verbose = true
t.warning = false
end end


begin begin
Expand Down
1 change: 0 additions & 1 deletion bin/review-compile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def _main
opts.on('-c', '--check', 'Check manuscript') { check_only = true } opts.on('-c', '--check', 'Check manuscript') { check_only = true }
opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i } opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i }
opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i } opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i }
opts.on('--nolfinxml', 'Do not insert LF in XML. (idgxml)') { config["nolf"] = true }
opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true } opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true }
opts.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| config["tableopt"] = tbl } opts.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| config["tableopt"] = tbl }
opts.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { config["listinfo"] = true } opts.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { config["listinfo"] = true }
Expand Down
9 changes: 5 additions & 4 deletions bin/review-validate
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Copyright (c) 2010-2014 Kenshi Muto # Copyright (c) 2010-2016 Kenshi Muto
# #
# This program is free software # This program is free software
# You can distribute or modify this program under the terms of # You can distribute or modify this program under the terms of
Expand All @@ -16,20 +16,20 @@ ln = 0


ARGF.each {|line| ARGF.each {|line|
ln += 1 ln += 1
if line =~ /\A\/\/([a-z]+).+\{/ if line =~ /\A\/\/([a-z]+)\{\s*\Z/ || line =~ /\A\/\/([a-z]+)\[.+?\{\s*\Z/
# block # block
_block = $1 _block = $1
puts "#{ln}: block #{_block} started, but previous block #{block} didn't close yet." unless block.nil? puts "#{ln}: block #{_block} started, but previous block #{block} didn't close yet." unless block.nil?
block = _block block = _block
elsif line =~ /\A\/\/\}/ elsif line =~ /\A\/\/\}/
puts "#{ln}: block seen ended, but not opened." if block.nil? puts "#{ln}: block ended, but not opened." if block.nil?
block = nil block = nil
maxcolcount = 0 maxcolcount = 0
colcount = 0 colcount = 0
elsif line =~ /\A(\d+\.)\s+/ elsif line =~ /\A(\d+\.)\s+/
# number # number
unless ["list", "emlist", "listnum", "emlistnum", "cmd", "image", "table"].include?(block) unless ["list", "emlist", "listnum", "emlistnum", "cmd", "image", "table"].include?(block)
puts "#{ln}: found $1 without the head space. Is it correct?" puts "#{ln}: found '#{$1}' without the head space. Is it correct?"
end end
elsif line =~ /\A\*\s+/ elsif line =~ /\A\*\s+/
# itemize # itemize
Expand All @@ -41,6 +41,7 @@ ARGF.each {|line|
puts "#{ln}: found itemized list or numbered list in #{block}. Is it correct?" puts "#{ln}: found itemized list or numbered list in #{block}. Is it correct?"
end end
elsif block == "table" elsif block == "table"
next if line.start_with?('#@')
if line !~ /\A\-\-\-\-\-/ if line !~ /\A\-\-\-\-\-/
# table # table
colcount = line.split("\t").size colcount = line.split("\t").size
Expand Down
82 changes: 82 additions & 0 deletions doc/NEWS.ja.md
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,85 @@
# Version 2.1.0 の主な変更点

## 新機能

* review-init: Gemfileを生成するようにしました([#650])
* HTMLBuilder: リスト内で言語別のclassを生成するようにしました([#666])
* HTMLBuilder: image同様indepimageでも<div>要素にid属性を追加しました
* MD2INAOBuilder: 新builderとしてMD2INAOBuilderを追加しました ([#671])
* MARKDOWNBuilder, MD2INAOBuilder: ルビに対応しました ([#671])
* TEXTBuilder: `@<hd>`に対応しました([#648])
* TOPBuilder: `@<comment>{}`に対応しました ([#625], [#627])

## 非互換の変更

## バグ修正

* review-validate: ブロックや表内でのコメントの挙動と、メッセージを修正しました
* LATEXBuilder: config.ymlで`rights`が空の場合に対応しました ([#653])
* LATEXBuilder: config.ymlとlocale.ymlの値のエスケープを修正しました ([#642])
* PDFMaker: AI, EPS, TIFFの画像に対応しました ([#675])
* PDFMaker: フックからフルパスを取得できるよう @basehookdir を追加しました ([#662])
* EPUBMaker: dc:identifierが空になってしまうバグを修正しました ([#636])
* EPUBMaker: coverファイルの拡張子がxhtmlになってしまうバグを修正しました ([#618])
* WEBMaker: リンクを修正しました ([#645])
* WEBMaker: 部がファイルでない場合のリンクを修正しました ([#639], [#641])
* I18n: format_number_headerので`%pJ`の扱いを修正しました ([#628])

## 機能強化

* LATEXBuilder: pLaTeXでもpxjahyper packageを使うようにしました([#640])
* LATEXBuilder: `layout.tex.erb`を改良しました([#617])
* LATEXBuilder: locale.ymlで指定されたキーワードを使うようにしました ([#629])
* IDGXMLBuilder: コラムの埋め込み目次情報のXMLインストラクションを修正しました ([#634])
* IDGXMLBuilder: //emlistで空のcaptionができるバグを修正しました ([#633])
* Rakefile: `preproc`タスクを追加しました ([#630])

## ドキュメント

* 「EPUBローカルルールへの対応方法」のドキュメントを英訳しました
* 「review-preprocユーザガイド(preproc(.ja).md)」を追加しました ([#632])
* config.yml: `csl`の例を追加しました
* config.yml: シンプルなサンプルファイル(config.yml.sample-simple)を追加しました ([#626])

## その他

* templates/以下のテンプレートファイルのライセンスを他の文書内に取り込みやすくするため、MIT licenseにしました([#663])
* rubocopの新しい警告を抑制しました

## コントリビューターのみなさん

* [@kazken3](https://github.com/kazken3)
* [@vvakame](https://github.com/vvakame)
* [@masarakki](https://github.com/masarakki)
* [@munepi](https://github.com/munepi)
* [@znz](https://github.com/znz)

[#675]: https://github.com/kmuto/review/issues/
[#671]: https://github.com/kmuto/review/issues/
[#666]: https://github.com/kmuto/review/issues/
[#663]: https://github.com/kmuto/review/issues/
[#662]: https://github.com/kmuto/review/issues/
[#653]: https://github.com/kmuto/review/issues/
[#650]: https://github.com/kmuto/review/issues/
[#648]: https://github.com/kmuto/review/issues/
[#645]: https://github.com/kmuto/review/issues/
[#642]: https://github.com/kmuto/review/issues/
[#641]: https://github.com/kmuto/review/issues/
[#640]: https://github.com/kmuto/review/issues/
[#638]: https://github.com/kmuto/review/issues/
[#636]: https://github.com/kmuto/review/issues/
[#634]: https://github.com/kmuto/review/issues/
[#633]: https://github.com/kmuto/review/issues/
[#632]: https://github.com/kmuto/review/issues/
[#630]: https://github.com/kmuto/review/issues/
[#629]: https://github.com/kmuto/review/issues/
[#628]: https://github.com/kmuto/review/issues/
[#627]: https://github.com/kmuto/review/issues/
[#626]: https://github.com/kmuto/review/issues/
[#625]: https://github.com/kmuto/review/issues/
[#618]: https://github.com/kmuto/review/issues/
[#617]: https://github.com/kmuto/review/issues/

# Version 2.0.0の主な変更点 # Version 2.0.0の主な変更点


## 新機能 ## 新機能
Expand Down
84 changes: 84 additions & 0 deletions doc/NEWS.md
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,87 @@
# Version 2.1.0

## New Features

* review-init: generate Gemfile ([#650])
* HTMLBuilder: add language specified class in list ([#666])
* HTMLBuilder: set id to <div> of indepimage as same as image
* MD2INAOBuilder: support new builder MD2INAOBuilder ([#671])
* MARKDOWNBuilder, MD2INAOBuilder: support ruby ([#671])
* TEXTBuilder: support `@<hd>` ([#648])
* TOPBuilder: support `@<comment>{}` ([#625], [#627])

## Breaking Changes

## Bug Fixes

* review-validate: fix parsing blocks and comments in tables, and messages
* LATEXBuilder: fix when rights is null in config.yml ([#653])
* LATEXBuilder: escaping values from config.yml and locale.yml([#642])
* PDFMaker: support AI, EPS, and TIFF on pdfmaker correctly ([#675])
* PDFMaker: fix hooks; add @basehookdir and use it to get fullpath ([#662])
* EPUBMaker: fix missing default dc:identifier value ([#636])
* EPUBMaker: ext. of cover file should be "xhtml" in EPUB ([#618])
* WEBMaker: fix broken link ([#645])
* WEBMaker: fix when Part has no "*.re" file ([#641])
* I18n: fix `%pJ` in format_number_header ([#628])

## Enhancements

* LATEXBuilder: use pxjahyper package in pLaTeX ([#640])
* LATEXBuilder: Enhanced implementation of `layout.tex.erb` ([#617])
* LATEXBuilder: fix to use keywords in locale.yml ([#629])
* IDGXMLBuilder: add instruction to column headline for toc ([#634])
* IDGXMLBuilder: fix to avoid empty caption in //emlist ([#633])
* Rakefile: add task `preproc` ([#630])
* ReVIEW::Location: add test ([#638])

## Docs

* add customize_epub.md
* add preproc(.ja).md ([#632])
* config.yml: add `csl` in sample
* config.yml: add simplified sample ([#626])

## Others

* license of template fils are MIT license([#663])
* rubocop: suppress warnings of rubocop

## Contributors

* [@kazken3](https://github.com/kazken3)
* [@vvakame](https://github.com/vvakame)
* [@masarakki](https://github.com/masarakki)
* [@munepi](https://github.com/munepi)
* [@znz](https://github.com/znz)

[#675]: https://github.com/kmuto/review/issues/
[#671]: https://github.com/kmuto/review/issues/
[#666]: https://github.com/kmuto/review/issues/
[#663]: https://github.com/kmuto/review/issues/
[#662]: https://github.com/kmuto/review/issues/
[#653]: https://github.com/kmuto/review/issues/
[#650]: https://github.com/kmuto/review/issues/
[#648]: https://github.com/kmuto/review/issues/
[#645]: https://github.com/kmuto/review/issues/
[#642]: https://github.com/kmuto/review/issues/
[#641]: https://github.com/kmuto/review/issues/
[#640]: https://github.com/kmuto/review/issues/
[#638]: https://github.com/kmuto/review/issues/
[#636]: https://github.com/kmuto/review/issues/
[#634]: https://github.com/kmuto/review/issues/
[#633]: https://github.com/kmuto/review/issues/
[#632]: https://github.com/kmuto/review/issues/
[#630]: https://github.com/kmuto/review/issues/
[#629]: https://github.com/kmuto/review/issues/
[#628]: https://github.com/kmuto/review/issues/
[#627]: https://github.com/kmuto/review/issues/
[#626]: https://github.com/kmuto/review/issues/
[#625]: https://github.com/kmuto/review/issues/
[#618]: https://github.com/kmuto/review/issues/
[#617]: https://github.com/kmuto/review/issues/


# Version 2.0.0 # Version 2.0.0


## New Features ## New Features
Expand Down
4 changes: 2 additions & 2 deletions doc/config.yml.sample
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ secnolevel: 2
# fontdir内から取り込まれる対象となるファイル拡張子。省略した場合は以下 # fontdir内から取り込まれる対象となるファイル拡張子。省略した場合は以下
# font_ext: ["ttf", "woff", "otf"] # font_ext: ["ttf", "woff", "otf"]


# ソースコードハイライトを利用する (pygmentsには外部gemが必要) # ソースコードハイライトを利用する (rouge,pygmentsには外部gemが必要)
# highlight: # highlight:
# html: "pygments" # html: "rouge"
# latex: "listings" # latex: "listings"


# カタログファイル名を指定する # カタログファイル名を指定する
Expand Down
2 changes: 1 addition & 1 deletion doc/config.yml.sample-simple
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ colophon: true
## Syntax Highlighting ## Syntax Highlighting


highlight: highlight:
html: "pygments" html: "rouge"
latex: "listings" latex: "listings"


## for HTML ## for HTML
Expand Down
14 changes: 14 additions & 0 deletions doc/format.ja.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -221,6 +221,20 @@ puts "hello world!"


他章のリストを参照するには、後述の「章ID」を指定し、たとえば `@<list>{advanced|main}``advanced.re` ファイルの章にあるリスト `main` を参照する)と記述します。 他章のリストを参照するには、後述の「章ID」を指定し、たとえば `@<list>{advanced|main}``advanced.re` ファイルの章にあるリスト `main` を参照する)と記述します。


### 行番号の指定

行番号を指定した番号から始めるには、`//firstlinenum`を使います。

例:

```review
//firstlinenum[100]
//listnum[hello][ハローワールド][ruby]{
puts "hello world!"
//}
```


### ソースコード専用の引用 ### ソースコード専用の引用


ソースコードを引用するには次のように記述します。 ソースコードを引用するには次のように記述します。
Expand Down
14 changes: 14 additions & 0 deletions doc/format.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ such as `@<list>{main}`.


When you refer a list in the other chapter, you can use an ID with chapter ID, such like `@<list>{advanced|main}`, to refer a list `main` in `advanced.re`. When you refer a list in the other chapter, you can use an ID with chapter ID, such like `@<list>{advanced|main}`, to refer a list `main` in `advanced.re`.


### define line number of first line in code block

If you want to start with specified number as line number, you can use `firstlinenum` command.

Usage:

```review
//firstlinenum[100]
//listnum[hello][helloworld][ruby]{
puts "hello world!"
//}
```


### Quoting Source Code ### Quoting Source Code


`//source` is for quoting source code. filename is mandatory. `//source` is for quoting source code. filename is mandatory.
Expand Down
Loading

0 comments on commit b85e827

Please sign in to comment.