review-retrovert 0.9.10 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +1 -1
  3. data/.gitignore +0 -1
  4. data/.pinact.yaml +12 -0
  5. data/.ruby-version +1 -1
  6. data/Dockerfile +2 -1
  7. data/Dockerfile.local +13 -0
  8. data/Gemfile.lock +62 -35
  9. data/Makefile +7 -0
  10. data/README.md +2 -1
  11. data/Rakefile +9 -0
  12. data/aqua.yaml +20 -0
  13. data/hooks/post_push +14 -1
  14. data/lib/review/retrovert/cli.rb +10 -2
  15. data/lib/review/retrovert/converter.rb +106 -20
  16. data/lib/review/retrovert/reviewdef.rb +29 -0
  17. data/lib/review/retrovert/sty/review-utbook.cls +7 -0
  18. data/lib/review/retrovert/version.rb +1 -1
  19. data/lib/review/retrovert/yamlconfig.rb +38 -1
  20. data/review-retrovert.gemspec +18 -4
  21. data/zizmor.yml +5 -0
  22. metadata +54 -121
  23. data/.github/FUNDING.yml +0 -4
  24. data/.github/workflows/release.yml +0 -26
  25. data/.github/workflows/retrovert.yml +0 -76
  26. data/testdata/mybook/.gitignore +0 -9
  27. data/testdata/mybook/.textlintrc +0 -11
  28. data/testdata/mybook/README.md +0 -43
  29. data/testdata/mybook/Rakefile +0 -24
  30. data/testdata/mybook/catalog.yml +0 -60
  31. data/testdata/mybook/config-noretrovert.yml +0 -404
  32. data/testdata/mybook/config-retrovert.yml +0 -16
  33. data/testdata/mybook/config-starter.yml +0 -264
  34. data/testdata/mybook/config.yml +0 -404
  35. data/testdata/mybook/contents/00-preface.re +0 -129
  36. data/testdata/mybook/contents/01-install.re +0 -305
  37. data/testdata/mybook/contents/02-tutorial.re +0 -1228
  38. data/testdata/mybook/contents/03-syntax.re +0 -4610
  39. data/testdata/mybook/contents/04-customize.re +0 -1064
  40. data/testdata/mybook/contents/05-faq.re +0 -606
  41. data/testdata/mybook/contents/06-bestpractice.re +0 -1343
  42. data/testdata/mybook/contents/91-compare.re +0 -418
  43. data/testdata/mybook/contents/92-filelist.re +0 -125
  44. data/testdata/mybook/contents/93-background.re +0 -267
  45. data/testdata/mybook/contents/99-postface.re +0 -39
  46. data/testdata/mybook/contents/r0-inner.re +0 -2
  47. data/testdata/mybook/contents/r0-root.re +0 -31
  48. data/testdata/mybook/contents/table.csv +0 -4
  49. data/testdata/mybook/contents/test.txt +0 -1
  50. data/testdata/mybook/css/normalize.css +0 -349
  51. data/testdata/mybook/css/webstyle.css +0 -692
  52. data/testdata/mybook/data/terms.txt +0 -3
  53. data/testdata/mybook/data/words.txt +0 -15
  54. data/testdata/mybook/images/03-syntax/favicon-16x16.png +0 -0
  55. data/testdata/mybook/images/03-syntax/figure_heretop.png +0 -0
  56. data/testdata/mybook/images/03-syntax/index-page.png +0 -0
  57. data/testdata/mybook/images/03-syntax/order-detail.png +0 -0
  58. data/testdata/mybook/images/03-syntax/tw-icon1.jpg +0 -0
  59. data/testdata/mybook/images/03-syntax/tw-icon2.jpg +0 -0
  60. data/testdata/mybook/images/03-syntax/tw-icon3.jpg +0 -0
  61. data/testdata/mybook/images/03-syntax/tw-icon4.jpg +0 -0
  62. data/testdata/mybook/images/04-customize/caption_pagebreak.png +0 -0
  63. data/testdata/mybook/images/04-customize/chaptitlepage_sample.png +0 -0
  64. data/testdata/mybook/images/04-customize/section_decoration_samples.png +0 -0
  65. data/testdata/mybook/images/05-faq/codeblock_rpadding1.png +0 -0
  66. data/testdata/mybook/images/05-faq/codeblock_rpadding2.png +0 -0
  67. data/testdata/mybook/images/05-faq/dummy-image.png +0 -0
  68. data/testdata/mybook/images/06-bestpractice/figure_heretop.png +0 -0
  69. data/testdata/mybook/images/06-bestpractice/font_beramono.png +0 -0
  70. data/testdata/mybook/images/06-bestpractice/heading_design1.png +0 -0
  71. data/testdata/mybook/images/06-bestpractice/heading_design2.png +0 -0
  72. data/testdata/mybook/images/06-bestpractice/margin_book.png +0 -0
  73. data/testdata/mybook/images/06-bestpractice/multiline-title.png +0 -0
  74. data/testdata/mybook/images/06-bestpractice/preface_numbered.png +0 -0
  75. data/testdata/mybook/images/06-bestpractice/program_border.png +0 -0
  76. data/testdata/mybook/images/06-bestpractice/sechead_design_4.png +0 -0
  77. data/testdata/mybook/images/06-bestpractice/section_title_wlines.png +0 -0
  78. data/testdata/mybook/images/06-bestpractice/titlepage-samples.png +0 -0
  79. data/testdata/mybook/images/93-background/bug913.png +0 -0
  80. data/testdata/mybook/images/93-background/slide2.png +0 -0
  81. data/testdata/mybook/images/avatar-b.png +0 -0
  82. data/testdata/mybook/images/avatar-g.png +0 -0
  83. data/testdata/mybook/images/avatar-r.png +0 -0
  84. data/testdata/mybook/images/caution-icon.png +0 -0
  85. data/testdata/mybook/images/cover_a5.pdf +0 -0
  86. data/testdata/mybook/images/cover_b5.pdf +0 -0
  87. data/testdata/mybook/images/info-icon.png +0 -0
  88. data/testdata/mybook/images/tw-icon.jpg +0 -0
  89. data/testdata/mybook/images/warning-icon.png +0 -0
  90. data/testdata/mybook/layouts/layout.epub.erb +0 -29
  91. data/testdata/mybook/layouts/layout.html5.erb +0 -108
  92. data/testdata/mybook/layouts/layout.tex.erb +0 -432
  93. data/testdata/mybook/layouts/layout.tex.erb.orig +0 -386
  94. data/testdata/mybook/lib/hooks/beforetexcompile.rb +0 -55
  95. data/testdata/mybook/lib/ruby/review-book.rb +0 -64
  96. data/testdata/mybook/lib/ruby/review-builder.rb +0 -1342
  97. data/testdata/mybook/lib/ruby/review-cli.rb +0 -58
  98. data/testdata/mybook/lib/ruby/review-compiler.rb +0 -1176
  99. data/testdata/mybook/lib/ruby/review-epubbuilder.rb +0 -33
  100. data/testdata/mybook/lib/ruby/review-epubmaker.rb +0 -609
  101. data/testdata/mybook/lib/ruby/review-htmlbuilder.rb +0 -949
  102. data/testdata/mybook/lib/ruby/review-latexbuilder.rb +0 -1065
  103. data/testdata/mybook/lib/ruby/review-maker.rb +0 -346
  104. data/testdata/mybook/lib/ruby/review-markdownbuilder.rb +0 -945
  105. data/testdata/mybook/lib/ruby/review-markdownmaker.rb +0 -91
  106. data/testdata/mybook/lib/ruby/review-monkeypatch.rb +0 -93
  107. data/testdata/mybook/lib/ruby/review-pdfmaker.rb +0 -546
  108. data/testdata/mybook/lib/ruby/review-textbuilder.rb +0 -36
  109. data/testdata/mybook/lib/ruby/review-tocparser.rb +0 -285
  110. data/testdata/mybook/lib/ruby/review-webmaker.rb +0 -448
  111. data/testdata/mybook/lib/tasks/mytasks.rake +0 -31
  112. data/testdata/mybook/lib/tasks/review.rake +0 -156
  113. data/testdata/mybook/lib/tasks/review.rake.orig +0 -72
  114. data/testdata/mybook/lib/tasks/starter.rake +0 -470
  115. data/testdata/mybook/locale.yml +0 -6
  116. data/testdata/mybook/review-ext.rb +0 -206
  117. data/testdata/mybook/sty/indexstyle.ist +0 -25
  118. data/testdata/mybook/sty/jumoline.sty +0 -310
  119. data/testdata/mybook/sty/mycolophon.sty +0 -81
  120. data/testdata/mybook/sty/mystyle.sty +0 -8
  121. data/testdata/mybook/sty/mytextsize.sty +0 -90
  122. data/testdata/mybook/sty/mytitlepage.sty +0 -126
  123. data/testdata/mybook/sty/review-base.sty +0 -276
  124. data/testdata/mybook/sty/reviewmacro.sty +0 -60
  125. data/testdata/mybook/sty/starter-codeblock.sty +0 -463
  126. data/testdata/mybook/sty/starter-color.sty +0 -134
  127. data/testdata/mybook/sty/starter-font.sty +0 -112
  128. data/testdata/mybook/sty/starter-heading.sty +0 -561
  129. data/testdata/mybook/sty/starter-misc.sty +0 -894
  130. data/testdata/mybook/sty/starter-note.sty +0 -180
  131. data/testdata/mybook/sty/starter-section.sty +0 -262
  132. data/testdata/mybook/sty/starter-talklist.sty +0 -105
  133. data/testdata/mybook/sty/starter-toc.sty +0 -72
  134. data/testdata/mybook/sty/starter-util.sty +0 -35
  135. data/testdata/mybook/sty/starter.sty +0 -36
  136. data/testdata/mybook/style.css +0 -597
@@ -1,285 +0,0 @@
1
- #
2
- # Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto
3
- # 2002-2007 Minero Aoki
4
- #
5
- # This program is free software.
6
- # You can distribute or modify this program under the terms of
7
- # the GNU LGPL, Lesser General Public License version 2.1.
8
- # For details of the GNU LGPL, see the file "COPYING".
9
- #
10
-
11
- require 'review/preprocessor'
12
- require 'review/book'
13
- require 'review/textbuilder'
14
-
15
- module ReVIEW
16
-
17
-
18
- class TOCParser
19
-
20
- def self.parse(chap)
21
- f = StringIO.new(chap.content, 'r:BOM|utf-8')
22
- stream = Preprocessor::Strip.new(f)
23
- parser = self.new
24
- return parser.parse(stream, chap).map {|root|
25
- root.number = chap.number
26
- root
27
- }
28
- end
29
-
30
- def self.chapter_node(chap)
31
- toc = self.parse(chap)
32
- if toc.size != 1
33
- $stderr.puts "warning: chapter #{toc.join} contains more than 1 chapter"
34
- end
35
- toc.first
36
- end
37
-
38
- def parse(stream, chap)
39
- f = stream
40
- roots = [] # list of chapters
41
- node_stack = []
42
- filename = chap.path
43
- while (line = f.gets)
44
- case line
45
- when /\A\#@\+\+\+$/
46
- beg = f.lineno
47
- line = f.gets() while line && line !~ /\A\#@---$/
48
- line or
49
- error! filename, beg, 'unterminated list'
50
- next
51
- when /\A\#@/
52
- # do nothing
53
- next
54
- when /\A\s*\z/
55
- # do nothing
56
- next
57
- when /\A(={2,})[\[\s\{]/
58
- lev = $1.size
59
- lev <= 6 or
60
- error! filename, f.lineno, "section level too deep: #{lev}"
61
- label = get_label(line)
62
- if node_stack.empty?
63
- # missing chapter label
64
- dummy_chapter = Chapter.new(label, chap)
65
- node_stack.push dummy_chapter
66
- roots.push dummy_chapter
67
- end
68
- next if label.start_with?('[/') # ex) "[/column]"
69
- sec = Section.new(lev, label.gsub(/\A\{.*?\}\s?/, ''))
70
- node_stack.pop until node_stack.last.level < sec.level
71
- node_stack.last.add_child sec
72
- node_stack.push sec
73
-
74
- when /\A=[^=]/
75
- label = get_label(line)
76
- node_stack.clear
77
- new_chapter = Chapter.new(label, chap)
78
- node_stack.push new_chapter
79
- roots.push new_chapter
80
-
81
- when %r{\A//\w+(?:\[.*?\])*\{\s*\z}
82
- ! node_stack.empty? or
83
- error! filename, f.lineno, 'list found before section label'
84
- node_stack.last.add_child(list = List.new)
85
- beg = f.lineno
86
- list.add line
87
- while (line = f.gets) && ! line.start_with?('//}')
88
- list.add line
89
- end
90
- line or
91
- error! filename, beg, 'unterminated list'
92
-
93
- when /\A\/\/\w/
94
- # do nothing
95
- next
96
- else
97
- # if node_stack.empty?
98
- # error! filename, f.lineno, 'text found before section label'
99
- # end
100
- next if node_stack.empty?
101
- node_stack.last.add_child(par = Paragraph.new(chap))
102
- par.add line
103
- while (line = f.gets) && line !~ /\A\s*\z/
104
- par.add line
105
- end
106
- end
107
- end
108
-
109
- roots
110
- end
111
-
112
- def get_label(line)
113
- line = line.strip.sub(/\A=+\s*/, '')
114
- compile_label(line)
115
- end
116
-
117
- def compile_label(line)
118
- b = ReVIEW::TEXTBuilder.new
119
- dummy_book = ReVIEW::Book::Base.load
120
- dummy_chapter = ReVIEW::Book::Chapter.new(dummy_book, 1, '-', nil, StringIO.new)
121
- dummy_loc = Location.new('', StringIO.new)
122
- b.bind(ReVIEW::Compiler.new(b), dummy_chapter, dummy_loc)
123
- b.compile_inline(line)
124
- end
125
-
126
- def error!(filename, lineno, msg)
127
- raise "#{filename}:#{lineno}: #{msg}"
128
- end
129
-
130
- # class Node
131
- # def initialize(children = [])
132
- # @children = children
133
- # end
134
- #
135
- # attr_reader :children
136
- #
137
- # def add_child(c)
138
- # @children.push c
139
- # end
140
- #
141
- # def each_node(&block)
142
- # @children.each do |c|
143
- # yield c
144
- # c.each(&block)
145
- # end
146
- # end
147
- #
148
- # def each_child(&block)
149
- # @children.each(&block)
150
- # end
151
- #
152
- # def chapter?
153
- # false
154
- # end
155
- #
156
- # def each_section(&block)
157
- # @children.each { |n| n.yield_section(&block) }
158
- # end
159
- #
160
- # def each_section_with_index
161
- # i = 0
162
- # each_section do |n|
163
- # yield n, i
164
- # i += 1
165
- # end
166
- # end
167
- #
168
- # def section_size
169
- # cnt = 0
170
- # @children.each { |n| n.yield_section { cnt += 1 } }
171
- # cnt
172
- # end
173
- # end
174
- #
175
- # class Section < Node
176
- # def initialize(level, label, path = nil)
177
- # super()
178
- # @level = level
179
- # @label = label
180
- # @filename = path ? real_filename(path) : nil
181
- # end
182
- #
183
- # def real_filename(path)
184
- # if FileTest.symlink?(path)
185
- # File.basename(File.readlink(path))
186
- # else
187
- # File.basename(path)
188
- # end
189
- # end
190
- # private :real_filename
191
- #
192
- # attr_reader :level
193
- # attr_reader :label
194
- #
195
- # def estimated_lines
196
- # @children.inject(0) { |sum, n| sum + n.estimated_lines }
197
- # end
198
- #
199
- # def yield_section
200
- # yield self
201
- # end
202
- #
203
- # def inspect
204
- # "#<#{self.class} level=#{@level} #{@label}>"
205
- # end
206
- # end
207
- #
208
- # class Chapter < Section
209
- # def initialize(label, chap)
210
- # super 1, label, chap.path
211
- # @chapter = chap
212
- # @chapter_id = chap.id
213
- # @path = chap.path
214
- # @page_metric = chap.book.page_metric
215
- # @volume = nil
216
- # @number = nil
217
- # end
218
- #
219
- # attr_accessor :number
220
- #
221
- # def chapter?
222
- # true
223
- # end
224
- #
225
- # attr_reader :chapter_id
226
- #
227
- # def volume
228
- # return @volume if @volume
229
- # @volume = @chapter.volume
230
- # @volume.lines = estimated_lines
231
- # @volume
232
- # end
233
- #
234
- # def inspect
235
- # "#<#{self.class} #{@filename}>"
236
- # end
237
- # end
238
- #
239
- # class Paragraph < Node
240
- # def initialize(chap)
241
- # @bytes = 0
242
- # @page_metric = chap.book.page_metric
243
- # end
244
- #
245
- # def inspect
246
- # "#<#{self.class}>"
247
- # end
248
- #
249
- # def add(line)
250
- # @bytes += line.strip.bytesize
251
- # end
252
- #
253
- # def estimated_lines
254
- # (@bytes + 2) / @page_metric.text.n_columns + 1
255
- # end
256
- #
257
- # def yield_section
258
- # end
259
- # end
260
- #
261
- # class List < Node
262
- # def initialize
263
- # @lines = 0
264
- # end
265
- #
266
- # def inspect
267
- # "#<#{self.class}>"
268
- # end
269
- #
270
- # def add(_line)
271
- # @lines += 1
272
- # end
273
- #
274
- # def estimated_lines
275
- # @lines + 2
276
- # end
277
- #
278
- # def yield_section
279
- # end
280
- # end
281
-
282
- end
283
-
284
-
285
- end