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.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/Rakefile +3 -12
- data/exe/coradoc +21 -2
- data/lib/coradoc/cli.rb +185 -91
- data/lib/coradoc/configurable.rb +527 -0
- data/lib/coradoc/coradoc.rb +463 -0
- data/lib/coradoc/core_model/annotation_block.rb +57 -0
- data/lib/coradoc/core_model/base.rb +172 -0
- data/lib/coradoc/core_model/bibliography.rb +41 -0
- data/lib/coradoc/core_model/bibliography_entry.rb +48 -0
- data/lib/coradoc/core_model/block.rb +63 -0
- data/lib/coradoc/core_model/children_content.rb +53 -0
- data/lib/coradoc/core_model/comment_block.rb +10 -0
- data/lib/coradoc/core_model/definition_item.rb +46 -0
- data/lib/coradoc/core_model/definition_list.rb +28 -0
- data/lib/coradoc/core_model/element_attribute.rb +26 -0
- data/lib/coradoc/core_model/example_block.rb +10 -0
- data/lib/coradoc/core_model/footnote.rb +92 -0
- data/lib/coradoc/core_model/horizontal_rule_block.rb +10 -0
- data/lib/coradoc/core_model/id_generator.rb +16 -0
- data/lib/coradoc/core_model/image.rb +66 -0
- data/lib/coradoc/core_model/inline_element.rb +140 -0
- data/lib/coradoc/core_model/list_block.rb +135 -0
- data/lib/coradoc/core_model/list_item.rb +142 -0
- data/lib/coradoc/core_model/listing_block.rb +13 -0
- data/lib/coradoc/core_model/literal_block.rb +10 -0
- data/lib/coradoc/core_model/metadata.rb +79 -0
- data/lib/coradoc/core_model/open_block.rb +10 -0
- data/lib/coradoc/core_model/paragraph_block.rb +10 -0
- data/lib/coradoc/core_model/pass_block.rb +10 -0
- data/lib/coradoc/core_model/quote_block.rb +12 -0
- data/lib/coradoc/core_model/reviewer_block.rb +10 -0
- data/lib/coradoc/core_model/sidebar_block.rb +10 -0
- data/lib/coradoc/core_model/source_block.rb +10 -0
- data/lib/coradoc/core_model/structural_element.rb +94 -0
- data/lib/coradoc/core_model/table.rb +148 -0
- data/lib/coradoc/core_model/term.rb +53 -0
- data/lib/coradoc/core_model/text_content.rb +22 -0
- data/lib/coradoc/core_model/toc.rb +105 -0
- data/lib/coradoc/core_model/toc_generator.rb +151 -0
- data/lib/coradoc/core_model/verse_block.rb +12 -0
- data/lib/coradoc/core_model.rb +77 -0
- data/lib/coradoc/document_builder.rb +184 -0
- data/lib/coradoc/document_manipulator.rb +203 -0
- data/lib/coradoc/errors.rb +312 -0
- data/lib/coradoc/format_module.rb +49 -0
- data/lib/coradoc/hooks.rb +176 -0
- data/lib/coradoc/input.rb +17 -7
- data/lib/coradoc/logger.rb +54 -0
- data/lib/coradoc/output.rb +17 -6
- data/lib/coradoc/performance_regression.rb +109 -0
- data/lib/coradoc/processor_registry.rb +50 -0
- data/lib/coradoc/query.rb +455 -0
- data/lib/coradoc/registry.rb +156 -0
- data/lib/coradoc/serializer/registry.rb +150 -0
- data/lib/coradoc/transform.rb +11 -0
- data/lib/coradoc/validation.rb +646 -0
- data/lib/coradoc/version.rb +1 -1
- data/lib/coradoc/visitor.rb +283 -0
- data/lib/coradoc.rb +40 -19
- metadata +67 -277
- data/.editorconfig +0 -15
- data/.envrc +0 -1
- data/.irbrc +0 -1
- data/.pryrc.sample +0 -1
- data/.rubocop.yml +0 -14
- data/.rubocop_todo.yml +0 -179
- data/CHANGELOG.md +0 -9
- data/CODE_OF_CONDUCT.md +0 -84
- data/Dockerfile +0 -19
- data/Gemfile +0 -16
- data/LICENSE.txt +0 -21
- data/Makefile +0 -35
- data/README.Docker.adoc +0 -57
- data/README.adoc +0 -119
- data/coradoc.gemspec +0 -40
- data/docker-compose.yml +0 -14
- data/exe/reverse_adoc +0 -81
- data/exe/w2a +0 -60
- data/flake.lock +0 -114
- data/flake.nix +0 -135
- data/lib/coradoc/converter.rb +0 -144
- data/lib/coradoc/document.rb +0 -77
- data/lib/coradoc/element/admonition.rb +0 -18
- data/lib/coradoc/element/attribute.rb +0 -36
- data/lib/coradoc/element/attribute_list.rb +0 -138
- data/lib/coradoc/element/audio.rb +0 -33
- data/lib/coradoc/element/author.rb +0 -24
- data/lib/coradoc/element/base.rb +0 -92
- data/lib/coradoc/element/bibliography.rb +0 -24
- data/lib/coradoc/element/bibliography_entry.rb +0 -24
- data/lib/coradoc/element/block/core.rb +0 -76
- data/lib/coradoc/element/block/example.rb +0 -23
- data/lib/coradoc/element/block/listing.rb +0 -21
- data/lib/coradoc/element/block/literal.rb +0 -21
- data/lib/coradoc/element/block/open.rb +0 -22
- data/lib/coradoc/element/block/pass.rb +0 -21
- data/lib/coradoc/element/block/quote.rb +0 -19
- data/lib/coradoc/element/block/reviewer_comment.rb +0 -19
- data/lib/coradoc/element/block/side.rb +0 -19
- data/lib/coradoc/element/block/sourcecode.rb +0 -21
- data/lib/coradoc/element/block.rb +0 -17
- data/lib/coradoc/element/break.rb +0 -11
- data/lib/coradoc/element/comment_block.rb +0 -22
- data/lib/coradoc/element/comment_line.rb +0 -18
- data/lib/coradoc/element/document_attributes.rb +0 -33
- data/lib/coradoc/element/header.rb +0 -22
- data/lib/coradoc/element/image/block_image.rb +0 -32
- data/lib/coradoc/element/image/core.rb +0 -58
- data/lib/coradoc/element/image/inline_image.rb +0 -12
- data/lib/coradoc/element/image.rb +0 -10
- data/lib/coradoc/element/include.rb +0 -18
- data/lib/coradoc/element/inline/anchor.rb +0 -19
- data/lib/coradoc/element/inline/attribute_reference.rb +0 -19
- data/lib/coradoc/element/inline/bold.rb +0 -25
- data/lib/coradoc/element/inline/cross_reference.rb +0 -46
- data/lib/coradoc/element/inline/footnote.rb +0 -24
- data/lib/coradoc/element/inline/hard_line_break.rb +0 -11
- data/lib/coradoc/element/inline/highlight.rb +0 -25
- data/lib/coradoc/element/inline/italic.rb +0 -25
- data/lib/coradoc/element/inline/link.rb +0 -42
- data/lib/coradoc/element/inline/monospace.rb +0 -25
- data/lib/coradoc/element/inline/quotation.rb +0 -20
- data/lib/coradoc/element/inline/small.rb +0 -19
- data/lib/coradoc/element/inline/span.rb +0 -37
- data/lib/coradoc/element/inline/subscript.rb +0 -20
- data/lib/coradoc/element/inline/superscript.rb +0 -20
- data/lib/coradoc/element/inline/underline.rb +0 -19
- data/lib/coradoc/element/inline.rb +0 -23
- data/lib/coradoc/element/list/core.rb +0 -51
- data/lib/coradoc/element/list/definition.rb +0 -29
- data/lib/coradoc/element/list/ordered.rb +0 -17
- data/lib/coradoc/element/list/unordered.rb +0 -17
- data/lib/coradoc/element/list.rb +0 -13
- data/lib/coradoc/element/list_item.rb +0 -98
- data/lib/coradoc/element/list_item_definition.rb +0 -32
- data/lib/coradoc/element/paragraph.rb +0 -37
- data/lib/coradoc/element/revision.rb +0 -27
- data/lib/coradoc/element/section.rb +0 -62
- data/lib/coradoc/element/table.rb +0 -91
- data/lib/coradoc/element/tag.rb +0 -19
- data/lib/coradoc/element/term.rb +0 -22
- data/lib/coradoc/element/text_element.rb +0 -92
- data/lib/coradoc/element/title.rb +0 -62
- data/lib/coradoc/element/video.rb +0 -50
- data/lib/coradoc/generator.rb +0 -19
- data/lib/coradoc/input/adoc.rb +0 -30
- data/lib/coradoc/input/docx.rb +0 -64
- data/lib/coradoc/input/html/LICENSE.txt +0 -25
- data/lib/coradoc/input/html/README.adoc +0 -308
- data/lib/coradoc/input/html/cleaner.rb +0 -142
- data/lib/coradoc/input/html/config.rb +0 -77
- data/lib/coradoc/input/html/converters/a.rb +0 -52
- data/lib/coradoc/input/html/converters/aside.rb +0 -16
- data/lib/coradoc/input/html/converters/audio.rb +0 -29
- data/lib/coradoc/input/html/converters/base.rb +0 -108
- data/lib/coradoc/input/html/converters/blockquote.rb +0 -22
- data/lib/coradoc/input/html/converters/br.rb +0 -15
- data/lib/coradoc/input/html/converters/bypass.rb +0 -81
- data/lib/coradoc/input/html/converters/code.rb +0 -23
- data/lib/coradoc/input/html/converters/div.rb +0 -19
- data/lib/coradoc/input/html/converters/dl.rb +0 -62
- data/lib/coradoc/input/html/converters/drop.rb +0 -26
- data/lib/coradoc/input/html/converters/em.rb +0 -21
- data/lib/coradoc/input/html/converters/figure.rb +0 -25
- data/lib/coradoc/input/html/converters/h.rb +0 -42
- data/lib/coradoc/input/html/converters/head.rb +0 -23
- data/lib/coradoc/input/html/converters/hr.rb +0 -15
- data/lib/coradoc/input/html/converters/ignore.rb +0 -20
- data/lib/coradoc/input/html/converters/img.rb +0 -110
- data/lib/coradoc/input/html/converters/li.rb +0 -17
- data/lib/coradoc/input/html/converters/mark.rb +0 -19
- data/lib/coradoc/input/html/converters/markup.rb +0 -31
- data/lib/coradoc/input/html/converters/math.rb +0 -38
- data/lib/coradoc/input/html/converters/ol.rb +0 -65
- data/lib/coradoc/input/html/converters/p.rb +0 -23
- data/lib/coradoc/input/html/converters/pass_through.rb +0 -17
- data/lib/coradoc/input/html/converters/pre.rb +0 -55
- data/lib/coradoc/input/html/converters/q.rb +0 -16
- data/lib/coradoc/input/html/converters/strong.rb +0 -20
- data/lib/coradoc/input/html/converters/sub.rb +0 -22
- data/lib/coradoc/input/html/converters/sup.rb +0 -22
- data/lib/coradoc/input/html/converters/table.rb +0 -319
- data/lib/coradoc/input/html/converters/td.rb +0 -81
- data/lib/coradoc/input/html/converters/text.rb +0 -32
- data/lib/coradoc/input/html/converters/th.rb +0 -18
- data/lib/coradoc/input/html/converters/tr.rb +0 -22
- data/lib/coradoc/input/html/converters/video.rb +0 -29
- data/lib/coradoc/input/html/converters.rb +0 -59
- data/lib/coradoc/input/html/errors.rb +0 -14
- data/lib/coradoc/input/html/html_converter.rb +0 -168
- data/lib/coradoc/input/html/plugin.rb +0 -131
- data/lib/coradoc/input/html/plugins/plateau.rb +0 -213
- data/lib/coradoc/input/html/postprocessor.rb +0 -220
- data/lib/coradoc/input/html.rb +0 -61
- data/lib/coradoc/legacy_parser.rb +0 -200
- data/lib/coradoc/oscal.rb +0 -99
- data/lib/coradoc/output/adoc.rb +0 -19
- data/lib/coradoc/output/coradoc_tree_debug.rb +0 -21
- data/lib/coradoc/parser/asciidoc/admonition.rb +0 -24
- data/lib/coradoc/parser/asciidoc/attribute_list.rb +0 -89
- data/lib/coradoc/parser/asciidoc/base.rb +0 -87
- data/lib/coradoc/parser/asciidoc/bibliography.rb +0 -29
- data/lib/coradoc/parser/asciidoc/block.rb +0 -94
- data/lib/coradoc/parser/asciidoc/citation.rb +0 -30
- data/lib/coradoc/parser/asciidoc/content.rb +0 -64
- data/lib/coradoc/parser/asciidoc/document_attributes.rb +0 -25
- data/lib/coradoc/parser/asciidoc/header.rb +0 -29
- data/lib/coradoc/parser/asciidoc/inline.rb +0 -195
- data/lib/coradoc/parser/asciidoc/list.rb +0 -115
- data/lib/coradoc/parser/asciidoc/paragraph.rb +0 -54
- data/lib/coradoc/parser/asciidoc/section.rb +0 -61
- data/lib/coradoc/parser/asciidoc/table.rb +0 -32
- data/lib/coradoc/parser/asciidoc/term.rb +0 -41
- data/lib/coradoc/parser/asciidoc/text.rb +0 -158
- data/lib/coradoc/parser/base.rb +0 -40
- data/lib/coradoc/parser.rb +0 -11
- data/lib/coradoc/reverse_adoc.rb +0 -18
- data/lib/coradoc/transformer.rb +0 -476
- data/lib/coradoc/util.rb +0 -12
- data/lib/reverse_adoc.rb +0 -20
- data/utils/inspect_asciidoc.rb +0 -29
- data/utils/parser_analyzer.rb +0 -66
- data/utils/round_trip.rb +0 -53
data/lib/coradoc/parser.rb
DELETED
data/lib/coradoc/reverse_adoc.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
warn <<~WARN
|
|
2
|
-
Deprecated: coradoc/reverse_adoc has been renamed to coradoc/input/html.
|
|
3
|
-
| Please update your references from:
|
|
4
|
-
| require 'coradoc/reverse_adoc'
|
|
5
|
-
| To:
|
|
6
|
-
| require 'coradoc/input/html'
|
|
7
|
-
|
|
|
8
|
-
| You are referencing an old require here:
|
|
9
|
-
| #{caller.join("\n| ")}
|
|
10
|
-
|
|
|
11
|
-
| Please also ensure that you replace all references to Coradoc::ReverseAdoc
|
|
12
|
-
| in your code with Coradoc::Input::HTML.
|
|
13
|
-
WARN
|
|
14
|
-
|
|
15
|
-
require "coradoc"
|
|
16
|
-
require "coradoc/input/html"
|
|
17
|
-
|
|
18
|
-
Coradoc::ReverseAdoc = Coradoc::Input::Html
|
data/lib/coradoc/transformer.rb
DELETED
|
@@ -1,476 +0,0 @@
|
|
|
1
|
-
require "parslet"
|
|
2
|
-
require "coradoc/document"
|
|
3
|
-
|
|
4
|
-
module Coradoc
|
|
5
|
-
class Transformer < Parslet::Transform
|
|
6
|
-
# Header
|
|
7
|
-
rule(
|
|
8
|
-
title: simple(:title),
|
|
9
|
-
author: simple(:author),
|
|
10
|
-
revision: simple(:revision),
|
|
11
|
-
) do
|
|
12
|
-
Element::Header.new(title, author: author, revision: revision)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Author
|
|
16
|
-
rule(
|
|
17
|
-
first_name: simple(:first_name),
|
|
18
|
-
last_name: simple(:last_name),
|
|
19
|
-
email: simple(:email),
|
|
20
|
-
) do
|
|
21
|
-
Element::Author.new(first_name, last_name, email)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Revision
|
|
25
|
-
rule(number: simple(:number), date: simple(:date),
|
|
26
|
-
remark: simple(:remark)) do
|
|
27
|
-
Element::Revision.new(number, date: date, remark: remark)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Comments
|
|
31
|
-
rule(comment_line: { comment_text: simple(:comment_text) }) do
|
|
32
|
-
Element::Comment::Line.new(comment_text)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
rule(comment_block: { comment_text: simple(:comment_text) }) do
|
|
36
|
-
Element::Comment::Block.new(comment_text)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
rule(tag: subtree(:tag)) do
|
|
40
|
-
opts = {}
|
|
41
|
-
opts[:prefix] = tag[:prefix]
|
|
42
|
-
opts[:attribute_list] = tag[:attribute_list]
|
|
43
|
-
opts[:line_break] = tag[:line_break]
|
|
44
|
-
Element::Tag.new(tag[:name], opts)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# AttributeList
|
|
48
|
-
NamedAttribute = Struct.new(:key, :value)
|
|
49
|
-
|
|
50
|
-
rule(named: { named_key: simple(:key),
|
|
51
|
-
named_value: simple(:value) }) do
|
|
52
|
-
NamedAttribute.new(key.to_s, value.to_s)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
rule(positional: simple(:positional)) do
|
|
56
|
-
positional.to_s
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
rule(attribute_array: nil) do
|
|
60
|
-
Element::AttributeList.new
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
rule(attribute_array: sequence(:attributes)) do
|
|
64
|
-
attr_list = Element::AttributeList.new
|
|
65
|
-
attributes.each do |a|
|
|
66
|
-
if a.is_a?(String)
|
|
67
|
-
attr_list.add_positional(a)
|
|
68
|
-
elsif a.is_a?(NamedAttribute)
|
|
69
|
-
attr_list.add_named(a[:key], a[:value])
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
attr_list
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Include
|
|
76
|
-
rule(include: {
|
|
77
|
-
path: simple(:path),
|
|
78
|
-
attribute_list: simple(:attribute_list),
|
|
79
|
-
line_break: simple(:line_break),
|
|
80
|
-
}) do
|
|
81
|
-
Element::Include.new(
|
|
82
|
-
path.to_s,
|
|
83
|
-
attributes: attribute_list,
|
|
84
|
-
line_break: line_break,
|
|
85
|
-
)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Text Element
|
|
89
|
-
rule(text: simple(:text)) do
|
|
90
|
-
Element::TextElement.new(text.to_s)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
rule(text_string: subtree(:text_string)) do
|
|
94
|
-
text_string.to_s
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
rule(text: simple(:text), line_break: simple(:line_break)) do
|
|
98
|
-
Element::TextElement.new(text.to_s, line_break: line_break)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
rule(text: sequence(:text), line_break: simple(:line_break)) do
|
|
102
|
-
Element::TextElement.new(text, line_break: line_break)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
rule(id: simple(:id), text: simple(:text)) do
|
|
106
|
-
Element::TextElement.new(text.to_s, id: id.to_s)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
rule(text: sequence(:text)) do
|
|
110
|
-
Element::TextElement.new(text)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
rule(
|
|
114
|
-
text: simple(:text),
|
|
115
|
-
line_break: simple(:line_break),
|
|
116
|
-
) do
|
|
117
|
-
Element::TextElement.new(
|
|
118
|
-
text.to_s,
|
|
119
|
-
line_break: line_break,
|
|
120
|
-
)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
rule(
|
|
124
|
-
id: simple(:id),
|
|
125
|
-
text: simple(:text),
|
|
126
|
-
line_break: simple(:line_break),
|
|
127
|
-
) do
|
|
128
|
-
Element::TextElement.new(
|
|
129
|
-
text.to_s,
|
|
130
|
-
id: id.to_s,
|
|
131
|
-
line_break: line_break,
|
|
132
|
-
)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
rule(
|
|
136
|
-
id: simple(:id),
|
|
137
|
-
text: sequence(:text),
|
|
138
|
-
line_break: simple(:line_break),
|
|
139
|
-
) do
|
|
140
|
-
Element::TextElement.new(
|
|
141
|
-
text,
|
|
142
|
-
id: id.to_s,
|
|
143
|
-
line_break: line_break,
|
|
144
|
-
)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
rule(text: sequence(:text),
|
|
148
|
-
line_break: simple(:line_break)) do
|
|
149
|
-
Element::TextElement.new(
|
|
150
|
-
text,
|
|
151
|
-
line_break: line_break,
|
|
152
|
-
)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
# Inlines
|
|
156
|
-
rule(href: simple(:href)) do
|
|
157
|
-
Element::Inline::CrossReference.new(
|
|
158
|
-
href.to_s,
|
|
159
|
-
)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
rule(href: simple(:href),
|
|
163
|
-
name: simple(:name)) do
|
|
164
|
-
Element::Inline::CrossReference.new(
|
|
165
|
-
href.to_s,
|
|
166
|
-
name.to_s,
|
|
167
|
-
)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
rule(bold_constrained: sequence(:text)) do
|
|
171
|
-
Element::Inline::Bold.new(text, unconstrained: false)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
rule(bold_unconstrained: sequence(:text)) do
|
|
175
|
-
Element::Inline::Bold.new(text, unconstrained: true)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
rule(span_constrained: subtree(:span_constrained)) do
|
|
179
|
-
Element::Inline::Span.new(span_constrained[:text],
|
|
180
|
-
unconstrained: false,
|
|
181
|
-
attributes: span_constrained[:attribute_list])
|
|
182
|
-
end
|
|
183
|
-
rule(span_unconstrained: subtree(:span_unconstrained)) do
|
|
184
|
-
Element::Inline::Span.new(span_unconstrained[:text], unconstrained: true,
|
|
185
|
-
attributes: span_unconstrained[:attribute_list])
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
rule(italic_constrained: sequence(:text)) do
|
|
189
|
-
Element::Inline::Italic.new(text, unconstrained: false)
|
|
190
|
-
end
|
|
191
|
-
rule(italic_unconstrained: sequence(:text)) do
|
|
192
|
-
Element::Inline::Italic.new(text, unconstrained: true)
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
rule(highlight_constrained: sequence(:text)) do
|
|
196
|
-
Element::Inline::Highlight.new(text, unconstrained: false)
|
|
197
|
-
end
|
|
198
|
-
rule(highlight_unconstrained: sequence(:text)) do
|
|
199
|
-
Element::Inline::Highlight.new(text, unconstrained: true)
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
rule(monospace_constrained: sequence(:text)) do
|
|
203
|
-
Element::Inline::Monospace.new(text, unconstrained: false)
|
|
204
|
-
end
|
|
205
|
-
rule(monospace_unconstrained: sequence(:text)) do
|
|
206
|
-
Element::Inline::Monospace.new(text, unconstrained: true)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
rule(superscript: sequence(:content)) do
|
|
210
|
-
Element::Inline::Superscript.new(content)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
rule(subscript: sequence(:content)) do
|
|
214
|
-
Element::Inline::Subscript.new(content)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Paragraph
|
|
218
|
-
rule(paragraph: subtree(:paragraph)) do
|
|
219
|
-
Element::Paragraph.new(
|
|
220
|
-
paragraph[:lines],
|
|
221
|
-
id: paragraph[:id],
|
|
222
|
-
attributes: paragraph[:attribute_list],
|
|
223
|
-
title: paragraph[:title],
|
|
224
|
-
)
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Title Element
|
|
228
|
-
rule(
|
|
229
|
-
level: simple(:level),
|
|
230
|
-
text: simple(:text),
|
|
231
|
-
line_break: simple(:line_break),
|
|
232
|
-
) do
|
|
233
|
-
Element::Title.new(text, level.size - 1, line_break: line_break)
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
rule(
|
|
237
|
-
name: simple(:name),
|
|
238
|
-
level: simple(:level),
|
|
239
|
-
text: simple(:text),
|
|
240
|
-
line_break: simple(:line_break),
|
|
241
|
-
) do
|
|
242
|
-
Element::Title.new(text, level.size - 1, line_break: line_break, id: name)
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
# Section
|
|
246
|
-
rule(section: subtree(:section)) do
|
|
247
|
-
id = section[:id] || nil
|
|
248
|
-
title = section[:title] || nil
|
|
249
|
-
attribute_list = section[:attribute_list] || nil
|
|
250
|
-
contents = section[:contents] || []
|
|
251
|
-
sections = section[:sections]
|
|
252
|
-
opts = { id:, attribute_list:, contents:, sections: }
|
|
253
|
-
Element::Section.new(title, opts)
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
rule(example: sequence(:example)) do
|
|
257
|
-
Element::Core.new("", type: "example", lines: example)
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
rule(bibliography_entry: subtree(:bib_entry)) do
|
|
261
|
-
Element::BibliographyEntry.new(bib_entry)
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
rule(
|
|
265
|
-
id: simple(:id),
|
|
266
|
-
title: simple(:title),
|
|
267
|
-
entries: sequence(:entries),
|
|
268
|
-
) do
|
|
269
|
-
Element::Bibliography.new(
|
|
270
|
-
id: id,
|
|
271
|
-
title: title,
|
|
272
|
-
entries: entries,
|
|
273
|
-
)
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
rule(
|
|
277
|
-
key: simple(:key),
|
|
278
|
-
delimiter: simple(:delimiter),
|
|
279
|
-
value: simple(:value),
|
|
280
|
-
) do
|
|
281
|
-
Element::Inline::CrossReferenceArg.new(key, delimiter, value)
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
rule(href_arg: simple(:href_arg)) do
|
|
285
|
-
href_arg.to_s
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
rule(cross_reference: sequence(:xref)) do
|
|
289
|
-
args = xref.size > 1 ? xref[1..-1] : []
|
|
290
|
-
Element::Inline::CrossReference.new(xref[0], args)
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
rule(attribute_reference: simple(:name)) do
|
|
294
|
-
Element::Inline::AttributeReference.new(name)
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
rule(term_type: simple(:term_type),
|
|
298
|
-
term: simple(:term)) do
|
|
299
|
-
Coradoc::Element::Term.new(term, type: term_type, lang: :en)
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
rule(footnote: simple(:footnote)) do
|
|
303
|
-
Coradoc::Element::Inline::Footnote.new(footnote)
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
rule(footnote: simple(:footnote), id: simple(:id)) do
|
|
307
|
-
Coradoc::Element::Inline::Footnote.new(footnote, id)
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
rule(block: subtree(:block)) do
|
|
311
|
-
id = block[:id]
|
|
312
|
-
title = block[:title]
|
|
313
|
-
attribute_list = block[:attribute_list]
|
|
314
|
-
delimiter = block[:delimiter].to_s
|
|
315
|
-
delimiter_c = delimiter[0]
|
|
316
|
-
lines = block[:lines]
|
|
317
|
-
ordering = block.keys.select do |k|
|
|
318
|
-
%i[id title attribute_list attribute_list2].include?(k)
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
opts = { id: id,
|
|
322
|
-
title: title,
|
|
323
|
-
delimiter_len: delimiter.size,
|
|
324
|
-
lines: lines,
|
|
325
|
-
ordering: ordering }
|
|
326
|
-
opts[:attributes] = attribute_list if attribute_list
|
|
327
|
-
if delimiter_c == "*"
|
|
328
|
-
if attribute_list
|
|
329
|
-
if attribute_list.positional == [] &&
|
|
330
|
-
attribute_list.named.keys[0] == "reviewer"
|
|
331
|
-
Element::Block::ReviewerComment.new(opts)
|
|
332
|
-
elsif attribute_list.positional[0] == "sidebar" &&
|
|
333
|
-
attribute_list.named == {}
|
|
334
|
-
Element::Block::Side.new(opts)
|
|
335
|
-
else
|
|
336
|
-
Element::Block::Side.new(opts)
|
|
337
|
-
end
|
|
338
|
-
else
|
|
339
|
-
Element::Block::Side.new(opts)
|
|
340
|
-
end
|
|
341
|
-
elsif delimiter_c == "="
|
|
342
|
-
Element::Block::Example.new(title, opts)
|
|
343
|
-
elsif delimiter_c == "+"
|
|
344
|
-
Element::Block::Pass.new(opts)
|
|
345
|
-
elsif delimiter_c == "-" && delimiter.size == 2
|
|
346
|
-
Element::Block::Open.new(title, opts)
|
|
347
|
-
elsif delimiter_c == "-" && delimiter.size >= 4
|
|
348
|
-
Element::Block::SourceCode.new(title, opts)
|
|
349
|
-
elsif delimiter_c == "_"
|
|
350
|
-
Element::Block::Quote.new(title, opts)
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
# Admonition
|
|
355
|
-
rule(admonition_type: simple(:admonition_type),
|
|
356
|
-
content: sequence(:content)) do
|
|
357
|
-
Element::Admonition.new(content, admonition_type.to_s)
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
rule(block_image: subtree(:block_image)) do
|
|
361
|
-
id = block_image[:id]
|
|
362
|
-
title = block_image[:title]
|
|
363
|
-
path = block_image[:path]
|
|
364
|
-
opts = {
|
|
365
|
-
attributes: block_image[:attribute_list_macro],
|
|
366
|
-
line_break: block_image[:line_break],
|
|
367
|
-
}
|
|
368
|
-
Element::Image::BlockImage.new(title, id, path, opts)
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
# Attribute
|
|
372
|
-
rule(key: simple(:key), value: simple(:value)) do
|
|
373
|
-
Element::Attribute.new(key.to_s, value.to_s)
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
rule(key: simple(:key), value: simple(:value),
|
|
377
|
-
line_break: simple(:line_break)) do
|
|
378
|
-
Element::Attribute.new(key.to_s, value.to_s, line_break: line_break.to_s)
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
rule(line_break: simple(:line_break)) do
|
|
382
|
-
Element::LineBreak.new(line_break)
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
rule(document_attributes: sequence(:document_attributes)) do
|
|
386
|
-
Element::DocumentAttributes.new(document_attributes)
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
# Table
|
|
390
|
-
|
|
391
|
-
rule(cols: sequence(:cols)) do
|
|
392
|
-
cells = cols.map { |c| Element::Table::Cell.new(content: c) }
|
|
393
|
-
Element::Table::Row.new(cells)
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
rule(table: subtree(:table)) do
|
|
397
|
-
title = table[:title] || nil
|
|
398
|
-
rows = table[:rows] || []
|
|
399
|
-
opts = {
|
|
400
|
-
id: table[:id] || nil,
|
|
401
|
-
attributes: table[:attribute_list] || nil,
|
|
402
|
-
}
|
|
403
|
-
Element::Table.new(title, rows, opts)
|
|
404
|
-
end
|
|
405
|
-
|
|
406
|
-
rule(list_item: subtree(:list_item)) do
|
|
407
|
-
marker = list_item[:marker]
|
|
408
|
-
id = list_item[:id]
|
|
409
|
-
text = list_item[:text]
|
|
410
|
-
text = list_item[:text].to_s if list_item[:text].instance_of?(Parslet::Slice)
|
|
411
|
-
attached = list_item[:attached]
|
|
412
|
-
nested = list_item[:nested]
|
|
413
|
-
line_break = list_item[:line_break]
|
|
414
|
-
Element::ListItem.new(
|
|
415
|
-
text, id:, marker:, attached:, nested:, line_break:
|
|
416
|
-
)
|
|
417
|
-
end
|
|
418
|
-
|
|
419
|
-
# List
|
|
420
|
-
rule(list: simple(:list)) { list }
|
|
421
|
-
rule(unordered: sequence(:list_items)) do
|
|
422
|
-
Element::List::Unordered.new(list_items)
|
|
423
|
-
end
|
|
424
|
-
rule(attribute_list: simple(:attribute_list),
|
|
425
|
-
unordered: sequence(:list_items)) do
|
|
426
|
-
Element::List::Unordered.new(list_items, attrs: attribute_list)
|
|
427
|
-
end
|
|
428
|
-
|
|
429
|
-
rule(ordered: sequence(:list_items)) do
|
|
430
|
-
Element::List::Ordered.new(list_items)
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
rule(attribute_list: simple(:attribute_list),
|
|
434
|
-
ordered: sequence(:list_items)) do
|
|
435
|
-
Element::List::Ordered.new(list_items, attrs: attribute_list)
|
|
436
|
-
end
|
|
437
|
-
|
|
438
|
-
rule(dlist_term: simple(:t),
|
|
439
|
-
delimiter: simple(:d)) do
|
|
440
|
-
# DefinitionListTerm.new(t.to_s, d.to_s)
|
|
441
|
-
t.to_s
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
rule(definition_list_item: { terms: sequence(:terms),
|
|
445
|
-
definition: simple(:contents) }) do
|
|
446
|
-
Element::ListItemDefinition.new(terms, contents)
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
rule(definition_list: sequence(:list_items)) do
|
|
450
|
-
Element::List::Definition.new(list_items)
|
|
451
|
-
end
|
|
452
|
-
|
|
453
|
-
# Highlight
|
|
454
|
-
rule(highlight: simple(:text)) { Element::Highlight.new(text) }
|
|
455
|
-
|
|
456
|
-
# Glossaries
|
|
457
|
-
rule(glossaries: sequence(:glossaries)) do
|
|
458
|
-
Element::Glossaries.new(glossaries)
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
rule(header: simple(:header)) { header }
|
|
462
|
-
rule(section: simple(:section)) { section }
|
|
463
|
-
|
|
464
|
-
rule(document: sequence(:elements)) do
|
|
465
|
-
Document.from_ast(elements)
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
# rule(unparsed: simple(:text)) do
|
|
469
|
-
# text.to_s
|
|
470
|
-
# end
|
|
471
|
-
|
|
472
|
-
def self.transform(syntax_tree)
|
|
473
|
-
new.apply(syntax_tree)
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
end
|
data/lib/coradoc/util.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
def self.strip_unicode(str, only: nil)
|
|
3
|
-
str = str.gsub(/\A[[:space:]]+/, "") unless only == :end
|
|
4
|
-
str = str.gsub(/[[:space:]]+\z/, "") unless only == :begin
|
|
5
|
-
str
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.a_single?(obj, klass)
|
|
9
|
-
obj.is_a?(klass) ||
|
|
10
|
-
(obj.is_a?(Array) && obj.length == 1 && obj.first.is_a?(klass))
|
|
11
|
-
end
|
|
12
|
-
end
|
data/lib/reverse_adoc.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
warn <<~WARN
|
|
2
|
-
Deprecated: reverse_adoc has been merged into coradoc gem.
|
|
3
|
-
| Please update your references from:
|
|
4
|
-
| require 'reverse_adoc'
|
|
5
|
-
| To:
|
|
6
|
-
| require 'coradoc/input/html'
|
|
7
|
-
|
|
|
8
|
-
| You are referencing an old require here:
|
|
9
|
-
| #{caller.join("\n| ")}
|
|
10
|
-
|
|
|
11
|
-
| You should also replace 'reverse_adoc' with 'coradoc' in your gem dependencies.
|
|
12
|
-
| reverse_adoc 2.0.0 will be kept with 'coradoc' as the only dependency.
|
|
13
|
-
|
|
|
14
|
-
| Please also ensure that you replace all references to ReverseAdoc in your code
|
|
15
|
-
| with Coradoc::Input::HTML.
|
|
16
|
-
WARN
|
|
17
|
-
|
|
18
|
-
require "coradoc/input/html"
|
|
19
|
-
|
|
20
|
-
ReverseAdoc = Coradoc::Input::Html
|
data/utils/inspect_asciidoc.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift("../coradoc/lib")
|
|
2
|
-
require "coradoc"
|
|
3
|
-
require "pp"
|
|
4
|
-
|
|
5
|
-
def pretty_print_obj(obj)
|
|
6
|
-
sio = StringIO.new
|
|
7
|
-
PP.pp(obj, sio, 69)
|
|
8
|
-
puts sio.string
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def print_parsed(str)
|
|
12
|
-
parse = Coradoc::Parser::Base.new.parse(str)
|
|
13
|
-
puts str
|
|
14
|
-
puts ""
|
|
15
|
-
pretty_print_obj parse[:document]
|
|
16
|
-
puts ""
|
|
17
|
-
doc = Coradoc::Transformer.transform(parse[:document])
|
|
18
|
-
pp doc
|
|
19
|
-
puts Coradoc::Generator.gen_adoc(doc)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
content = <<~END
|
|
23
|
-
[a='quoted named']
|
|
24
|
-
****
|
|
25
|
-
block
|
|
26
|
-
****
|
|
27
|
-
END
|
|
28
|
-
|
|
29
|
-
print_parsed(content)
|
data/utils/parser_analyzer.rb
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
require "rubocop"
|
|
2
|
-
|
|
3
|
-
def ast_from(string)
|
|
4
|
-
RuboCop::ProcessedSource.new(string, RUBY_VERSION.to_f).ast
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def is_def?(arr)
|
|
8
|
-
if Array === arr
|
|
9
|
-
if arr[0] == :def
|
|
10
|
-
$defs << arr
|
|
11
|
-
else
|
|
12
|
-
arr.each do |e|
|
|
13
|
-
is_def?(e)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
path = "lib/coradoc/parser/asciidoc/"
|
|
20
|
-
class_files = Dir.entries(path).select { |x| File.file?(path + x) }
|
|
21
|
-
|
|
22
|
-
$all_defs = {}
|
|
23
|
-
|
|
24
|
-
class_files.each do |cf|
|
|
25
|
-
a = ast_from(File.open(path + cf).read)
|
|
26
|
-
next if a.nil?
|
|
27
|
-
|
|
28
|
-
sexp = a.to_sexp_array
|
|
29
|
-
$defs = []
|
|
30
|
-
is_def?(sexp)
|
|
31
|
-
$all_defs[cf] = $defs
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
relevant_names = $all_defs.map { |_fn, defs| defs.map { |d| d[1] } }.flatten
|
|
35
|
-
|
|
36
|
-
require "graphviz"
|
|
37
|
-
|
|
38
|
-
g = GraphViz.new(:G, type: :digraph)
|
|
39
|
-
|
|
40
|
-
g[:fontsize] = 8
|
|
41
|
-
g[:rankdir] = "LR"
|
|
42
|
-
g[:overlap] = false
|
|
43
|
-
g[:splines] = false
|
|
44
|
-
|
|
45
|
-
nodes = {}
|
|
46
|
-
|
|
47
|
-
$all_defs.each do |file_name, defs|
|
|
48
|
-
defs.each do |ast_def|
|
|
49
|
-
ast_def[2..].flatten & relevant_names
|
|
50
|
-
node_name = ast_def[1]
|
|
51
|
-
nodes[node_name] = g.add_nodes("#{node_name}\n#{file_name}")
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
$all_defs.each_value do |defs|
|
|
56
|
-
defs.each do |ast_def|
|
|
57
|
-
calls = ast_def[2..].flatten & relevant_names
|
|
58
|
-
node_name = ast_def[1]
|
|
59
|
-
calls.each do |cl|
|
|
60
|
-
w = g.add_edges(nodes[node_name], nodes[cl])
|
|
61
|
-
w[:weight] = 1.5
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
g.output(png: "utils/parser_graph.png_#{Time.now.to_i}")
|
data/utils/round_trip.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift("../coradoc/lib")
|
|
2
|
-
|
|
3
|
-
require "coradoc"
|
|
4
|
-
require "coradoc/input/html"
|
|
5
|
-
|
|
6
|
-
require "pp"
|
|
7
|
-
require "stringio"
|
|
8
|
-
|
|
9
|
-
rt = ARGV[0]
|
|
10
|
-
|
|
11
|
-
rt_path = if rt == "rice-2023"
|
|
12
|
-
"../mn-samples-iso/sources/international-standard/rice-2023/"
|
|
13
|
-
elsif rt.to_s.include? "samples"
|
|
14
|
-
"../mn-samples-iso/sources/"
|
|
15
|
-
else
|
|
16
|
-
"./spec/fixtures/"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
if !Dir.exist?(rt_path)
|
|
20
|
-
puts "pleas set path to rice-2023"
|
|
21
|
-
exit
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
adoc_files = Dir.glob("#{rt_path}**/*adoc")
|
|
25
|
-
|
|
26
|
-
adoc_files.each do |file_path|
|
|
27
|
-
puts file_path
|
|
28
|
-
file_path_ast = "#{file_path}.ast"
|
|
29
|
-
file_path_rt = "#{file_path}.roundtrip"
|
|
30
|
-
file_path_diff = "#{file_path}.roundtrip.diff"
|
|
31
|
-
FileUtils.rm(file_path_rt) if File.exist?(file_path_rt)
|
|
32
|
-
FileUtils.rm(file_path_diff) if File.exist?(file_path_diff)
|
|
33
|
-
# begin
|
|
34
|
-
adoc_file = File.open(file_path).read
|
|
35
|
-
next if adoc_file.empty?
|
|
36
|
-
|
|
37
|
-
puts "parsing..."
|
|
38
|
-
ast = Coradoc::Parser::Base.new.parse(adoc_file)
|
|
39
|
-
sio = StringIO.new
|
|
40
|
-
PP.pp(ast, sio)
|
|
41
|
-
ast_string = sio.string
|
|
42
|
-
File.open(file_path_ast, "w") { |f| f.write(ast_string) }
|
|
43
|
-
puts "transforming..."
|
|
44
|
-
doc = Coradoc::Transformer.transform(ast[:document])
|
|
45
|
-
puts "generating..."
|
|
46
|
-
generated_adoc = Coradoc::Generator.gen_adoc(doc)
|
|
47
|
-
cleaned_adoc = Coradoc::Input::HTML.cleaner.tidy(generated_adoc)
|
|
48
|
-
File.open("#{file_path}.roundtrip", "w") { |f| f.write(cleaned_adoc) }
|
|
49
|
-
`diff -B #{file_path} #{file_path}.roundtrip > #{file_path}.roundtrip.diff`
|
|
50
|
-
# rescue
|
|
51
|
-
# puts "unsuccessful..."
|
|
52
|
-
# end
|
|
53
|
-
end
|