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,46 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class CrossReference < Base
|
|
5
|
-
attr_accessor :href, :args
|
|
6
|
-
|
|
7
|
-
declare_children :href, :args
|
|
8
|
-
|
|
9
|
-
def initialize(href, args = nil)
|
|
10
|
-
@href = href
|
|
11
|
-
@args = args
|
|
12
|
-
@args = nil if @args == ""
|
|
13
|
-
@args = [@args] unless @args.is_a?(Array) || @args == nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def to_adoc
|
|
17
|
-
if @args
|
|
18
|
-
args = @args.map do |a|
|
|
19
|
-
Coradoc::Generator.gen_adoc(a)
|
|
20
|
-
end.join(",")
|
|
21
|
-
if args.empty?
|
|
22
|
-
return "<<#{@href}>>"
|
|
23
|
-
else
|
|
24
|
-
return "<<#{@href},#{args}>>"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
"<<#{@href}>>"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class CrossReferenceArg < Base
|
|
32
|
-
attr_accessor :key, :delimiter, :value
|
|
33
|
-
|
|
34
|
-
def initialize(key, delimiter, value)
|
|
35
|
-
@key = key
|
|
36
|
-
@delimiter = delimiter
|
|
37
|
-
@value = value
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def to_adoc
|
|
41
|
-
[@key, @delimiter, @value].join
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Footnote < Base
|
|
5
|
-
attr_accessor :text, :id
|
|
6
|
-
|
|
7
|
-
declare_children :text, :id
|
|
8
|
-
|
|
9
|
-
def initialize(text, id = nil)
|
|
10
|
-
@text = text
|
|
11
|
-
@id = id
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def to_adoc
|
|
15
|
-
if @id
|
|
16
|
-
"footnote:#{@id}[#{@text}]"
|
|
17
|
-
else
|
|
18
|
-
"footnote:[#{@text}]"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Highlight < 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
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Italic < 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
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require "uri"
|
|
2
|
-
|
|
3
|
-
module Coradoc
|
|
4
|
-
module Element
|
|
5
|
-
module Inline
|
|
6
|
-
class Link < Base
|
|
7
|
-
attr_accessor :path, :title, :name, :right_constrain
|
|
8
|
-
|
|
9
|
-
declare_children :path, :title, :name
|
|
10
|
-
|
|
11
|
-
def initialize(options = {})
|
|
12
|
-
@path = options.fetch(:path, nil)
|
|
13
|
-
@title = options.fetch(:title, nil)
|
|
14
|
-
@name = options.fetch(:name, nil)
|
|
15
|
-
@right_constrain = options.fetch(:right_constrain, false)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def to_adoc
|
|
19
|
-
link = @path
|
|
20
|
-
unless @path.to_s&.match?(URI::DEFAULT_PARSER.make_regexp)
|
|
21
|
-
link = "link:#{link}"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
name_empty = @name.to_s.empty?
|
|
25
|
-
title_empty = @title.to_s.empty?
|
|
26
|
-
valid_empty_name_link = link.start_with?(%r{https?://})
|
|
27
|
-
|
|
28
|
-
link << if name_empty && !title_empty
|
|
29
|
-
"[#{@title}]"
|
|
30
|
-
elsif !name_empty
|
|
31
|
-
"[#{@name}]"
|
|
32
|
-
elsif valid_empty_name_link && !right_constrain
|
|
33
|
-
""
|
|
34
|
-
else
|
|
35
|
-
"[]"
|
|
36
|
-
end
|
|
37
|
-
link
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Monospace < Base
|
|
5
|
-
attr_accessor :content, :constrained
|
|
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
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Quotation < Base
|
|
5
|
-
attr_accessor :content
|
|
6
|
-
|
|
7
|
-
declare_children :content
|
|
8
|
-
|
|
9
|
-
def initialize(content)
|
|
10
|
-
@content = content
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
content = Coradoc::Generator.gen_adoc(@content)
|
|
15
|
-
"#{content[/^\s*/]}\"#{content.strip}\"#{content[/\s*$/]}"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Small < Base
|
|
5
|
-
attr_accessor :text
|
|
6
|
-
|
|
7
|
-
declare_children :text
|
|
8
|
-
|
|
9
|
-
def initialize(text, _options = {})
|
|
10
|
-
@text = text
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"[.small]##{@text}#"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Span < Base
|
|
5
|
-
attr_accessor :text, :role, :attributes, :unconstrained
|
|
6
|
-
|
|
7
|
-
declare_children :text, :attributes
|
|
8
|
-
|
|
9
|
-
def initialize(text, options = {})
|
|
10
|
-
@text = text
|
|
11
|
-
@role = options.fetch(:role, nil)
|
|
12
|
-
@attributes = options.fetch(:attributes, nil)
|
|
13
|
-
@unconstrained = options.fetch(:unconstrained, false)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def to_adoc
|
|
17
|
-
if @attributes
|
|
18
|
-
attr_string = @attributes.to_adoc
|
|
19
|
-
if @unconstrained
|
|
20
|
-
"#{attr_string}###{@text}##"
|
|
21
|
-
else
|
|
22
|
-
"#{attr_string}##{@text}#"
|
|
23
|
-
end
|
|
24
|
-
elsif @role
|
|
25
|
-
if @unconstrained
|
|
26
|
-
"[.#{@role}]###{@text}##"
|
|
27
|
-
else
|
|
28
|
-
"[.#{@role}]##{@text}#"
|
|
29
|
-
end
|
|
30
|
-
else
|
|
31
|
-
@text.to_s
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Subscript < Base
|
|
5
|
-
attr_accessor :content
|
|
6
|
-
|
|
7
|
-
declare_children :content
|
|
8
|
-
|
|
9
|
-
def initialize(content)
|
|
10
|
-
@content = content
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
content = Coradoc::Generator.gen_adoc(@content)
|
|
15
|
-
"~#{content}~"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Superscript < Base
|
|
5
|
-
attr_accessor :content
|
|
6
|
-
|
|
7
|
-
declare_children :content
|
|
8
|
-
|
|
9
|
-
def initialize(content)
|
|
10
|
-
@content = content
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
content = Coradoc::Generator.gen_adoc(@content)
|
|
15
|
-
"^#{content}^"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
class Underline < Base
|
|
5
|
-
attr_accessor :text
|
|
6
|
-
|
|
7
|
-
declare_children :text
|
|
8
|
-
|
|
9
|
-
def initialize(text, _options = {})
|
|
10
|
-
@text = text
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def to_adoc
|
|
14
|
-
"[.underline]##{@text}#"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module Inline
|
|
4
|
-
end
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
require_relative "inline/anchor"
|
|
9
|
-
require_relative "inline/attribute_reference"
|
|
10
|
-
require_relative "inline/bold"
|
|
11
|
-
require_relative "inline/cross_reference"
|
|
12
|
-
require_relative "inline/hard_line_break"
|
|
13
|
-
require_relative "inline/highlight"
|
|
14
|
-
require_relative "inline/italic"
|
|
15
|
-
require_relative "inline/link"
|
|
16
|
-
require_relative "inline/monospace"
|
|
17
|
-
require_relative "inline/quotation"
|
|
18
|
-
require_relative "inline/span"
|
|
19
|
-
require_relative "inline/subscript"
|
|
20
|
-
require_relative "inline/superscript"
|
|
21
|
-
require_relative "inline/footnote"
|
|
22
|
-
require_relative "inline/underline"
|
|
23
|
-
require_relative "inline/small"
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require_relative "../inline/anchor"
|
|
2
|
-
require_relative "core"
|
|
3
|
-
|
|
4
|
-
module Coradoc
|
|
5
|
-
module Element
|
|
6
|
-
module List
|
|
7
|
-
class Core < Base
|
|
8
|
-
attr_accessor :items, :prefix, :id, :ol_count, :anchor
|
|
9
|
-
|
|
10
|
-
declare_children :items, :anchor, :id
|
|
11
|
-
|
|
12
|
-
def initialize(items, options = {})
|
|
13
|
-
@items = items
|
|
14
|
-
@items = [@items] unless @items.is_a?(Array)
|
|
15
|
-
@id = options.fetch(:id, nil)
|
|
16
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
17
|
-
@ol_count = options.fetch(:ol_count, nil)
|
|
18
|
-
if @ol_count.nil?
|
|
19
|
-
m = @items.find do |i|
|
|
20
|
-
i.is_a?(Coradoc::Element::ListItem) &&
|
|
21
|
-
!i.marker.nil?
|
|
22
|
-
end&.marker.to_s
|
|
23
|
-
@ol_count = m.size
|
|
24
|
-
end
|
|
25
|
-
@ol_count = 1 if @ol_count.nil?
|
|
26
|
-
@attrs = options.fetch(:attrs, AttributeList.new)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def to_adoc
|
|
30
|
-
anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s
|
|
31
|
-
attrs = @attrs.to_adoc(false).to_s
|
|
32
|
-
content = "\n"
|
|
33
|
-
@items.each do |item|
|
|
34
|
-
c = Coradoc::Generator.gen_adoc(item)
|
|
35
|
-
if !c.empty?
|
|
36
|
-
# If there's a list inside a list directly, we want to
|
|
37
|
-
# skip adding an empty list item.
|
|
38
|
-
# See: https://github.com/metanorma/coradoc/issues/96
|
|
39
|
-
unless item.is_a? List::Core
|
|
40
|
-
content << prefix.to_s
|
|
41
|
-
content << " " if c[0] != " "
|
|
42
|
-
end
|
|
43
|
-
content << c
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
"\n#{anchor}#{attrs}" + content
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module List
|
|
4
|
-
class Definition < Base
|
|
5
|
-
attr_accessor :items, :delimiter
|
|
6
|
-
|
|
7
|
-
declare_children :items
|
|
8
|
-
|
|
9
|
-
def initialize(items, options = {})
|
|
10
|
-
@items = items
|
|
11
|
-
@delimiter = options.fetch(:delimiter, "::")
|
|
12
|
-
# super(items, options)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def prefix
|
|
16
|
-
@delimiter
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def to_adoc
|
|
20
|
-
content = "\n"
|
|
21
|
-
@items.each do |item|
|
|
22
|
-
content << item.to_adoc(@delimiter)
|
|
23
|
-
end
|
|
24
|
-
content
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module List
|
|
4
|
-
class Unordered < Core
|
|
5
|
-
def initialize(items, options = {})
|
|
6
|
-
super(items, options)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def prefix
|
|
10
|
-
return @marker if @marker
|
|
11
|
-
|
|
12
|
-
"*" * [@ol_count, 1].max
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/lib/coradoc/element/list.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
module List
|
|
4
|
-
end
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
require_relative "list_item"
|
|
9
|
-
require_relative "list_item_definition"
|
|
10
|
-
require_relative "list/core"
|
|
11
|
-
require_relative "list/ordered"
|
|
12
|
-
require_relative "list/unordered"
|
|
13
|
-
require_relative "list/definition"
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class ListItem < Base
|
|
4
|
-
attr_accessor :marker, :id, :anchor, :content, :subitem, :line_break
|
|
5
|
-
|
|
6
|
-
declare_children :content, :id, :anchor
|
|
7
|
-
|
|
8
|
-
def initialize(content, options = {})
|
|
9
|
-
@marker = options.fetch(:marker, nil)
|
|
10
|
-
@id = options.fetch(:id, nil)
|
|
11
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
12
|
-
@content = content
|
|
13
|
-
# @content = [@content] unless @content.class == Array
|
|
14
|
-
@attached = options.fetch(:attached, [])
|
|
15
|
-
@nested = options.fetch(:nested, nil)
|
|
16
|
-
@line_break = options.fetch(:line_break, "\n")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def inline?(elem)
|
|
20
|
-
case elem
|
|
21
|
-
when Inline::HardLineBreak
|
|
22
|
-
:hardbreak
|
|
23
|
-
when ->(i) { i.class.name.to_s.include? "::Inline::" }
|
|
24
|
-
true
|
|
25
|
-
when String, TextElement, Image::InlineImage
|
|
26
|
-
true
|
|
27
|
-
else
|
|
28
|
-
false
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def to_adoc
|
|
33
|
-
anchor = @anchor.nil? ? "" : " #{@anchor.to_adoc} "
|
|
34
|
-
|
|
35
|
-
content = Array(@content).flatten.compact
|
|
36
|
-
out = ""
|
|
37
|
-
prev_inline = :init
|
|
38
|
-
|
|
39
|
-
# Collapse meaningless <DIV>s
|
|
40
|
-
while content.map(&:class) == [Section] && content.first.safe_to_collapse?
|
|
41
|
-
content = Array(content.first.contents)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
content.each_with_index do |subitem, idx|
|
|
45
|
-
subcontent = Coradoc::Generator.gen_adoc(subitem)
|
|
46
|
-
inline = inline?(subitem)
|
|
47
|
-
next_inline = idx + 1 == content.length ? :end : inline?(content[idx + 1])
|
|
48
|
-
|
|
49
|
-
# Only try to postprocess elements that are text,
|
|
50
|
-
# otherwise we could strip markup.
|
|
51
|
-
if subitem.is_a? Coradoc::Element::TextElement
|
|
52
|
-
if [:hardbreak, :init, false].include?(prev_inline)
|
|
53
|
-
subcontent = Coradoc.strip_unicode(subcontent, only: :begin)
|
|
54
|
-
end
|
|
55
|
-
if [:hardbreak, :end, false].include?(next_inline)
|
|
56
|
-
subcontent = Coradoc.strip_unicode(subcontent, only: :end)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
case inline
|
|
61
|
-
when true
|
|
62
|
-
out += if prev_inline == false
|
|
63
|
-
"\n+\n#{subcontent}"
|
|
64
|
-
else
|
|
65
|
-
subcontent
|
|
66
|
-
end
|
|
67
|
-
when false
|
|
68
|
-
out += case prev_inline
|
|
69
|
-
when :hardbreak
|
|
70
|
-
subcontent.strip
|
|
71
|
-
when :init
|
|
72
|
-
"{empty}\n+\n#{subcontent.to_s.strip}"
|
|
73
|
-
else
|
|
74
|
-
"\n+\n#{subcontent.to_s.strip}"
|
|
75
|
-
end
|
|
76
|
-
when :hardbreak
|
|
77
|
-
if %i[hardbreak init].include? prev_inline
|
|
78
|
-
# can't have two hard breaks in a row; can't start with a hard break
|
|
79
|
-
else
|
|
80
|
-
out += "\n+\n"
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
prev_inline = inline
|
|
85
|
-
end
|
|
86
|
-
out += "{empty}" if prev_inline == :hardbreak
|
|
87
|
-
out = "{empty}" if out.empty?
|
|
88
|
-
|
|
89
|
-
attach = @attached.map do |elem|
|
|
90
|
-
"+\n#{Coradoc::Generator.gen_adoc(elem)}"
|
|
91
|
-
end.join
|
|
92
|
-
nest = Coradoc::Generator.gen_adoc(@nested)
|
|
93
|
-
out = " #{anchor}#{out}#{@line_break}"
|
|
94
|
-
out + attach + nest
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class ListItemDefinition < Base
|
|
4
|
-
attr_accessor :id, :terms, :contents
|
|
5
|
-
|
|
6
|
-
declare_children :id, :terms, :contents
|
|
7
|
-
|
|
8
|
-
def initialize(terms, contents, options = {})
|
|
9
|
-
@terms = terms
|
|
10
|
-
@contents = contents
|
|
11
|
-
@id = options.fetch(:id, nil)
|
|
12
|
-
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def to_adoc(delimiter)
|
|
16
|
-
anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s
|
|
17
|
-
content = ""
|
|
18
|
-
if (@terms.is_a?(Array) && @terms.size == 1) || !@terms.is_a?(Array)
|
|
19
|
-
t = Coradoc::Generator.gen_adoc(@terms)
|
|
20
|
-
content << "#{anchor}#{t}#{delimiter} "
|
|
21
|
-
else
|
|
22
|
-
@terms.map do |term|
|
|
23
|
-
t = Coradoc::Generator.gen_adoc(term)
|
|
24
|
-
content << "#{t}#{delimiter}\n"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
d = Coradoc::Generator.gen_adoc(@contents)
|
|
28
|
-
content << "#{d}\n"
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Coradoc
|
|
2
|
-
module Element
|
|
3
|
-
class Paragraph < Base
|
|
4
|
-
attr_accessor :content, :anchor, :tdsinglepara
|
|
5
|
-
|
|
6
|
-
declare_children :content, :anchor
|
|
7
|
-
|
|
8
|
-
def initialize(content, options = {})
|
|
9
|
-
@content = content
|
|
10
|
-
@id = options.fetch(:id, nil)
|
|
11
|
-
@anchor = Inline::Anchor.new(@id) if @id
|
|
12
|
-
@title = options.fetch(:title, nil)
|
|
13
|
-
@attributes = options.fetch(:attributes, nil)
|
|
14
|
-
@tdsinglepara = options.fetch(:tdsinglepara, nil)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def id
|
|
18
|
-
content&.first&.id&.to_s
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def texts
|
|
22
|
-
content.map(&:content)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def to_adoc
|
|
26
|
-
title = @title.nil? ? "" : ".#{Coradoc::Generator.gen_adoc(@title)}\n"
|
|
27
|
-
anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
|
|
28
|
-
attrs = @attributes.nil? ? "" : "#{@attributes.to_adoc}\n"
|
|
29
|
-
if @tdsinglepara
|
|
30
|
-
"#{title}#{anchor}" << Coradoc.strip_unicode(Coradoc::Generator.gen_adoc(@content))
|
|
31
|
-
else
|
|
32
|
-
"\n\n#{title}#{anchor}#{attrs}" << Coradoc.strip_unicode(Coradoc::Generator.gen_adoc(@content)) << "\n\n"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|