Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into bibliography
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmsnr committed Dec 12, 2020
2 parents 6a20de8 + dfc1fd7 commit c2199f3
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 199 deletions.
6 changes: 5 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
AllCops:
Exclude:
- lib/lineinput.rb
- lib/uuid.rb
- test/syntax-book/*
- tmp/*
Expand Down Expand Up @@ -135,6 +134,9 @@ Style/ClassMethods:
Style/CommentedKeyword:
Enabled: false

Style/DocumentDynamicEvalDefinition:
Enabled: false

Style/FloatDivision:
Enabled: false

Expand Down Expand Up @@ -592,6 +594,8 @@ Naming/VariableName:
Naming/VariableNumber:
EnforcedStyle: normalcase
Enabled: true
Exclude:
- test/*

#### Security

Expand Down
5 changes: 1 addition & 4 deletions bin/review-check
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def each_paragraph(f)
case line
when /\A\#@ok\((.*)\)/
@review_utils_word_ok = $1
when /\A\#@/
when /\A\#@/, /\A\s*\z/
# do nothing
next
when %r{\A//caption\{(.*?)//\}}
Expand All @@ -145,9 +145,6 @@ def each_paragraph(f)
end
when /\A=/
yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno
when /\A\s*\z/
# skip
next
else
buf = [line.strip]
lineno = f.lineno
Expand Down
155 changes: 0 additions & 155 deletions lib/lineinput.rb

This file was deleted.

2 changes: 2 additions & 0 deletions lib/review/book/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def find_first_header_option
nil
rescue ArgumentError => e
raise ReVIEW::CompileError, "#{@name}: #{e}"
rescue SyntaxError => e
raise ReVIEW::SyntaxError, "#{@name}:#{f.lineno}: #{e}"
end
end

Expand Down
21 changes: 14 additions & 7 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

module ReVIEW
class Compiler
MAX_HEADLINE_LEVEL = 6

def initialize(builder)
@builder = builder

Expand Down Expand Up @@ -333,6 +335,8 @@ def do_compile
end
end
close_all_tagged_section
rescue SyntaxError => e
error e
end

def compile_minicolumn_begin(name, caption = nil)
Expand Down Expand Up @@ -366,24 +370,27 @@ def compile_headline(line)
@headline_indexs ||= [@chapter.number.to_i - 1]
m = /\A(=+)(?:\[(.+?)\])?(?:\{(.+?)\})?(.*)/.match(line)
level = m[1].size
if level > MAX_HEADLINE_LEVEL
raise CompileError, "Invalid header: max headline level is #{MAX_HEADLINE_LEVEL}"
end
tag = m[2]
label = m[3]
caption = m[4].strip
index = level - 1
if tag
if tag !~ %r{\A/}
if caption.empty?
warn 'headline is empty.'
end
close_current_tagged_section(level)
open_tagged_section(tag, level, label, caption)
else
if tag.start_with?('/')
open_tag = tag[1..-1]
prev_tag_info = @tagged_section.pop
if prev_tag_info.nil? || prev_tag_info.first != open_tag
error "#{open_tag} is not opened."
end
close_tagged_section(*prev_tag_info)
else
if caption.empty?
warn 'headline is empty.'
end
close_current_tagged_section(level)
open_tagged_section(tag, level, label, caption)
end
else
if caption.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/review/idgxmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,10 @@ def inline_chapref(id)
chs = ['', '「', '」']
if @book.config['chapref']
chs2 = @book.config['chapref'].split(',')
if chs2.size != 3
error '--chapsplitter must have exactly 3 parameters with comma.'
else
if chs2.size == 3
chs = chs2
else
error '--chapsplitter must have exactly 3 parameters with comma.'
end
end
s = "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
Expand Down
12 changes: 6 additions & 6 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ def notoc_end(level)
end

def nodisp_begin(level, _label, caption)
if @output.pos != 0
blank
else
if @output.pos == 0
puts macro('clearpage')
else
blank
end
puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption))
# FIXME: headings
Expand Down Expand Up @@ -1377,10 +1377,10 @@ def index(str)
else
if item =~ /\A[[:ascii:]]+\Z/ || @index_mecab.nil?
esc_item = escape_index(escape(item))
if esc_item != item
"#{escape_index(item)}@#{esc_item}"
else
if esc_item == item
esc_item
else
"#{escape_index(item)}@#{esc_item}"
end
else
yomi = NKF.nkf('-w --hiragana', @index_mecab.parse(item).force_encoding('UTF-8').chomp)
Expand Down
Loading

0 comments on commit c2199f3

Please sign in to comment.