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
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class Bibliography < Base
|
|
4
|
-
attr_accessor :id, :title, :entries
|
|
5
|
-
|
|
6
|
-
def initialize(options = {})
|
|
7
|
-
@id = options.fetch(:id, nil)
|
|
8
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
9
|
-
@title = options.fetch(:title, nil)
|
|
10
|
-
@entries = options.fetch(:entries, nil)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
adoc = "#{gen_anchor}\n"
|
|
15
|
-
adoc << "[bibliography]"
|
|
16
|
-
adoc << "== #{@title}\n\n"
|
|
17
|
-
@entries.each do |entry|
|
|
18
|
-
adoc << "#{entry.to_adoc}\n"
|
|
19
|
-
end
|
|
20
|
-
adoc
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class BibliographyEntry < Base
|
|
4
|
-
attr_accessor :anchor_name, :document_id, :ref_text, :line_break
|
|
5
|
-
|
|
6
|
-
def initialize(options = {})
|
|
7
|
-
@anchor_name = options.fetch(:anchor_name, nil)
|
|
8
|
-
@document_id = options.fetch(:document_id, nil)
|
|
9
|
-
@ref_text = options.fetch(:ref_text, nil)
|
|
10
|
-
@line_break = options.fetch(:line_break, "")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
text = Coradoc::Generator.gen_adoc(@ref_text) if @ref_text
|
|
15
|
-
adoc = "* [[[#{@anchor_name}"
|
|
16
|
-
adoc << ",#{@document_id}" if @document_id
|
|
17
|
-
adoc << "]]]"
|
|
18
|
-
adoc << text.to_s if @ref_text
|
|
19
|
-
adoc << @line_break
|
|
20
|
-
adoc
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
require_relative "../inline/anchor"
|
|
2
|
-
|
|
3
|
-
module Coradoc
|
|
4
|
-
module Element
|
|
5
|
-
module Block
|
|
6
|
-
class Core < Base
|
|
7
|
-
attr_accessor :title, :lines, :attributes, :lang, :id
|
|
8
|
-
|
|
9
|
-
declare_children :title, :lines, :attributes, :lang, :id
|
|
10
|
-
|
|
11
|
-
def initialize(title, options = {})
|
|
12
|
-
@title = title
|
|
13
|
-
@id = options.fetch(:id, nil)
|
|
14
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
15
|
-
@type_str = options.fetch(:type, nil)
|
|
16
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
17
|
-
@delimiter = options.fetch(:delimiter, "")
|
|
18
|
-
@lang = options.fetch(:lang, nil)
|
|
19
|
-
@lines = options.fetch(:lines, [])
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def type
|
|
23
|
-
@type ||= defined_type || type_from_delimiter
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def gen_anchor
|
|
27
|
-
@anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def gen_title
|
|
31
|
-
t = Coradoc::Generator.gen_adoc(@title)
|
|
32
|
-
return "" if t.empty?
|
|
33
|
-
|
|
34
|
-
".#{t}\n"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def gen_attributes
|
|
38
|
-
attrs = @attributes.to_adoc(false)
|
|
39
|
-
return "#{attrs}\n" if !attrs.empty?
|
|
40
|
-
|
|
41
|
-
""
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def gen_delimiter
|
|
45
|
-
@delimiter_char * @delimiter_len
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def gen_lines
|
|
49
|
-
Coradoc::Generator.gen_adoc(@lines)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
def defined_type
|
|
55
|
-
@type_str&.to_s&.to_sym
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def type_from_delimiter
|
|
59
|
-
type_hash.fetch(@delimiter, nil)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def type_hash
|
|
63
|
-
@type_hash ||= {
|
|
64
|
-
"====" => :example,
|
|
65
|
-
"...." => :literal,
|
|
66
|
-
"--" => :open,
|
|
67
|
-
"++++" => :pass,
|
|
68
|
-
"____" => :quote,
|
|
69
|
-
"****" => :side,
|
|
70
|
-
"----" => :source,
|
|
71
|
-
}
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require_relative "core"
|
|
2
|
-
|
|
3
|
-
module Coradoc
|
|
4
|
-
module Element
|
|
5
|
-
module Block
|
|
6
|
-
class Example < Core
|
|
7
|
-
def initialize(title, options = {})
|
|
8
|
-
@title = title
|
|
9
|
-
@id = options.fetch(:id, nil)
|
|
10
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
11
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
12
|
-
@lines = options.fetch(:lines, [])
|
|
13
|
-
@delimiter_char = "="
|
|
14
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def to_adoc
|
|
18
|
-
"\n\n#{gen_anchor}#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Listing < Core
|
|
5
|
-
def initialize(_title, options = {})
|
|
6
|
-
@id = options.fetch(:id, nil)
|
|
7
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
8
|
-
@lang = options.fetch(:lang, "")
|
|
9
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
10
|
-
@lines = options.fetch(:lines, [])
|
|
11
|
-
@delimiter_char = "-"
|
|
12
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def to_adoc
|
|
16
|
-
"\n\n#{gen_anchor}#{gen_attributes}\n#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Literal < Core
|
|
5
|
-
def initialize(title, options = {})
|
|
6
|
-
@title = title
|
|
7
|
-
@id = options.fetch(:id, nil)
|
|
8
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
9
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
10
|
-
@lines = options.fetch(:lines, [])
|
|
11
|
-
@delimiter_char = "."
|
|
12
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def to_adoc
|
|
16
|
-
"\n\n#{gen_anchor}#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Open < Core
|
|
5
|
-
def initialize(title, options = {})
|
|
6
|
-
@title = title
|
|
7
|
-
@id = options.fetch(:id, nil)
|
|
8
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
9
|
-
@lang = options.fetch(:lang, "")
|
|
10
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
11
|
-
@lines = options.fetch(:lines, [])
|
|
12
|
-
@delimiter_char = "-"
|
|
13
|
-
@delimiter_len = options.fetch(:delimiter_len, 2)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def to_adoc
|
|
17
|
-
"\n\n#{gen_anchor}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Pass < Core
|
|
5
|
-
def initialize(options = {})
|
|
6
|
-
@id = options.fetch(:id, nil)
|
|
7
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
8
|
-
@title = options.fetch(:title, "")
|
|
9
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
10
|
-
@delimiter_char = "+"
|
|
11
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
12
|
-
@lines = options.fetch(:lines, [])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def to_adoc
|
|
16
|
-
"\n\n#{gen_anchor}#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Quote < Core
|
|
5
|
-
def initialize(title, options = {})
|
|
6
|
-
@title = title
|
|
7
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
8
|
-
@lines = options.fetch(:lines, [])
|
|
9
|
-
@delimiter_char = "_"
|
|
10
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"\n\n#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class ReviewerComment < Core
|
|
5
|
-
def initialize(options = {})
|
|
6
|
-
@title = options.fetch(:title, "")
|
|
7
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
8
|
-
@delimiter_char = "*"
|
|
9
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
10
|
-
@lines = options.fetch(:lines, [])
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"\n\n#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class Side < Core
|
|
5
|
-
def initialize(options = {})
|
|
6
|
-
@title = options.fetch(:title, "")
|
|
7
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
8
|
-
@delimiter_char = "*"
|
|
9
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
10
|
-
@lines = options.fetch(:lines, [])
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"\n\n#{gen_title}#{gen_attributes}#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
class SourceCode < Core
|
|
5
|
-
def initialize(_title, options = {})
|
|
6
|
-
@id = options.fetch(:id, nil)
|
|
7
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
8
|
-
@lang = options.fetch(:lang, "")
|
|
9
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
10
|
-
@lines = options.fetch(:lines, [])
|
|
11
|
-
@delimiter_char = "-"
|
|
12
|
-
@delimiter_len = options.fetch(:delimiter_len, 4)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def to_adoc
|
|
16
|
-
"\n\n#{gen_anchor}[source,#{@lang}]\n#{gen_delimiter}\n" << gen_lines << "\n#{gen_delimiter}\n\n"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Block
|
|
4
|
-
end
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
require_relative "block/core"
|
|
9
|
-
require_relative "block/example"
|
|
10
|
-
require_relative "block/literal"
|
|
11
|
-
require_relative "block/listing"
|
|
12
|
-
require_relative "block/open"
|
|
13
|
-
require_relative "block/pass"
|
|
14
|
-
require_relative "block/quote"
|
|
15
|
-
require_relative "block/side"
|
|
16
|
-
require_relative "block/sourcecode"
|
|
17
|
-
require_relative "block/reviewer_comment"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Comment
|
|
4
|
-
class Block < Base
|
|
5
|
-
attr_accessor :text
|
|
6
|
-
|
|
7
|
-
def initialize(text, options = {})
|
|
8
|
-
@text = text
|
|
9
|
-
@line_break = options.fetch(:line_break, "\n")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def to_adoc
|
|
13
|
-
<<~ADOC.chomp
|
|
14
|
-
////
|
|
15
|
-
#{@text}
|
|
16
|
-
////#{@line_break}
|
|
17
|
-
ADOC
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Comment
|
|
4
|
-
class Line < Base
|
|
5
|
-
attr_accessor :text
|
|
6
|
-
|
|
7
|
-
def initialize(text, options = {})
|
|
8
|
-
@text = text
|
|
9
|
-
@line_break = options.fetch(:line_break, "\n")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def to_adoc
|
|
13
|
-
"// #{@text}#{@line_break}"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class DocumentAttributes < Base
|
|
4
|
-
attr_accessor :data
|
|
5
|
-
|
|
6
|
-
declare_children :data
|
|
7
|
-
|
|
8
|
-
def initialize(data = {}, options = {})
|
|
9
|
-
@data = data
|
|
10
|
-
@options = options
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_hash
|
|
14
|
-
@data.to_h do |attribute|
|
|
15
|
-
[attribute.key, attribute.value]
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def to_adoc
|
|
20
|
-
to_hash.map do |key, value|
|
|
21
|
-
v = if value.to_s.empty?
|
|
22
|
-
""
|
|
23
|
-
elsif value.is_a? Array
|
|
24
|
-
" #{value.join(',')}"
|
|
25
|
-
else
|
|
26
|
-
" #{value}"
|
|
27
|
-
end
|
|
28
|
-
":#{key}:#{v}\n"
|
|
29
|
-
end.join + "\n"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class Header < Base
|
|
4
|
-
attr_accessor :title, :author, :revision
|
|
5
|
-
|
|
6
|
-
declare_children :title
|
|
7
|
-
|
|
8
|
-
def initialize(title, options = {})
|
|
9
|
-
@title = title
|
|
10
|
-
@author = options.fetch(:author, nil)
|
|
11
|
-
@revision = options.fetch(:revision, nil)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def to_adoc
|
|
15
|
-
adoc = "= #{@title}\n"
|
|
16
|
-
adoc << @author.to_adoc if @author
|
|
17
|
-
adoc << @revision.to_adoc if @revision
|
|
18
|
-
adoc
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Image
|
|
4
|
-
class BlockImage < Core
|
|
5
|
-
def initialize(title, id, src, options = {})
|
|
6
|
-
super
|
|
7
|
-
@colons = "::"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def to_adoc
|
|
11
|
-
missing = "// FIXME: Missing image: #{@annotate_missing}\n" if @annotate_missing
|
|
12
|
-
anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
|
|
13
|
-
title = ".#{@title}\n" unless @title.to_s.empty?
|
|
14
|
-
attrs = @attributes.to_adoc
|
|
15
|
-
[missing, anchor, title, "image", @colons, @src, attrs,
|
|
16
|
-
@line_break].join("")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def validate_named
|
|
20
|
-
@attributes.validate_named(VALIDATORS_NAMED, VALIDATORS_NAMED_BLOCK)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
extend AttributeList::Matchers
|
|
24
|
-
VALIDATORS_NAMED_BLOCK = {
|
|
25
|
-
caption: String,
|
|
26
|
-
align: one("left", "center", "right"),
|
|
27
|
-
float: one("left", "right"),
|
|
28
|
-
}.freeze
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Image
|
|
4
|
-
class Core < Base
|
|
5
|
-
attr_accessor :title, :id, :src, :attributes
|
|
6
|
-
|
|
7
|
-
declare_children :id, :src, :title, :attributes
|
|
8
|
-
|
|
9
|
-
def initialize(title, id, src, options = {})
|
|
10
|
-
@title = title
|
|
11
|
-
@id = id
|
|
12
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
13
|
-
@src = src
|
|
14
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
15
|
-
@annotate_missing = options.fetch(:annotate_missing, nil)
|
|
16
|
-
@title ||= options.fetch(:title, nil)
|
|
17
|
-
if @attributes.any?
|
|
18
|
-
@attributes.validate_positional(VALIDATORS_POSITIONAL)
|
|
19
|
-
@attributes.validate_named(VALIDATORS_NAMED)
|
|
20
|
-
end
|
|
21
|
-
@line_break = options.fetch(:line_break, "")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def to_adoc
|
|
25
|
-
missing = "// FIXME: Missing image: #{@annotate_missing}\n" if @annotate_missing
|
|
26
|
-
anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
|
|
27
|
-
title = ".#{@title}\n" unless @title.to_s.empty?
|
|
28
|
-
attrs = @attributes_macro.to_adoc
|
|
29
|
-
[missing, anchor, title, "image", @colons, @src, attrs,
|
|
30
|
-
@line_break].join("")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
extend AttributeList::Matchers
|
|
34
|
-
VALIDATORS_POSITIONAL = [
|
|
35
|
-
[:alt, String],
|
|
36
|
-
[:width, Integer],
|
|
37
|
-
[:height, Integer],
|
|
38
|
-
].freeze
|
|
39
|
-
|
|
40
|
-
VALIDATORS_NAMED = {
|
|
41
|
-
id: String,
|
|
42
|
-
alt: String,
|
|
43
|
-
fallback: String,
|
|
44
|
-
title: String,
|
|
45
|
-
width: Integer,
|
|
46
|
-
height: Integer,
|
|
47
|
-
link: String, # change to that URI regexp
|
|
48
|
-
window: String,
|
|
49
|
-
scale: Integer,
|
|
50
|
-
scaledwidth: /\A[0-9]{1,2}%\z/,
|
|
51
|
-
pdfwidth: /\A[0-9]+vw\z/,
|
|
52
|
-
role: many(/.*/, "left", "right", "th", "thumb", "related", "rel"),
|
|
53
|
-
opts: many("nofollow", "noopener", "inline", "interactive"),
|
|
54
|
-
}.freeze
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class Include
|
|
4
|
-
attr_accessor :text
|
|
5
|
-
|
|
6
|
-
def initialize(path, options = {})
|
|
7
|
-
@path = path
|
|
8
|
-
@attributes = options.fetch(:attributes, AttributeList.new)
|
|
9
|
-
@line_break = options.fetch(:line_break, "\n")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def to_adoc
|
|
13
|
-
attrs = @attributes.to_adoc(true)
|
|
14
|
-
"include::#{@path}#{attrs}#{@line_break}"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class AttributeReference < Base
|
|
5
|
-
attr_accessor :name
|
|
6
|
-
|
|
7
|
-
declare_children :name
|
|
8
|
-
|
|
9
|
-
def initialize(name)
|
|
10
|
-
@name = name
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"{#{@name}}"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Bold < Base
|
|
5
|
-
attr_accessor :content, :unconstrained
|
|
6
|
-
|
|
7
|
-
declare_children :content
|
|
8
|
-
|
|
9
|
-
def initialize(content, unconstrained: true)
|
|
10
|
-
@content = content
|
|
11
|
-
@unconstrained = unconstrained
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def to_adoc
|
|
15
|
-
content = Coradoc::Generator.gen_adoc(@content)
|
|
16
|
-
if @unconstrained
|
|
17
|
-
"**#{content}**"
|
|
18
|
-
else
|
|
19
|
-
"*#{content}*"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|