coradoc 1.1.8 → 2.0.12

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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -1
  3. data/Rakefile +3 -12
  4. data/exe/coradoc +21 -2
  5. data/lib/coradoc/cli.rb +185 -91
  6. data/lib/coradoc/configurable.rb +527 -0
  7. data/lib/coradoc/coradoc.rb +463 -0
  8. data/lib/coradoc/core_model/annotation_block.rb +57 -0
  9. data/lib/coradoc/core_model/base.rb +172 -0
  10. data/lib/coradoc/core_model/bibliography.rb +41 -0
  11. data/lib/coradoc/core_model/bibliography_entry.rb +48 -0
  12. data/lib/coradoc/core_model/block.rb +63 -0
  13. data/lib/coradoc/core_model/children_content.rb +53 -0
  14. data/lib/coradoc/core_model/comment_block.rb +10 -0
  15. data/lib/coradoc/core_model/definition_item.rb +46 -0
  16. data/lib/coradoc/core_model/definition_list.rb +28 -0
  17. data/lib/coradoc/core_model/element_attribute.rb +26 -0
  18. data/lib/coradoc/core_model/example_block.rb +10 -0
  19. data/lib/coradoc/core_model/footnote.rb +92 -0
  20. data/lib/coradoc/core_model/horizontal_rule_block.rb +10 -0
  21. data/lib/coradoc/core_model/id_generator.rb +16 -0
  22. data/lib/coradoc/core_model/image.rb +66 -0
  23. data/lib/coradoc/core_model/inline_element.rb +140 -0
  24. data/lib/coradoc/core_model/list_block.rb +135 -0
  25. data/lib/coradoc/core_model/list_item.rb +142 -0
  26. data/lib/coradoc/core_model/listing_block.rb +13 -0
  27. data/lib/coradoc/core_model/literal_block.rb +10 -0
  28. data/lib/coradoc/core_model/metadata.rb +79 -0
  29. data/lib/coradoc/core_model/open_block.rb +10 -0
  30. data/lib/coradoc/core_model/paragraph_block.rb +10 -0
  31. data/lib/coradoc/core_model/pass_block.rb +10 -0
  32. data/lib/coradoc/core_model/quote_block.rb +12 -0
  33. data/lib/coradoc/core_model/reviewer_block.rb +10 -0
  34. data/lib/coradoc/core_model/sidebar_block.rb +10 -0
  35. data/lib/coradoc/core_model/source_block.rb +10 -0
  36. data/lib/coradoc/core_model/structural_element.rb +94 -0
  37. data/lib/coradoc/core_model/table.rb +148 -0
  38. data/lib/coradoc/core_model/term.rb +53 -0
  39. data/lib/coradoc/core_model/text_content.rb +22 -0
  40. data/lib/coradoc/core_model/toc.rb +105 -0
  41. data/lib/coradoc/core_model/toc_generator.rb +151 -0
  42. data/lib/coradoc/core_model/verse_block.rb +12 -0
  43. data/lib/coradoc/core_model.rb +77 -0
  44. data/lib/coradoc/document_builder.rb +184 -0
  45. data/lib/coradoc/document_manipulator.rb +203 -0
  46. data/lib/coradoc/errors.rb +312 -0
  47. data/lib/coradoc/format_module.rb +49 -0
  48. data/lib/coradoc/hooks.rb +176 -0
  49. data/lib/coradoc/input.rb +17 -7
  50. data/lib/coradoc/logger.rb +54 -0
  51. data/lib/coradoc/output.rb +17 -6
  52. data/lib/coradoc/performance_regression.rb +109 -0
  53. data/lib/coradoc/processor_registry.rb +50 -0
  54. data/lib/coradoc/query.rb +455 -0
  55. data/lib/coradoc/registry.rb +156 -0
  56. data/lib/coradoc/serializer/registry.rb +150 -0
  57. data/lib/coradoc/transform.rb +11 -0
  58. data/lib/coradoc/validation.rb +646 -0
  59. data/lib/coradoc/version.rb +1 -1
  60. data/lib/coradoc/visitor.rb +283 -0
  61. data/lib/coradoc.rb +40 -19
  62. metadata +67 -277
  63. data/.editorconfig +0 -15
  64. data/.envrc +0 -1
  65. data/.irbrc +0 -1
  66. data/.pryrc.sample +0 -1
  67. data/.rubocop.yml +0 -14
  68. data/.rubocop_todo.yml +0 -179
  69. data/CHANGELOG.md +0 -9
  70. data/CODE_OF_CONDUCT.md +0 -84
  71. data/Dockerfile +0 -19
  72. data/Gemfile +0 -16
  73. data/LICENSE.txt +0 -21
  74. data/Makefile +0 -35
  75. data/README.Docker.adoc +0 -57
  76. data/README.adoc +0 -119
  77. data/coradoc.gemspec +0 -40
  78. data/docker-compose.yml +0 -14
  79. data/exe/reverse_adoc +0 -81
  80. data/exe/w2a +0 -60
  81. data/flake.lock +0 -114
  82. data/flake.nix +0 -135
  83. data/lib/coradoc/converter.rb +0 -144
  84. data/lib/coradoc/document.rb +0 -77
  85. data/lib/coradoc/element/admonition.rb +0 -18
  86. data/lib/coradoc/element/attribute.rb +0 -36
  87. data/lib/coradoc/element/attribute_list.rb +0 -138
  88. data/lib/coradoc/element/audio.rb +0 -33
  89. data/lib/coradoc/element/author.rb +0 -24
  90. data/lib/coradoc/element/base.rb +0 -92
  91. data/lib/coradoc/element/bibliography.rb +0 -24
  92. data/lib/coradoc/element/bibliography_entry.rb +0 -24
  93. data/lib/coradoc/element/block/core.rb +0 -76
  94. data/lib/coradoc/element/block/example.rb +0 -23
  95. data/lib/coradoc/element/block/listing.rb +0 -21
  96. data/lib/coradoc/element/block/literal.rb +0 -21
  97. data/lib/coradoc/element/block/open.rb +0 -22
  98. data/lib/coradoc/element/block/pass.rb +0 -21
  99. data/lib/coradoc/element/block/quote.rb +0 -19
  100. data/lib/coradoc/element/block/reviewer_comment.rb +0 -19
  101. data/lib/coradoc/element/block/side.rb +0 -19
  102. data/lib/coradoc/element/block/sourcecode.rb +0 -21
  103. data/lib/coradoc/element/block.rb +0 -17
  104. data/lib/coradoc/element/break.rb +0 -11
  105. data/lib/coradoc/element/comment_block.rb +0 -22
  106. data/lib/coradoc/element/comment_line.rb +0 -18
  107. data/lib/coradoc/element/document_attributes.rb +0 -33
  108. data/lib/coradoc/element/header.rb +0 -22
  109. data/lib/coradoc/element/image/block_image.rb +0 -32
  110. data/lib/coradoc/element/image/core.rb +0 -58
  111. data/lib/coradoc/element/image/inline_image.rb +0 -12
  112. data/lib/coradoc/element/image.rb +0 -10
  113. data/lib/coradoc/element/include.rb +0 -18
  114. data/lib/coradoc/element/inline/anchor.rb +0 -19
  115. data/lib/coradoc/element/inline/attribute_reference.rb +0 -19
  116. data/lib/coradoc/element/inline/bold.rb +0 -25
  117. data/lib/coradoc/element/inline/cross_reference.rb +0 -46
  118. data/lib/coradoc/element/inline/footnote.rb +0 -24
  119. data/lib/coradoc/element/inline/hard_line_break.rb +0 -11
  120. data/lib/coradoc/element/inline/highlight.rb +0 -25
  121. data/lib/coradoc/element/inline/italic.rb +0 -25
  122. data/lib/coradoc/element/inline/link.rb +0 -42
  123. data/lib/coradoc/element/inline/monospace.rb +0 -25
  124. data/lib/coradoc/element/inline/quotation.rb +0 -20
  125. data/lib/coradoc/element/inline/small.rb +0 -19
  126. data/lib/coradoc/element/inline/span.rb +0 -37
  127. data/lib/coradoc/element/inline/subscript.rb +0 -20
  128. data/lib/coradoc/element/inline/superscript.rb +0 -20
  129. data/lib/coradoc/element/inline/underline.rb +0 -19
  130. data/lib/coradoc/element/inline.rb +0 -23
  131. data/lib/coradoc/element/list/core.rb +0 -51
  132. data/lib/coradoc/element/list/definition.rb +0 -29
  133. data/lib/coradoc/element/list/ordered.rb +0 -17
  134. data/lib/coradoc/element/list/unordered.rb +0 -17
  135. data/lib/coradoc/element/list.rb +0 -13
  136. data/lib/coradoc/element/list_item.rb +0 -98
  137. data/lib/coradoc/element/list_item_definition.rb +0 -32
  138. data/lib/coradoc/element/paragraph.rb +0 -37
  139. data/lib/coradoc/element/revision.rb +0 -27
  140. data/lib/coradoc/element/section.rb +0 -62
  141. data/lib/coradoc/element/table.rb +0 -91
  142. data/lib/coradoc/element/tag.rb +0 -19
  143. data/lib/coradoc/element/term.rb +0 -22
  144. data/lib/coradoc/element/text_element.rb +0 -92
  145. data/lib/coradoc/element/title.rb +0 -62
  146. data/lib/coradoc/element/video.rb +0 -50
  147. data/lib/coradoc/generator.rb +0 -19
  148. data/lib/coradoc/input/adoc.rb +0 -30
  149. data/lib/coradoc/input/docx.rb +0 -64
  150. data/lib/coradoc/input/html/LICENSE.txt +0 -25
  151. data/lib/coradoc/input/html/README.adoc +0 -308
  152. data/lib/coradoc/input/html/cleaner.rb +0 -142
  153. data/lib/coradoc/input/html/config.rb +0 -77
  154. data/lib/coradoc/input/html/converters/a.rb +0 -52
  155. data/lib/coradoc/input/html/converters/aside.rb +0 -16
  156. data/lib/coradoc/input/html/converters/audio.rb +0 -29
  157. data/lib/coradoc/input/html/converters/base.rb +0 -108
  158. data/lib/coradoc/input/html/converters/blockquote.rb +0 -22
  159. data/lib/coradoc/input/html/converters/br.rb +0 -15
  160. data/lib/coradoc/input/html/converters/bypass.rb +0 -81
  161. data/lib/coradoc/input/html/converters/code.rb +0 -23
  162. data/lib/coradoc/input/html/converters/div.rb +0 -19
  163. data/lib/coradoc/input/html/converters/dl.rb +0 -62
  164. data/lib/coradoc/input/html/converters/drop.rb +0 -26
  165. data/lib/coradoc/input/html/converters/em.rb +0 -21
  166. data/lib/coradoc/input/html/converters/figure.rb +0 -25
  167. data/lib/coradoc/input/html/converters/h.rb +0 -42
  168. data/lib/coradoc/input/html/converters/head.rb +0 -23
  169. data/lib/coradoc/input/html/converters/hr.rb +0 -15
  170. data/lib/coradoc/input/html/converters/ignore.rb +0 -20
  171. data/lib/coradoc/input/html/converters/img.rb +0 -110
  172. data/lib/coradoc/input/html/converters/li.rb +0 -17
  173. data/lib/coradoc/input/html/converters/mark.rb +0 -19
  174. data/lib/coradoc/input/html/converters/markup.rb +0 -31
  175. data/lib/coradoc/input/html/converters/math.rb +0 -38
  176. data/lib/coradoc/input/html/converters/ol.rb +0 -65
  177. data/lib/coradoc/input/html/converters/p.rb +0 -23
  178. data/lib/coradoc/input/html/converters/pass_through.rb +0 -17
  179. data/lib/coradoc/input/html/converters/pre.rb +0 -55
  180. data/lib/coradoc/input/html/converters/q.rb +0 -16
  181. data/lib/coradoc/input/html/converters/strong.rb +0 -20
  182. data/lib/coradoc/input/html/converters/sub.rb +0 -22
  183. data/lib/coradoc/input/html/converters/sup.rb +0 -22
  184. data/lib/coradoc/input/html/converters/table.rb +0 -319
  185. data/lib/coradoc/input/html/converters/td.rb +0 -81
  186. data/lib/coradoc/input/html/converters/text.rb +0 -32
  187. data/lib/coradoc/input/html/converters/th.rb +0 -18
  188. data/lib/coradoc/input/html/converters/tr.rb +0 -22
  189. data/lib/coradoc/input/html/converters/video.rb +0 -29
  190. data/lib/coradoc/input/html/converters.rb +0 -59
  191. data/lib/coradoc/input/html/errors.rb +0 -14
  192. data/lib/coradoc/input/html/html_converter.rb +0 -168
  193. data/lib/coradoc/input/html/plugin.rb +0 -131
  194. data/lib/coradoc/input/html/plugins/plateau.rb +0 -213
  195. data/lib/coradoc/input/html/postprocessor.rb +0 -220
  196. data/lib/coradoc/input/html.rb +0 -61
  197. data/lib/coradoc/legacy_parser.rb +0 -200
  198. data/lib/coradoc/oscal.rb +0 -99
  199. data/lib/coradoc/output/adoc.rb +0 -19
  200. data/lib/coradoc/output/coradoc_tree_debug.rb +0 -21
  201. data/lib/coradoc/parser/asciidoc/admonition.rb +0 -24
  202. data/lib/coradoc/parser/asciidoc/attribute_list.rb +0 -89
  203. data/lib/coradoc/parser/asciidoc/base.rb +0 -87
  204. data/lib/coradoc/parser/asciidoc/bibliography.rb +0 -29
  205. data/lib/coradoc/parser/asciidoc/block.rb +0 -94
  206. data/lib/coradoc/parser/asciidoc/citation.rb +0 -30
  207. data/lib/coradoc/parser/asciidoc/content.rb +0 -64
  208. data/lib/coradoc/parser/asciidoc/document_attributes.rb +0 -25
  209. data/lib/coradoc/parser/asciidoc/header.rb +0 -29
  210. data/lib/coradoc/parser/asciidoc/inline.rb +0 -195
  211. data/lib/coradoc/parser/asciidoc/list.rb +0 -115
  212. data/lib/coradoc/parser/asciidoc/paragraph.rb +0 -54
  213. data/lib/coradoc/parser/asciidoc/section.rb +0 -61
  214. data/lib/coradoc/parser/asciidoc/table.rb +0 -32
  215. data/lib/coradoc/parser/asciidoc/term.rb +0 -41
  216. data/lib/coradoc/parser/asciidoc/text.rb +0 -158
  217. data/lib/coradoc/parser/base.rb +0 -40
  218. data/lib/coradoc/parser.rb +0 -11
  219. data/lib/coradoc/reverse_adoc.rb +0 -18
  220. data/lib/coradoc/transformer.rb +0 -476
  221. data/lib/coradoc/util.rb +0 -12
  222. data/lib/reverse_adoc.rb +0 -20
  223. data/utils/inspect_asciidoc.rb +0 -29
  224. data/utils/parser_analyzer.rb +0 -66
  225. data/utils/round_trip.rb +0 -53
@@ -1,195 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Inline
5
- def attribute_reference
6
- str("{").present? >> str("{") >>
7
- match("[a-zA-Z0-9_-]").repeat(1).as(:attribute_reference) >>
8
- str("}")
9
- end
10
-
11
- def bold_constrained
12
- (str("*").present? >> str("*") >>
13
- match("[^*]").repeat(1).as(:text).repeat(1, 1) >>
14
- str("*") >> str("*").absent? >>
15
- str("\n\n").absent?
16
- ).as(:bold_constrained)
17
- end
18
-
19
- def bold_unconstrained
20
- (str("**").present? >> str("**") >>
21
- match("[^*]").repeat(1).as(:text).repeat(1, 1) >>
22
- str("**")
23
- ).as(:bold_unconstrained)
24
- end
25
-
26
- def span_constrained
27
- (attribute_list >>
28
- str("#") >>
29
- match("[^#]").repeat(1).as(:text) >>
30
- str("#") >> str("#").absent?
31
- ).as(:span_constrained)
32
- end
33
-
34
- def span_unconstrained
35
- (attribute_list >>
36
- str("##") >>
37
- match("[^#]").repeat(1).as(:text) >>
38
- str("##")
39
- ).as(:span_unconstrained)
40
- end
41
-
42
- def italic_constrained
43
- (str("_") >> str("_").absent? >>
44
- match("[^_]").repeat(1).as(:text).repeat(1, 1) >>
45
- str("_") >> str("_").absent?
46
- ).as(:italic_constrained)
47
- end
48
-
49
- def italic_unconstrained
50
- (str("__") >>
51
- match("[^_]").repeat(1).as(:text).repeat(1, 1) >>
52
- str("__")
53
- ).as(:italic_unconstrained)
54
- end
55
-
56
- def highlight_constrained
57
- (str("#") >>
58
- match("[^#]").repeat(1).as(:text).repeat(1, 1) >>
59
- str("#") >> str("#").absent?
60
- ).as(:highlight_constrained)
61
- end
62
-
63
- def highlight_unconstrained
64
- (str("##") >>
65
- match("[^#]").repeat(1).as(:text).repeat(1, 1) >>
66
- str("##")
67
- ).as(:highlight_unconstrained)
68
- end
69
-
70
- def monospace_constrained
71
- (str("`") >>
72
- match("[^`]").repeat(1).as(:text).repeat(1, 1) >>
73
- str("`") >> str("`").absent?
74
- ).as(:monospace_constrained)
75
- end
76
-
77
- def monospace_unconstrained
78
- (str("``") >>
79
- match("[^`]").repeat(1).as(:text).repeat(1, 1) >>
80
- str("``")
81
- ).as(:monospace_unconstrained)
82
- end
83
-
84
- def superscript
85
- (str("^") >>
86
- match("[^^]").repeat(1).as(:text).repeat(1, 1) >>
87
- str("^")
88
- ).as(:superscript)
89
- end
90
-
91
- def subscript
92
- (str("~") >>
93
- match("[^~]").repeat(1).as(:text).repeat(1, 1) >>
94
- str("~")
95
- ).as(:subscript)
96
- end
97
-
98
- def span
99
- attribute_list >>
100
- (str("#") >>
101
- match("[^#]").repeat(1).as(:text) >>
102
- str("#") >> str("#").absent?
103
- ).as(:span)
104
- end
105
-
106
- def link
107
- ((str("http").present? | str("https").present? | str("ftp").present?) >>
108
- match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
109
- (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
110
- ).as(:link) |
111
- (str("link:").present? >> str("link:") >>
112
- match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
113
- (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
114
- ).as(:link)
115
- end
116
-
117
- def inline_image
118
- (str("image:").present? >> str("image:") >>
119
- match("[A-Za-z0-9_.\\-:/&?=+,%#~;]+").repeat(1).as(:path) >>
120
- (str("[") >> match("[^\\]]").repeat(1).as(:text) >> str("]")).maybe
121
- ).as(:inline_image)
122
- end
123
-
124
- def underline
125
- (attribute_list >> match("\\[.underline\\]").as(:role) >>
126
- str("#") >>
127
- match("[^#]").repeat(1).as(:text) >>
128
- str("#")
129
- ).as(:underline)
130
- end
131
-
132
- def small
133
- (attribute_list >> match("\\[.small\\]").as(:role) >>
134
- str("#") >>
135
- match("[^#]").repeat(1).as(:text) >>
136
- str("#")
137
- ).as(:small)
138
- end
139
-
140
- def inline_chars?
141
- match('[\[*#_{<^~`]').present? |
142
- str("http").present? |
143
- str("https").present? |
144
- str("link:").present? |
145
- str("image:").present? |
146
- term_type.present? |
147
- str("footnote").present?
148
- end
149
-
150
- def inline
151
- bold_unconstrained |
152
- bold_constrained |
153
- span_unconstrained |
154
- span_constrained |
155
- italic_unconstrained |
156
- italic_constrained |
157
- highlight_unconstrained |
158
- highlight_constrained |
159
- monospace_unconstrained |
160
- monospace_constrained |
161
- superscript |
162
- subscript |
163
- attribute_reference |
164
- cross_reference |
165
- term_inline |
166
- term_inline2 |
167
- footnote |
168
- link |
169
- inline_image |
170
- underline |
171
- small
172
- end
173
-
174
- def text_unformatted
175
- # line_not_text? >>
176
- (inline.absent? >>
177
- match("[^\n]")
178
- ).repeat(1)
179
- end
180
-
181
- def text_formatted
182
- (inline_chars? >> inline)
183
- end
184
-
185
- def text_any
186
- (text_formatted |
187
- text_unformatted.as(:text)
188
- ).repeat(2) |
189
- text_formatted.repeat(1, 1) |
190
- text_unformatted
191
- end
192
- end
193
- end
194
- end
195
- end
@@ -1,115 +0,0 @@
1
- # $DEBUG = true
2
- module Coradoc
3
- module Parser
4
- module Asciidoc
5
- module List
6
- def list(nesting_level = 1)
7
- (
8
- unordered_list(nesting_level) |
9
- ordered_list(nesting_level) |
10
- definition_list
11
- ).as(:list)
12
- end
13
-
14
- def list_continuation
15
- line_start? >> str("+\n")
16
- end
17
-
18
- def ordered_list(nesting_level = 1)
19
- attrs = (attribute_list >> newline).maybe
20
- r = olist_item(nesting_level)
21
- attrs >> olist_item(nesting_level).present? >> r.repeat(1).as(:ordered)
22
- end
23
-
24
- def unordered_list(nesting_level = 1)
25
- attrs = (attribute_list >> newline).maybe
26
- r = ulist_item(nesting_level)
27
- attrs >> r.repeat(1).as(:unordered)
28
- end
29
-
30
- def definition_list(delimiter = "::")
31
- (attribute_list >> newline).maybe >>
32
- dlist_item(delimiter).repeat(1).as(:definition_list) >>
33
- dlist_item(delimiter).absent?
34
- end
35
-
36
- def list_marker(nesting_level = 1)
37
- olist_marker(nesting_level) | ulist_marker(nesting_level)
38
- end
39
-
40
- def olist_marker(nesting_level = 1)
41
- line_start? >> str("." * nesting_level) >> str(".").absent?
42
- end
43
-
44
- def olist_item(nesting_level = 1)
45
- item = olist_marker(nesting_level).as(:marker) >>
46
- match("\n").absent? >> space >> text_line(true)
47
- # >>
48
- # (list_continuation.present? >> list_continuation >>
49
- # paragraph #| example_block(n_deep: 1)
50
- # ).repeat(0).as(:attached)
51
-
52
- att = (list_continuation.present? >>
53
- list_continuation >>
54
- (admonition_line | paragraph | block) # (n_deep: 1))
55
- ).repeat(0).as(:attached)
56
- item = item >> att.maybe
57
-
58
- if nesting_level <= 4
59
- item = item >>
60
- (list_marker(nesting_level + 1).present? >>
61
- list(nesting_level + 1)).repeat(0).as(:nested) # ).maybe
62
- end
63
- olist_marker(nesting_level).present? >> item.as(:list_item)
64
- end
65
-
66
- def ulist_marker(nesting_level = 1)
67
- line_start? >> str("*" * nesting_level) >> str("*").absent?
68
- end
69
-
70
- def ulist_item(nesting_level = 1)
71
- item = ulist_marker(nesting_level).as(:marker) >>
72
- str(" [[[").absent? >>
73
- match("\n").absent? >> space >> text_line(true)
74
-
75
- att = (list_continuation.present? >>
76
- list_continuation >>
77
- (admonition_line | paragraph | block) # (n_deep: 1))
78
- ).repeat(0).as(:attached)
79
- item = item >> att.maybe
80
-
81
- if nesting_level <= 4
82
- item = item >>
83
- (list_marker(nesting_level + 1).present? >>
84
- list(nesting_level + 1)).repeat(0).as(:nested) # ).maybe
85
- end
86
- ulist_marker(nesting_level).present? >> item.as(:list_item)
87
- end
88
-
89
- def dlist_delimiter
90
- (str("::") | str(":::") | str("::::") | str(";;")
91
- ).as(:delimiter)
92
- end
93
-
94
- def dlist_term(_delimiter)
95
- match("[^\n:]").repeat(1) # >> empty_line.repeat(0)
96
- .as(:dlist_term) >> dlist_delimiter
97
- end
98
-
99
- def dlist_definition
100
- text # >> empty_line.repeat(0)
101
- .as(:definition) >> line_ending >> empty_line.repeat(0)
102
- end
103
-
104
- def dlist_item(delimiter)
105
- (((dlist_term(delimiter).as(:terms).repeat(1) >> line_ending >>
106
- empty_line.repeat(0)).repeat(1) >>
107
- dlist_definition) |
108
- (dlist_term(delimiter).repeat(1, 1).as(:terms) >> space >>
109
- dlist_definition)
110
- ).as(:definition_list_item)
111
- end
112
- end
113
- end
114
- end
115
- end
@@ -1,54 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Paragraph
5
- def line_not_text?
6
- line_start? >>
7
- (attribute_list >> newline).absent? >>
8
- block_delimiter.absent? >>
9
- list.absent? >>
10
- list_prefix.absent? >>
11
- list_continuation.absent? >>
12
- element_id.absent? >>
13
- section_prefix.absent?
14
- end
15
-
16
- # TODO: This is crazy that many_breaks can be 0, true or false!?
17
- def paragraph_text_line(many_breaks = false)
18
- tl = line_not_text? >>
19
- (asciidoc_char_with_id.absent? |
20
- element_id_inline >> literal_space? |
21
- line_start? >> line_not_text?) >>
22
- text_any.as(:text)
23
- if many_breaks == 0
24
- tl >> eof?
25
- elsif many_breaks
26
- tl >> (newline.as(:line_break) | eof?)
27
- else
28
- tl >> (newline_single.as(:line_break) | eof?)
29
- end
30
- end
31
-
32
- def paragraph
33
- (element_id.maybe >>
34
- block_title.maybe >>
35
- (attribute_list >> newline).maybe >>
36
- ((paragraph_text_line(0).repeat(1, 1) >>
37
- (newline.repeat(1).as(:line_break) | eof?)) |
38
- paragraph_text_line(false).repeat(1) >>
39
- (paragraph_text_line(true).repeat(1, 1) >>
40
- (newline.repeat(1).as(:line_break) | eof?)).repeat(0, 1)
41
- ).as(:lines) >>
42
- (newline.repeat(0) | eof?)
43
- ).as(:paragraph)
44
- end
45
-
46
- def paragraph_attributes
47
- str("[") >>
48
- keyword.as(:key) >> str("=") >>
49
- word.as(:value) >> str("]") >> newline
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,61 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Section
5
- def contents
6
- (
7
- bib_entry |
8
- block_image |
9
- tag |
10
- comment_block |
11
- comment_line |
12
- include_directive |
13
- admonition_line |
14
- block |
15
- table.as(:table) |
16
- # highlight.as(:highlight) |
17
- # glossaries.as(:glossaries) |
18
- paragraph |
19
- list |
20
- empty_line.as(:line_break)
21
- ).repeat(1)
22
- end
23
-
24
- def section_block(level = 2)
25
- return nil if level > 8
26
-
27
- (attribute_list >> newline).maybe >>
28
- element_id.maybe >>
29
- (attribute_list >> newline).maybe >>
30
- section_title(level).as(:title) >>
31
- contents.as(:contents).maybe
32
- end
33
-
34
- def section_prefix
35
- (line_start? >> match("^[=]") >> str("=").repeat(0) >> match('[^\n]'))
36
- end
37
-
38
- # Heading
39
- def section_title(level = 2, max_level = 8)
40
- line_start? >>
41
- match("=").repeat(level, max_level).as(:level) >>
42
- str("=").absent? >>
43
- space? >> text.as(:text) >> endline.as(:line_break)
44
- end
45
-
46
- # section
47
- def section(level = 2)
48
- r = section_block(level)
49
- if level < 8
50
- r = r >> section(level + 1).as(:section).repeat(0).as(:sections)
51
- end
52
- if level == 2
53
- r.as(:section)
54
- else
55
- r
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,32 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Table
5
- # include Coradoc::Parser::Asciidoc::Base
6
-
7
- def table
8
- element_id.maybe >>
9
- (attribute_list >> newline).maybe >>
10
- block_title.maybe >>
11
- (attribute_list >> newline).maybe >>
12
- str("|===") >> line_ending >>
13
- table_row.repeat(1).as(:rows) >>
14
- str("|===") >> line_ending
15
- end
16
-
17
- def table_row
18
- (literal_space? >> str("|") >> (cell_content | empty_cell_content))
19
- .repeat(1).as(:cols) >> line_ending
20
- end
21
-
22
- def empty_cell_content
23
- str("|").absent? >> literal_space.as(:text)
24
- end
25
-
26
- def cell_content
27
- str("|").absent? >> literal_space? >> rich_texts.as(:text)
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,41 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Term
5
- def term_type
6
- (str("term") |
7
- str("alt") |
8
- str("deprecated") |
9
- str("domain")).as(:term_type)
10
- end
11
-
12
- def term
13
- line_start? >>
14
- term_type >> str(":[") >>
15
- match('[^\]]').repeat(1).as(:term) >>
16
- str("]") >> str("\n").repeat(1).as(:line_break)
17
- end
18
-
19
- def footnote
20
- str("footnote:") >>
21
- keyword.as(:id).maybe >>
22
- str("[") >>
23
- match('[^\]]').repeat(1).as(:footnote) >>
24
- str("]")
25
- end
26
-
27
- def term_inline
28
- term_type >> str(":[") >>
29
- match('[^\]]').repeat(1).as(:term) >>
30
- str("]")
31
- end
32
-
33
- def term_inline2
34
- line_start? >>
35
- match('^\[') >> term_type >> str("]#") >>
36
- match('[^\#]').repeat(1).as(:term2) >> str("#")
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,158 +0,0 @@
1
- module Coradoc
2
- module Parser
3
- module Asciidoc
4
- module Text
5
- def space?
6
- space.maybe
7
- end
8
-
9
- def space
10
- str(" ").repeat(1)
11
- end
12
-
13
- def text
14
- match("[^\n]").repeat(1)
15
- end
16
-
17
- def line_start?
18
- match('^[^\n]').present?
19
- end
20
-
21
- def line_ending
22
- str("\n") # | match('[\z]')# | match('$')
23
- end
24
-
25
- def eof?
26
- any.absent?
27
- end
28
-
29
- def line_end
30
- str("\n") | str("\r\n") | eof?
31
- end
32
-
33
- def endline
34
- newline | any.absent?
35
- end
36
-
37
- # def endline_single
38
- # newline_single | any.absent?
39
- # end
40
-
41
- def newline
42
- (str("\n") | str("\r\n")).repeat(1)
43
- end
44
-
45
- def newline_single
46
- (str("\n") | str("\r\n"))
47
- end
48
-
49
- def keyword
50
- (match('[a-zA-Z0-9_\-.,]') | str(".")).repeat(1)
51
- end
52
-
53
- def empty_line
54
- match("^\n")
55
- end
56
-
57
- def digit
58
- match("[0-9]")
59
- end
60
-
61
- def digits
62
- match("[0-9]").repeat(1)
63
- end
64
-
65
- def word
66
- match("[a-zA-Z0-9_-]").repeat(1)
67
- end
68
-
69
- def words
70
- word >> (space? >> word).repeat
71
- end
72
-
73
- def rich_texts
74
- rich_text >> (space? >> rich_text).repeat
75
- end
76
-
77
- def rich_text
78
- (match("[a-zA-Z0-9_-]") | str(".") | str("*") | match("@")).repeat(1)
79
- end
80
-
81
- def email
82
- word >> str("@") >> word >> str(".") >> word
83
- end
84
-
85
- def special_character
86
- match("^[*:=-]") | str("[#") | str("[[")
87
- end
88
-
89
- def date
90
- digit.repeat(2, 4) >> str("-") >>
91
- digit.repeat(1, 2) >> str("-") >> digit.repeat(1, 2)
92
- end
93
-
94
- def attr_name
95
- match("[^\t\s]").repeat(1)
96
- end
97
-
98
- def file_path
99
- match('[^\[]').repeat(1)
100
- end
101
-
102
- def include_directive
103
- (str("include::") >>
104
- file_path.as(:path) >>
105
- attribute_list >>
106
- (newline | str("")).as(:line_break)
107
- ).as(:include)
108
- end
109
-
110
- def inline_image
111
- (str("image::") >>
112
- file_path.as(:path) >>
113
- attribute_list >>
114
- (line_ending)
115
- ).as(:inline_image)
116
- end
117
-
118
- def block_image
119
- (element_id.maybe >>
120
- block_title.maybe >>
121
- (attribute_list >> newline).maybe >>
122
- match("^i") >> str("mage::") >>
123
- file_path.as(:path) >>
124
- attribute_list(:attribute_list_macro) >>
125
- newline.as(:line_break)
126
- ).as(:block_image)
127
- end
128
-
129
- def comment_line
130
- tag.absent? >>
131
- (str("//") >> str("/").absent? >>
132
- space? >>
133
- text.as(:comment_text)
134
- ).as(:comment_line)
135
- end
136
-
137
- def tag
138
- (str("//") >> str("/").absent? >>
139
- space? >>
140
- (str("tag") | str("end")).as(:prefix) >>
141
- str("::") >> str(":").absent? >>
142
- match('[^\[]').repeat(1).as(:name) >>
143
- attribute_list >>
144
- line_ending.maybe.as(:line_break)
145
- ).as(:tag)
146
- end
147
-
148
- def comment_block
149
- (str("////") >> line_ending >>
150
- ((line_ending >> str("////")).absent? >> any
151
- ).repeat.as(:comment_text) >>
152
- line_ending >> str("////")
153
- ).as(:comment_block)
154
- end
155
- end
156
- end
157
- end
158
- end
@@ -1,40 +0,0 @@
1
- require "digest"
2
- require "parslet"
3
- require "parslet/convenience"
4
-
5
- require_relative "asciidoc/base"
6
-
7
- module Coradoc
8
- module Parser
9
- class Base < Coradoc::Parser::Asciidoc::Base
10
- root :document
11
- rule(:document) do
12
- (
13
- admonition_line |
14
- bib_entry |
15
- block_image |
16
- tag |
17
- comment_block |
18
- comment_line |
19
- block |
20
- section |
21
- include_directive |
22
- document_attributes |
23
- list |
24
- table.as(:table) |
25
- paragraph |
26
- header.as(:header) |
27
- empty_line.as(:line_break) |
28
- any.as(:unparsed)
29
- ).repeat(1).as(:document)
30
- end
31
-
32
- def self.parse(filename)
33
- content = File.read(filename)
34
- new.parse(content)
35
- rescue Parslet::ParseFailed => e
36
- puts e.parse_failure_cause.ascii_tree
37
- end
38
- end
39
- end
40
- end