coradoc 1.1.5 → 1.1.7
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/.envrc +1 -0
- data/.irbrc +1 -0
- data/.rspec +3 -0
- data/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +179 -0
- data/Gemfile +11 -0
- data/README.adoc +5 -7
- data/coradoc.gemspec +5 -16
- data/exe/reverse_adoc +1 -1
- data/exe/w2a +1 -1
- data/flake.lock +114 -0
- data/flake.nix +135 -0
- data/lib/coradoc/cli.rb +1 -1
- data/lib/coradoc/converter.rb +4 -5
- data/lib/coradoc/element/attribute.rb +10 -1
- data/lib/coradoc/element/attribute_list.rb +4 -3
- data/lib/coradoc/element/audio.rb +1 -1
- data/lib/coradoc/element/author.rb +2 -2
- data/lib/coradoc/element/base.rb +14 -2
- data/lib/coradoc/element/bibliography.rb +1 -1
- data/lib/coradoc/element/bibliography_entry.rb +1 -1
- data/lib/coradoc/element/block/open.rb +1 -1
- data/lib/coradoc/element/block.rb +1 -1
- data/lib/coradoc/element/document_attributes.rb +8 -2
- data/lib/coradoc/element/image/block_image.rb +3 -2
- data/lib/coradoc/element/image/core.rb +5 -4
- data/lib/coradoc/element/inline/attribute_reference.rb +19 -0
- data/lib/coradoc/element/inline/cross_reference.rb +4 -3
- data/lib/coradoc/element/inline/footnote.rb +24 -0
- data/lib/coradoc/element/inline/small.rb +19 -0
- data/lib/coradoc/element/inline/span.rb +37 -0
- data/lib/coradoc/element/inline/underline.rb +19 -0
- data/lib/coradoc/element/inline.rb +5 -1
- data/lib/coradoc/element/list/core.rb +2 -2
- data/lib/coradoc/element/list/ordered.rb +1 -0
- data/lib/coradoc/element/list/unordered.rb +1 -0
- data/lib/coradoc/element/list_item.rb +19 -20
- data/lib/coradoc/element/table.rb +4 -2
- data/lib/coradoc/element/term.rb +1 -0
- data/lib/coradoc/element/text_element.rb +4 -1
- data/lib/coradoc/element/title.rb +1 -1
- data/lib/coradoc/element/video.rb +2 -2
- data/lib/coradoc/input/adoc.rb +20 -18
- data/lib/coradoc/input/docx.rb +25 -23
- data/lib/coradoc/input/html/README.adoc +1 -1
- data/lib/coradoc/input/html/cleaner.rb +121 -117
- data/lib/coradoc/input/html/config.rb +58 -56
- data/lib/coradoc/input/html/converters/a.rb +44 -39
- data/lib/coradoc/input/html/converters/aside.rb +12 -8
- data/lib/coradoc/input/html/converters/audio.rb +24 -20
- data/lib/coradoc/input/html/converters/base.rb +103 -99
- data/lib/coradoc/input/html/converters/blockquote.rb +18 -14
- data/lib/coradoc/input/html/converters/br.rb +11 -7
- data/lib/coradoc/input/html/converters/bypass.rb +77 -73
- data/lib/coradoc/input/html/converters/code.rb +18 -14
- data/lib/coradoc/input/html/converters/div.rb +15 -11
- data/lib/coradoc/input/html/converters/dl.rb +51 -44
- data/lib/coradoc/input/html/converters/drop.rb +21 -17
- data/lib/coradoc/input/html/converters/em.rb +16 -12
- data/lib/coradoc/input/html/converters/figure.rb +19 -15
- data/lib/coradoc/input/html/converters/h.rb +32 -30
- data/lib/coradoc/input/html/converters/head.rb +17 -13
- data/lib/coradoc/input/html/converters/hr.rb +11 -7
- data/lib/coradoc/input/html/converters/ignore.rb +15 -11
- data/lib/coradoc/input/html/converters/img.rb +98 -93
- data/lib/coradoc/input/html/converters/li.rb +13 -9
- data/lib/coradoc/input/html/converters/mark.rb +14 -10
- data/lib/coradoc/input/html/converters/markup.rb +22 -18
- data/lib/coradoc/input/html/converters/math.rb +26 -19
- data/lib/coradoc/input/html/converters/ol.rb +55 -50
- data/lib/coradoc/input/html/converters/p.rb +16 -12
- data/lib/coradoc/input/html/converters/pass_through.rb +12 -8
- data/lib/coradoc/input/html/converters/pre.rb +49 -45
- data/lib/coradoc/input/html/converters/q.rb +12 -8
- data/lib/coradoc/input/html/converters/strong.rb +15 -11
- data/lib/coradoc/input/html/converters/sub.rb +15 -11
- data/lib/coradoc/input/html/converters/sup.rb +15 -11
- data/lib/coradoc/input/html/converters/table.rb +21 -13
- data/lib/coradoc/input/html/converters/td.rb +64 -60
- data/lib/coradoc/input/html/converters/text.rb +24 -20
- data/lib/coradoc/input/html/converters/th.rb +13 -9
- data/lib/coradoc/input/html/converters/tr.rb +17 -13
- data/lib/coradoc/input/html/converters/video.rb +24 -20
- data/lib/coradoc/input/html/converters.rb +45 -43
- data/lib/coradoc/input/html/errors.rb +8 -6
- data/lib/coradoc/input/html/html_converter.rb +93 -90
- data/lib/coradoc/input/html/plugin.rb +104 -104
- data/lib/coradoc/input/html/plugins/plateau.rb +197 -190
- data/lib/coradoc/input/html/postprocessor.rb +188 -182
- data/lib/coradoc/input/html.rb +34 -32
- data/lib/coradoc/oscal.rb +18 -5
- data/lib/coradoc/output/adoc.rb +13 -11
- data/lib/coradoc/output/coradoc_tree_debug.rb +15 -13
- data/lib/coradoc/parser/asciidoc/admonition.rb +6 -6
- data/lib/coradoc/parser/asciidoc/attribute_list.rb +43 -27
- data/lib/coradoc/parser/asciidoc/base.rb +3 -6
- data/lib/coradoc/parser/asciidoc/bibliography.rb +5 -6
- data/lib/coradoc/parser/asciidoc/block.rb +30 -31
- data/lib/coradoc/parser/asciidoc/citation.rb +11 -29
- data/lib/coradoc/parser/asciidoc/content.rb +23 -33
- data/lib/coradoc/parser/asciidoc/document_attributes.rb +2 -3
- data/lib/coradoc/parser/asciidoc/header.rb +1 -2
- data/lib/coradoc/parser/asciidoc/inline.rb +165 -42
- data/lib/coradoc/parser/asciidoc/list.rb +27 -27
- data/lib/coradoc/parser/asciidoc/paragraph.rb +28 -19
- data/lib/coradoc/parser/asciidoc/section.rb +11 -17
- data/lib/coradoc/parser/asciidoc/table.rb +5 -5
- data/lib/coradoc/parser/asciidoc/term.rb +24 -8
- data/lib/coradoc/parser/asciidoc/text.rb +18 -21
- data/lib/coradoc/parser/base.rb +0 -3
- data/lib/coradoc/reverse_adoc.rb +3 -3
- data/lib/coradoc/transformer.rb +167 -137
- data/lib/coradoc/version.rb +1 -1
- data/lib/reverse_adoc.rb +1 -1
- data/utils/inspect_asciidoc.rb +29 -0
- data/utils/parser_analyzer.rb +14 -14
- data/utils/round_trip.rb +31 -15
- metadata +34 -137
- data/.hound.yml +0 -5
- data/lib/coradoc/element/inline/citation.rb +0 -24
- data/todo.md +0 -10
@@ -1,138 +1,142 @@
|
|
1
|
-
module Coradoc
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
string.gsub("]\n****\n\n", "]\n****\n")
|
29
|
-
end
|
1
|
+
module Coradoc
|
2
|
+
module Input
|
3
|
+
module Html
|
4
|
+
class Cleaner
|
5
|
+
def tidy(string)
|
6
|
+
if string.is_a? Hash
|
7
|
+
return string.transform_values { |i| tidy(i) }
|
8
|
+
end
|
9
|
+
|
10
|
+
result = HtmlConverter.track_time "Removing inner whitespace" do
|
11
|
+
remove_inner_whitespaces(String.new(string))
|
12
|
+
end
|
13
|
+
result = HtmlConverter.track_time "Removing newlines" do
|
14
|
+
remove_newlines(result)
|
15
|
+
end
|
16
|
+
result = HtmlConverter.track_time "Removing leading newlines" do
|
17
|
+
remove_leading_newlines(result)
|
18
|
+
end
|
19
|
+
result = HtmlConverter.track_time "Cleaning tag borders" do
|
20
|
+
clean_tag_borders(result)
|
21
|
+
end
|
22
|
+
result = HtmlConverter.track_time "Cleaning punctuation characters" do
|
23
|
+
clean_punctuation_characters(result)
|
24
|
+
end
|
25
|
+
result = remove_block_leading_newlines(result)
|
26
|
+
result = remove_section_attribute_newlines(result)
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def remove_block_leading_newlines(string)
|
30
|
+
string.gsub("]\n****\n\n", "]\n****\n")
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
def remove_section_attribute_newlines(string)
|
34
|
+
string.gsub("]\n\n==", "]\n==")
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def remove_newlines(string)
|
38
|
+
string.gsub(/\n{3,}/, "\n\n")
|
39
|
+
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
string.gsub!(/\n stem:\[/, "\nstem:[")
|
46
|
-
string.gsub!(/(stem:\[([^\]]|\\\])*\])\n(?=\S)/, "\\1 ")
|
47
|
-
string.gsub!(/(stem:\[([^\]]|\\\])*\])\s+(?=[\^-])/, "\\1")
|
48
|
-
end
|
49
|
-
result = +""
|
50
|
-
string.each_line do |line|
|
51
|
-
result << preserve_border_whitespaces(line) do
|
52
|
-
line.strip.gsub(/[ \t]{2,}/, " ")
|
41
|
+
def remove_leading_newlines(string)
|
42
|
+
string.gsub(/\A\n+/, "")
|
53
43
|
end
|
54
|
-
end
|
55
|
-
result
|
56
|
-
end
|
57
44
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
# match.strip.sub("__ ", "__").sub(" __", "__")
|
72
|
-
# end
|
73
|
-
# end
|
74
|
-
|
75
|
-
result = string.gsub(/\s?~{2,}.*?~{2,}\s?/) do |match|
|
76
|
-
preserve_border_whitespaces(match,
|
77
|
-
default_border: Coradoc::Input::HTML.config.tag_border) do
|
78
|
-
match.strip.sub("~~ ", "~~").sub(" ~~", "~~")
|
45
|
+
def remove_inner_whitespaces(string)
|
46
|
+
unless string.nil?
|
47
|
+
string.gsub!(/\n stem:\[/, "\nstem:[")
|
48
|
+
string.gsub!(/(stem:\[([^\]]|\\\])*\])\n(?=\S)/, "\\1 ")
|
49
|
+
string.gsub!(/(stem:\[([^\]]|\\\])*\])\s+(?=[\^-])/, "\\1")
|
50
|
+
end
|
51
|
+
result = +""
|
52
|
+
string.each_line do |line|
|
53
|
+
result << preserve_border_whitespaces(line) do
|
54
|
+
line.strip.gsub(/[ \t]{2,}/, " ")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
result
|
79
58
|
end
|
80
|
-
end
|
81
59
|
|
82
|
-
|
83
|
-
|
84
|
-
|
60
|
+
# Find non-asterisk content that is enclosed by two or
|
61
|
+
# more asterisks. Ensure that only one whitespace occurs
|
62
|
+
# in the border area.
|
63
|
+
# Same for underscores and brackets.
|
64
|
+
def clean_tag_borders(string)
|
65
|
+
# result = string.gsub(/\s?\*{2,}.*?\*{2,}\s?/) do |match|
|
66
|
+
# preserve_border_whitespaces(match, default_border: Coradoc::Input::HTML.config.tag_border) do
|
67
|
+
# match.strip.sub("** ", "**").sub(" **", "**")
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
|
71
|
+
# result = string.gsub(/\s?_{2,}.*?_{2,}\s?/) do |match|
|
72
|
+
# preserve_border_whitespaces(match, default_border: Coradoc::Input::HTML.config.tag_border) do
|
73
|
+
# match.strip.sub("__ ", "__").sub(" __", "__")
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
|
77
|
+
result = string.gsub(/\s?~{2,}.*?~{2,}\s?/) do |match|
|
78
|
+
preserve_border_whitespaces(match,
|
79
|
+
default_border: Coradoc::Input::Html.config.tag_border) do
|
80
|
+
match.strip.sub("~~ ", "~~").sub(" ~~", "~~")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
result.gsub(/\s?\[.*?\]\s?/) do |match|
|
85
|
+
preserve_border_whitespaces(match) do
|
86
|
+
match.strip.sub("[ ", "[").sub(" ]", "]")
|
87
|
+
end
|
88
|
+
end
|
85
89
|
end
|
86
|
-
end
|
87
|
-
end
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
def clean_punctuation_characters(string)
|
92
|
+
string.gsub(/(\*\*|~~|__)\s([.!?'"])/, "\\1\\2")
|
93
|
+
end
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
# preprocesses HTML, rather than postprocessing it
|
96
|
+
def preprocess_word_html(string)
|
97
|
+
clean_headings(scrub_whitespace(string.dup))
|
98
|
+
end
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
def scrub_whitespace(string)
|
101
|
+
string.gsub!(/ | |\u00a0/i, " ") # HTML encoded spaces
|
102
|
+
string = Coradoc.strip_unicode(string) # Strip document-level leading and trailing whitespace
|
103
|
+
string.gsub!(/( +)$/, " ") # line trailing whitespace
|
104
|
+
string.gsub!(/\n\n\n\n/, "\n\n") # Quadruple line breaks
|
105
|
+
# string.delete!('?| ') # Unicode non-breaking spaces, injected as tabs
|
106
|
+
string
|
107
|
+
end
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
109
|
+
# following added by me
|
110
|
+
def clean_headings(string)
|
111
|
+
string.gsub!(%r{<h([1-9])[^>]*></h\1>}, " ")
|
112
|
+
# I don't know why Libre Office is inserting them, but they need to go
|
113
|
+
string.gsub!(%r{<h([1-9])[^>]* style="vertical-align: super;[^>]*>(.+?)</h\1>},
|
114
|
+
"<sup>\\2</sup>")
|
115
|
+
# I absolutely don't know why Libre Office is rendering superscripts as h1
|
116
|
+
string
|
117
|
+
end
|
116
118
|
|
117
|
-
|
119
|
+
private
|
118
120
|
|
119
|
-
|
120
|
-
|
121
|
+
def preserve_border_whitespaces(string, options = {})
|
122
|
+
return string if /\A\s*\Z/.match?(string)
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
124
|
+
default_border = options.fetch(:default_border, "")
|
125
|
+
# If the string contains part of a link so the characters [,],(,)
|
126
|
+
# then don't add any extra spaces
|
127
|
+
default_border = "" if /[\[(\])]/.match?(string)
|
128
|
+
string_start = present_or_default(string[/\A\s*/], default_border)
|
129
|
+
string_end = present_or_default(string[/\s*\Z/], default_border)
|
130
|
+
result = yield
|
131
|
+
string_start + result + string_end
|
132
|
+
end
|
131
133
|
|
132
|
-
|
133
|
-
|
134
|
+
def present_or_default(string, default)
|
135
|
+
return default if string.nil? || string.empty?
|
134
136
|
|
135
|
-
|
137
|
+
string
|
138
|
+
end
|
139
|
+
end
|
136
140
|
end
|
137
141
|
end
|
138
142
|
end
|
@@ -1,75 +1,77 @@
|
|
1
1
|
require "tmpdir"
|
2
2
|
|
3
3
|
module Coradoc
|
4
|
-
module Input
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module Input
|
5
|
+
module Html
|
6
|
+
class Config
|
7
|
+
def initialize
|
8
|
+
@unknown_tags = :pass_through
|
9
|
+
@input_format = :html
|
10
|
+
@mathml2asciimath = false
|
11
|
+
@external_images = false
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
# Destination to save file and images
|
14
|
+
@destination = nil
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# Source of HTML
|
17
|
+
# @sourcedir = nil
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
# Image counter, assuming there are max 999 images
|
20
|
+
@image_counter = 1
|
21
|
+
# pad with 0s
|
22
|
+
@image_counter_pattern = "%03d"
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
@em_delimiter = "_".freeze
|
25
|
+
@strong_delimiter = "*".freeze
|
26
|
+
@inline_options = {}
|
27
|
+
@tag_border = " ".freeze
|
27
28
|
|
28
|
-
|
29
|
+
@split_sections = nil
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
# Document width - used to compute table sizes.
|
32
|
+
# This is an assumption for screen size in input document.
|
33
|
+
# If column widths are specified in absolute values, then we
|
34
|
+
# have to convert them to relative values, as AsciiDoc only
|
35
|
+
# supports those.
|
36
|
+
@doc_width = 1000
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
# Plugin system
|
39
|
+
@plugins = []
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
# Debugging options
|
42
|
+
@track_time = false
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def with(options = {})
|
46
|
+
old_options = @inline_options
|
47
|
+
@inline_options = options
|
48
|
+
result = yield
|
49
|
+
@inline_options = old_options
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.declare_option(option)
|
54
|
+
define_method(option) do
|
55
|
+
@inline_options[option] || instance_variable_get(:"@#{option}")
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
define_method(option) do
|
54
|
-
@inline_options[option] || instance_variable_get(:"@#{option}")
|
58
|
+
attr_writer option
|
55
59
|
end
|
56
60
|
|
57
|
-
|
61
|
+
declare_option :unknown_tags
|
62
|
+
declare_option :tag_border
|
63
|
+
declare_option :mathml2asciimath
|
64
|
+
declare_option :external_images
|
65
|
+
declare_option :destination
|
66
|
+
declare_option :sourcedir
|
67
|
+
declare_option :image_counter
|
68
|
+
declare_option :image_counter_pattern
|
69
|
+
declare_option :input_format
|
70
|
+
declare_option :split_sections
|
71
|
+
declare_option :doc_width
|
72
|
+
declare_option :plugins
|
73
|
+
declare_option :track_time
|
58
74
|
end
|
59
|
-
|
60
|
-
declare_option :unknown_tags
|
61
|
-
declare_option :tag_border
|
62
|
-
declare_option :mathml2asciimath
|
63
|
-
declare_option :external_images
|
64
|
-
declare_option :destination
|
65
|
-
declare_option :sourcedir
|
66
|
-
declare_option :image_counter
|
67
|
-
declare_option :image_counter_pattern
|
68
|
-
declare_option :input_format
|
69
|
-
declare_option :split_sections
|
70
|
-
declare_option :doc_width
|
71
|
-
declare_option :plugins
|
72
|
-
declare_option :track_time
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
@@ -1,47 +1,52 @@
|
|
1
1
|
require "coradoc"
|
2
2
|
|
3
|
-
module Coradoc
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
module Coradoc
|
4
|
+
module Input
|
5
|
+
module Html
|
6
|
+
module Converters
|
7
|
+
class A < Base
|
8
|
+
def to_coradoc(node, state = {})
|
9
|
+
name = treat_children(node, state)
|
10
|
+
|
11
|
+
href = node["href"]
|
12
|
+
title = extract_title(node)
|
13
|
+
id = node["id"] || node["name"]
|
14
|
+
|
15
|
+
id = id&.gsub(/\s/, "")&.gsub(/__+/, "_")
|
16
|
+
id = nil if id&.empty?
|
17
|
+
|
18
|
+
return "" if /^_Toc\d+$|^_GoBack$/.match?(id)
|
19
|
+
|
20
|
+
return Coradoc::Element::Inline::Anchor.new(id) if id
|
21
|
+
|
22
|
+
if href.to_s.start_with?("#")
|
23
|
+
href = href.sub(/^#/, "").gsub(/\s/, "").gsub(/__+/, "_")
|
24
|
+
return Coradoc::Element::Inline::CrossReference.new(href, name)
|
25
|
+
end
|
26
|
+
|
27
|
+
return name if href.to_s.empty?
|
28
|
+
|
29
|
+
ambigous_characters = /[\w.?&#=%;\[\u{ff}-\u{10ffff}]/
|
30
|
+
if name&.strip == href
|
31
|
+
name = ""
|
32
|
+
right_constrain = textnode_after_start_with?(node,
|
33
|
+
ambigous_characters)
|
34
|
+
end
|
35
|
+
|
36
|
+
out = []
|
37
|
+
out << " " if textnode_before_end_with?(node, ambigous_characters)
|
38
|
+
out << Coradoc::Element::Inline::Link.new(
|
39
|
+
path: href,
|
40
|
+
name: name.strip,
|
41
|
+
title: title.strip,
|
42
|
+
right_constrain: right_constrain,
|
43
|
+
)
|
44
|
+
out
|
45
|
+
end
|
23
46
|
end
|
24
47
|
|
25
|
-
|
26
|
-
|
27
|
-
ambigous_characters = /[\w.?&#=%;\[\u{ff}-\u{10ffff}]/
|
28
|
-
if name&.strip == href
|
29
|
-
name = ""
|
30
|
-
right_constrain = textnode_after_start_with?(node, ambigous_characters)
|
31
|
-
end
|
32
|
-
|
33
|
-
out = []
|
34
|
-
out << " " if textnode_before_end_with?(node, ambigous_characters)
|
35
|
-
out << Coradoc::Element::Inline::Link.new(
|
36
|
-
path: href,
|
37
|
-
name: name.strip,
|
38
|
-
title: title.strip,
|
39
|
-
right_constrain: right_constrain,
|
40
|
-
)
|
41
|
-
out
|
48
|
+
register :a, A.new
|
42
49
|
end
|
43
50
|
end
|
44
|
-
|
45
|
-
register :a, A.new
|
46
51
|
end
|
47
52
|
end
|
@@ -1,12 +1,16 @@
|
|
1
|
-
module Coradoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Coradoc
|
2
|
+
module Input
|
3
|
+
module Html
|
4
|
+
module Converters
|
5
|
+
class Aside < Base
|
6
|
+
def to_coradoc(node, state = {})
|
7
|
+
content = treat_children(node, state)
|
8
|
+
Coradoc::Element::Block::Side.new(lines: content.lines)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
register :aside, Aside.new
|
7
13
|
end
|
8
14
|
end
|
9
|
-
|
10
|
-
register :aside, Aside.new
|
11
15
|
end
|
12
16
|
end
|
@@ -1,25 +1,29 @@
|
|
1
|
-
module Coradoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
module Coradoc
|
2
|
+
module Input
|
3
|
+
module Html
|
4
|
+
module Converters
|
5
|
+
class Audio < Base
|
6
|
+
def to_coradoc(node, _state = {})
|
7
|
+
src = node["src"]
|
8
|
+
id = node["id"]
|
9
|
+
title = extract_title(node)
|
10
|
+
attributes = Coradoc::Element::AttributeList.new
|
11
|
+
options = options(node)
|
12
|
+
attributes.add_named("options", options) if options.any?
|
13
|
+
Coradoc::Element::Audio.new(title, id: id, src: src,
|
14
|
+
attributes: attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
def options(node)
|
18
|
+
autoplay = node["autoplay"]
|
19
|
+
loop_attr = node["loop"]
|
20
|
+
controls = node["controls"]
|
21
|
+
[autoplay, loop_attr, controls].compact
|
22
|
+
end
|
23
|
+
end
|
14
24
|
|
15
|
-
|
16
|
-
autoplay = node["autoplay"]
|
17
|
-
loop_attr = node["loop"]
|
18
|
-
controls = node["controls"]
|
19
|
-
[autoplay, loop_attr, controls].compact
|
25
|
+
register :audio, Audio.new
|
20
26
|
end
|
21
27
|
end
|
22
|
-
|
23
|
-
register :audio, Audio.new
|
24
28
|
end
|
25
29
|
end
|