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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +1 -0
  3. data/.irbrc +1 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +5 -1
  6. data/.rubocop_todo.yml +179 -0
  7. data/Gemfile +11 -0
  8. data/README.adoc +5 -7
  9. data/coradoc.gemspec +5 -16
  10. data/exe/reverse_adoc +1 -1
  11. data/exe/w2a +1 -1
  12. data/flake.lock +114 -0
  13. data/flake.nix +135 -0
  14. data/lib/coradoc/cli.rb +1 -1
  15. data/lib/coradoc/converter.rb +4 -5
  16. data/lib/coradoc/element/attribute.rb +10 -1
  17. data/lib/coradoc/element/attribute_list.rb +4 -3
  18. data/lib/coradoc/element/audio.rb +1 -1
  19. data/lib/coradoc/element/author.rb +2 -2
  20. data/lib/coradoc/element/base.rb +14 -2
  21. data/lib/coradoc/element/bibliography.rb +1 -1
  22. data/lib/coradoc/element/bibliography_entry.rb +1 -1
  23. data/lib/coradoc/element/block/open.rb +1 -1
  24. data/lib/coradoc/element/block.rb +1 -1
  25. data/lib/coradoc/element/document_attributes.rb +8 -2
  26. data/lib/coradoc/element/image/block_image.rb +3 -2
  27. data/lib/coradoc/element/image/core.rb +5 -4
  28. data/lib/coradoc/element/inline/attribute_reference.rb +19 -0
  29. data/lib/coradoc/element/inline/cross_reference.rb +4 -3
  30. data/lib/coradoc/element/inline/footnote.rb +24 -0
  31. data/lib/coradoc/element/inline/small.rb +19 -0
  32. data/lib/coradoc/element/inline/span.rb +37 -0
  33. data/lib/coradoc/element/inline/underline.rb +19 -0
  34. data/lib/coradoc/element/inline.rb +5 -1
  35. data/lib/coradoc/element/list/core.rb +2 -2
  36. data/lib/coradoc/element/list/ordered.rb +1 -0
  37. data/lib/coradoc/element/list/unordered.rb +1 -0
  38. data/lib/coradoc/element/list_item.rb +19 -20
  39. data/lib/coradoc/element/table.rb +4 -2
  40. data/lib/coradoc/element/term.rb +1 -0
  41. data/lib/coradoc/element/text_element.rb +4 -1
  42. data/lib/coradoc/element/title.rb +1 -1
  43. data/lib/coradoc/element/video.rb +2 -2
  44. data/lib/coradoc/input/adoc.rb +20 -18
  45. data/lib/coradoc/input/docx.rb +25 -23
  46. data/lib/coradoc/input/html/README.adoc +1 -1
  47. data/lib/coradoc/input/html/cleaner.rb +121 -117
  48. data/lib/coradoc/input/html/config.rb +58 -56
  49. data/lib/coradoc/input/html/converters/a.rb +44 -39
  50. data/lib/coradoc/input/html/converters/aside.rb +12 -8
  51. data/lib/coradoc/input/html/converters/audio.rb +24 -20
  52. data/lib/coradoc/input/html/converters/base.rb +103 -99
  53. data/lib/coradoc/input/html/converters/blockquote.rb +18 -14
  54. data/lib/coradoc/input/html/converters/br.rb +11 -7
  55. data/lib/coradoc/input/html/converters/bypass.rb +77 -73
  56. data/lib/coradoc/input/html/converters/code.rb +18 -14
  57. data/lib/coradoc/input/html/converters/div.rb +15 -11
  58. data/lib/coradoc/input/html/converters/dl.rb +51 -44
  59. data/lib/coradoc/input/html/converters/drop.rb +21 -17
  60. data/lib/coradoc/input/html/converters/em.rb +16 -12
  61. data/lib/coradoc/input/html/converters/figure.rb +19 -15
  62. data/lib/coradoc/input/html/converters/h.rb +32 -30
  63. data/lib/coradoc/input/html/converters/head.rb +17 -13
  64. data/lib/coradoc/input/html/converters/hr.rb +11 -7
  65. data/lib/coradoc/input/html/converters/ignore.rb +15 -11
  66. data/lib/coradoc/input/html/converters/img.rb +98 -93
  67. data/lib/coradoc/input/html/converters/li.rb +13 -9
  68. data/lib/coradoc/input/html/converters/mark.rb +14 -10
  69. data/lib/coradoc/input/html/converters/markup.rb +22 -18
  70. data/lib/coradoc/input/html/converters/math.rb +26 -19
  71. data/lib/coradoc/input/html/converters/ol.rb +55 -50
  72. data/lib/coradoc/input/html/converters/p.rb +16 -12
  73. data/lib/coradoc/input/html/converters/pass_through.rb +12 -8
  74. data/lib/coradoc/input/html/converters/pre.rb +49 -45
  75. data/lib/coradoc/input/html/converters/q.rb +12 -8
  76. data/lib/coradoc/input/html/converters/strong.rb +15 -11
  77. data/lib/coradoc/input/html/converters/sub.rb +15 -11
  78. data/lib/coradoc/input/html/converters/sup.rb +15 -11
  79. data/lib/coradoc/input/html/converters/table.rb +21 -13
  80. data/lib/coradoc/input/html/converters/td.rb +64 -60
  81. data/lib/coradoc/input/html/converters/text.rb +24 -20
  82. data/lib/coradoc/input/html/converters/th.rb +13 -9
  83. data/lib/coradoc/input/html/converters/tr.rb +17 -13
  84. data/lib/coradoc/input/html/converters/video.rb +24 -20
  85. data/lib/coradoc/input/html/converters.rb +45 -43
  86. data/lib/coradoc/input/html/errors.rb +8 -6
  87. data/lib/coradoc/input/html/html_converter.rb +93 -90
  88. data/lib/coradoc/input/html/plugin.rb +104 -104
  89. data/lib/coradoc/input/html/plugins/plateau.rb +197 -190
  90. data/lib/coradoc/input/html/postprocessor.rb +188 -182
  91. data/lib/coradoc/input/html.rb +34 -32
  92. data/lib/coradoc/oscal.rb +18 -5
  93. data/lib/coradoc/output/adoc.rb +13 -11
  94. data/lib/coradoc/output/coradoc_tree_debug.rb +15 -13
  95. data/lib/coradoc/parser/asciidoc/admonition.rb +6 -6
  96. data/lib/coradoc/parser/asciidoc/attribute_list.rb +43 -27
  97. data/lib/coradoc/parser/asciidoc/base.rb +3 -6
  98. data/lib/coradoc/parser/asciidoc/bibliography.rb +5 -6
  99. data/lib/coradoc/parser/asciidoc/block.rb +30 -31
  100. data/lib/coradoc/parser/asciidoc/citation.rb +11 -29
  101. data/lib/coradoc/parser/asciidoc/content.rb +23 -33
  102. data/lib/coradoc/parser/asciidoc/document_attributes.rb +2 -3
  103. data/lib/coradoc/parser/asciidoc/header.rb +1 -2
  104. data/lib/coradoc/parser/asciidoc/inline.rb +165 -42
  105. data/lib/coradoc/parser/asciidoc/list.rb +27 -27
  106. data/lib/coradoc/parser/asciidoc/paragraph.rb +28 -19
  107. data/lib/coradoc/parser/asciidoc/section.rb +11 -17
  108. data/lib/coradoc/parser/asciidoc/table.rb +5 -5
  109. data/lib/coradoc/parser/asciidoc/term.rb +24 -8
  110. data/lib/coradoc/parser/asciidoc/text.rb +18 -21
  111. data/lib/coradoc/parser/base.rb +0 -3
  112. data/lib/coradoc/reverse_adoc.rb +3 -3
  113. data/lib/coradoc/transformer.rb +167 -137
  114. data/lib/coradoc/version.rb +1 -1
  115. data/lib/reverse_adoc.rb +1 -1
  116. data/utils/inspect_asciidoc.rb +29 -0
  117. data/utils/parser_analyzer.rb +14 -14
  118. data/utils/round_trip.rb +31 -15
  119. metadata +34 -137
  120. data/.hound.yml +0 -5
  121. data/lib/coradoc/element/inline/citation.rb +0 -24
  122. data/todo.md +0 -10
@@ -39,18 +39,30 @@ module Coradoc
39
39
 
40
40
  def self.declare_children(*children)
41
41
  @children = (@children || []).dup + children
42
+ access_children
43
+ end
44
+
45
+ # Make each child available for access
46
+ def self.access_children
47
+ @children.each do |child|
48
+ attr_accessor child
49
+ end
42
50
  end
43
51
 
44
52
  def self.visit(element, &block)
53
+ return element if element.nil?
54
+
45
55
  element = yield element, :pre
46
56
  element = if element.respond_to? :visit
47
57
  element.visit(&block)
48
58
  elsif element.is_a? Array
49
59
  element.map { |child| visit(child, &block) }.flatten.compact
50
60
  elsif element.is_a? Hash
51
- element.to_h do |k, v|
52
- [visit(k, &block), visit(v, &block)]
61
+ result = {}
62
+ element.each do |k, v|
63
+ result[k] = visit(v, &block)
53
64
  end
65
+ result
54
66
  else
55
67
  element
56
68
  end
@@ -7,7 +7,7 @@ module Coradoc
7
7
  @id = options.fetch(:id, nil)
8
8
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
9
9
  @title = options.fetch(:title, nil)
10
- @entries = options.fetch(:entries,nil)
10
+ @entries = options.fetch(:entries, nil)
11
11
  end
12
12
 
13
13
  def to_adoc
@@ -15,7 +15,7 @@ module Coradoc
15
15
  adoc = "* [[[#{@anchor_name}"
16
16
  adoc << ",#{@document_id}" if @document_id
17
17
  adoc << "]]]"
18
- adoc << "#{text}" if @ref_text
18
+ adoc << text.to_s if @ref_text
19
19
  adoc << @line_break
20
20
  adoc
21
21
  end
@@ -19,4 +19,4 @@ module Coradoc
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -14,4 +14,4 @@ require_relative "block/pass"
14
14
  require_relative "block/quote"
15
15
  require_relative "block/side"
16
16
  require_relative "block/sourcecode"
17
- require_relative "block/reviewer_comment"
17
+ require_relative "block/reviewer_comment"
@@ -12,13 +12,19 @@ module Coradoc
12
12
 
13
13
  def to_hash
14
14
  @data.to_h do |attribute|
15
- [attribute.key.to_s, attribute.value.to_s.gsub("'", "")]
15
+ [attribute.key, attribute.value]
16
16
  end
17
17
  end
18
18
 
19
19
  def to_adoc
20
20
  to_hash.map do |key, value|
21
- v = value.to_s.empty? ? "" : " #{value}"
21
+ v = if value.to_s.empty?
22
+ ""
23
+ elsif value.is_a? Array
24
+ " #{value.join(',')}"
25
+ else
26
+ " #{value}"
27
+ end
22
28
  ":#{key}:#{v}\n"
23
29
  end.join + "\n"
24
30
  end
@@ -12,7 +12,8 @@ module Coradoc
12
12
  anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
13
13
  title = ".#{@title}\n" unless @title.to_s.empty?
14
14
  attrs = @attributes.to_adoc
15
- [missing, anchor, title, "image", @colons, @src, attrs, @line_break].join("")
15
+ [missing, anchor, title, "image", @colons, @src, attrs,
16
+ @line_break].join("")
16
17
  end
17
18
 
18
19
  def validate_named
@@ -24,7 +25,7 @@ module Coradoc
24
25
  caption: String,
25
26
  align: one("left", "center", "right"),
26
27
  float: one("left", "right"),
27
- }
28
+ }.freeze
28
29
  end
29
30
  end
30
31
  end
@@ -13,7 +13,7 @@ module Coradoc
13
13
  @src = src
14
14
  @attributes = options.fetch(:attributes, AttributeList.new)
15
15
  @annotate_missing = options.fetch(:annotate_missing, nil)
16
- @title = options.fetch(:title, nil) unless @title
16
+ @title ||= options.fetch(:title, nil)
17
17
  if @attributes.any?
18
18
  @attributes.validate_positional(VALIDATORS_POSITIONAL)
19
19
  @attributes.validate_named(VALIDATORS_NAMED)
@@ -26,7 +26,8 @@ module Coradoc
26
26
  anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
27
27
  title = ".#{@title}\n" unless @title.to_s.empty?
28
28
  attrs = @attributes_macro.to_adoc
29
- [missing, anchor, title, "image", @colons, @src, attrs, @line_break].join("")
29
+ [missing, anchor, title, "image", @colons, @src, attrs,
30
+ @line_break].join("")
30
31
  end
31
32
 
32
33
  extend AttributeList::Matchers
@@ -34,7 +35,7 @@ module Coradoc
34
35
  [:alt, String],
35
36
  [:width, Integer],
36
37
  [:height, Integer],
37
- ]
38
+ ].freeze
38
39
 
39
40
  VALIDATORS_NAMED = {
40
41
  id: String,
@@ -50,7 +51,7 @@ module Coradoc
50
51
  pdfwidth: /\A[0-9]+vw\z/,
51
52
  role: many(/.*/, "left", "right", "th", "thumb", "related", "rel"),
52
53
  opts: many("nofollow", "noopener", "inline", "interactive"),
53
- }
54
+ }.freeze
54
55
  end
55
56
  end
56
57
  end
@@ -0,0 +1,19 @@
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
@@ -15,8 +15,9 @@ module Coradoc
15
15
 
16
16
  def to_adoc
17
17
  if @args
18
- args = @args.map{|a|
19
- Coradoc::Generator.gen_adoc(a)}.join(',')
18
+ args = @args.map do |a|
19
+ Coradoc::Generator.gen_adoc(a)
20
+ end.join(",")
20
21
  if args.empty?
21
22
  return "<<#{@href}>>"
22
23
  else
@@ -37,7 +38,7 @@ module Coradoc
37
38
  end
38
39
 
39
40
  def to_adoc
40
- [@key,@delimiter,@value].join
41
+ [@key, @delimiter, @value].join
41
42
  end
42
43
  end
43
44
  end
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,19 @@
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
@@ -6,14 +6,18 @@ module Coradoc
6
6
  end
7
7
 
8
8
  require_relative "inline/anchor"
9
+ require_relative "inline/attribute_reference"
9
10
  require_relative "inline/bold"
10
11
  require_relative "inline/cross_reference"
11
- require_relative "inline/citation"
12
12
  require_relative "inline/hard_line_break"
13
13
  require_relative "inline/highlight"
14
14
  require_relative "inline/italic"
15
15
  require_relative "inline/link"
16
16
  require_relative "inline/monospace"
17
17
  require_relative "inline/quotation"
18
+ require_relative "inline/span"
18
19
  require_relative "inline/subscript"
19
20
  require_relative "inline/superscript"
21
+ require_relative "inline/footnote"
22
+ require_relative "inline/underline"
23
+ require_relative "inline/small"
@@ -16,10 +16,10 @@ module Coradoc
16
16
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
17
17
  @ol_count = options.fetch(:ol_count, nil)
18
18
  if @ol_count.nil?
19
- m = @items.select do |i|
19
+ m = @items.find do |i|
20
20
  i.is_a?(Coradoc::Element::ListItem) &&
21
21
  !i.marker.nil?
22
- end.first&.marker.to_s
22
+ end&.marker.to_s
23
23
  @ol_count = m.size
24
24
  end
25
25
  @ol_count = 1 if @ol_count.nil?
@@ -8,6 +8,7 @@ module Coradoc
8
8
 
9
9
  def prefix
10
10
  return @marker if @marker
11
+
11
12
  "." * [@ol_count, 1].max
12
13
  end
13
14
  end
@@ -8,6 +8,7 @@ module Coradoc
8
8
 
9
9
  def prefix
10
10
  return @marker if @marker
11
+
11
12
  "*" * [@ol_count, 1].max
12
13
  end
13
14
  end
@@ -10,6 +10,7 @@ module Coradoc
10
10
  @id = options.fetch(:id, nil)
11
11
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
12
12
  @content = content
13
+ # @content = [@content] unless @content.class == Array
13
14
  @attached = options.fetch(:attached, [])
14
15
  @nested = options.fetch(:nested, nil)
15
16
  @line_break = options.fetch(:line_break, "\n")
@@ -19,7 +20,7 @@ module Coradoc
19
20
  case elem
20
21
  when Inline::HardLineBreak
21
22
  :hardbreak
22
- when ->(i){ i.class.name.to_s.include? "::Inline::" }
23
+ when ->(i) { i.class.name.to_s.include? "::Inline::" }
23
24
  true
24
25
  when String, TextElement, Image::InlineImage
25
26
  true
@@ -29,8 +30,8 @@ module Coradoc
29
30
  end
30
31
 
31
32
  def to_adoc
32
- anchor = @anchor.nil? ? "" : " #{@anchor.to_adoc.to_s} "
33
- # text = Coradoc::Generator.gen_adoc(@content)
33
+ anchor = @anchor.nil? ? "" : " #{@anchor.to_adoc} "
34
+
34
35
  content = Array(@content).flatten.compact
35
36
  out = ""
36
37
  prev_inline = :init
@@ -42,9 +43,8 @@ module Coradoc
42
43
 
43
44
  content.each_with_index do |subitem, idx|
44
45
  subcontent = Coradoc::Generator.gen_adoc(subitem)
45
-
46
46
  inline = inline?(subitem)
47
- next_inline = idx+1 == content.length ? :end : inline?(content[idx+1])
47
+ next_inline = idx + 1 == content.length ? :end : inline?(content[idx + 1])
48
48
 
49
49
  # Only try to postprocess elements that are text,
50
50
  # otherwise we could strip markup.
@@ -59,20 +59,20 @@ module Coradoc
59
59
 
60
60
  case inline
61
61
  when true
62
- if prev_inline == false
63
- out += "\n+\n" + subcontent
64
- else
65
- out += subcontent
66
- end
62
+ out += if prev_inline == false
63
+ "\n+\n#{subcontent}"
64
+ else
65
+ subcontent
66
+ end
67
67
  when false
68
- case prev_inline
69
- when :hardbreak
70
- out += subcontent.strip
71
- when :init
72
- out += "{empty}\n+\n" + subcontent.strip
73
- else
74
- out += "\n+\n" + subcontent.strip
75
- end
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
76
  when :hardbreak
77
77
  if %i[hardbreak init].include? prev_inline
78
78
  # can't have two hard breaks in a row; can't start with a hard break
@@ -86,9 +86,8 @@ module Coradoc
86
86
  out += "{empty}" if prev_inline == :hardbreak
87
87
  out = "{empty}" if out.empty?
88
88
 
89
- # attach = Coradoc::Generator.gen_adoc(@attached)
90
89
  attach = @attached.map do |elem|
91
- "+\n" + Coradoc::Generator.gen_adoc(elem)
90
+ "+\n#{Coradoc::Generator.gen_adoc(elem)}"
92
91
  end.join
93
92
  nest = Coradoc::Generator.gen_adoc(@nested)
94
93
  out = " #{anchor}#{out}#{@line_break}"
@@ -37,12 +37,14 @@ module Coradoc
37
37
  end
38
38
 
39
39
  def asciidoc?
40
- @columns.any?(&:asciidoc?)
40
+ @columns.any? { |c| c.respond_to?(:asciidoc?) && c.asciidoc? }
41
41
  end
42
42
 
43
43
  def to_adoc
44
44
  delim = asciidoc? ? "\n" : " "
45
- content = @columns.map { |col| Coradoc::Generator.gen_adoc(col) }.join(delim)
45
+ content = @columns.map do |col|
46
+ Coradoc::Generator.gen_adoc(col)
47
+ end.join(delim)
46
48
  result = "#{content}\n"
47
49
  result << "\n" if asciidoc?
48
50
  table_header_row? ? result + underline_for : result
@@ -14,6 +14,7 @@ module Coradoc
14
14
 
15
15
  def to_adoc
16
16
  return "#{@type}:[#{@term}]#{@line_break}" if @lang == :en
17
+
17
18
  "[#{@type}]##{@term}##{@line_break}"
18
19
  end
19
20
  end
@@ -25,7 +25,10 @@ module Coradoc
25
25
  end
26
26
 
27
27
  def to_adoc
28
- Coradoc::Generator.gen_adoc(@content) + @line_break
28
+ str = ""
29
+ str += "[[#{@id}]] " if @id
30
+ str += Coradoc::Generator.gen_adoc(@content) + @line_break.to_s
31
+ str
29
32
  end
30
33
 
31
34
  def treat_text_to_adoc(text)
@@ -24,7 +24,7 @@ module Coradoc
24
24
  content = Coradoc.strip_unicode(Coradoc::Generator.gen_adoc(@content))
25
25
  <<~HERE
26
26
 
27
- #{anchor}#{style_str}#{level_str} #{content}
27
+ #{anchor}#{style_str}#{level_str} #{content}
28
28
  HERE
29
29
  end
30
30
 
@@ -29,7 +29,7 @@ module Coradoc
29
29
  [:alt, String],
30
30
  [:width, Integer],
31
31
  [:height, Integer],
32
- ]
32
+ ].freeze
33
33
 
34
34
  VALIDATORS_NAMED = {
35
35
  title: String,
@@ -44,7 +44,7 @@ module Coradoc
44
44
  playlist: String,
45
45
  options: many("autoplay", "loop", "modest",
46
46
  "nocontrols", "nofullscreen", "muted"),
47
- }
47
+ }.freeze
48
48
  end
49
49
  end
50
50
  end
@@ -1,28 +1,30 @@
1
1
  require "coradoc/input"
2
2
 
3
3
  module Coradoc
4
- module Input::Adoc
5
- def self.processor_id
6
- :adoc
7
- end
4
+ module Input
5
+ module Adoc
6
+ def self.processor_id
7
+ :adoc
8
+ end
8
9
 
9
- def self.processor_match?(filename)
10
- %w[.adoc].any? { |i| filename.downcase.end_with?(i) }
11
- end
10
+ def self.processor_match?(filename)
11
+ %w[.adoc].any? { |i| filename.downcase.end_with?(i) }
12
+ end
12
13
 
13
- def self.processor_execute(input, _options = {})
14
- ast = Coradoc::Parser::Base.new.parse(input)
15
- Coradoc::Transformer.transform(ast[:document])
16
- end
14
+ def self.processor_execute(input, _options = {})
15
+ ast = Coradoc::Parser::Base.new.parse(input)
16
+ Coradoc::Transformer.transform(ast[:document])
17
+ end
17
18
 
18
- def self.processor_postprocess(input, options)
19
- if options[:output_processor] == :adoc
20
- Coradoc::Input::HTML::Cleaner.new.tidy(input)
21
- else
22
- input
19
+ def self.processor_postprocess(input, options)
20
+ if options[:output_processor] == :adoc
21
+ Coradoc::Input::Html::Cleaner.new.tidy(input)
22
+ else
23
+ input
24
+ end
23
25
  end
24
- end
25
26
 
26
- Coradoc::Input.define(self)
27
+ Coradoc::Input.define(self)
28
+ end
27
29
  end
28
30
  end
@@ -3,33 +3,35 @@ require "coradoc/input/html"
3
3
  require "fileutils"
4
4
 
5
5
  module Coradoc
6
- module Input::Docx
7
- def self.processor_id
8
- :docx
9
- end
6
+ module Input
7
+ module Docx
8
+ def self.processor_id
9
+ :docx
10
+ end
10
11
 
11
- def self.processor_match?(filename)
12
- %w[.docx .doc].any? { |i| filename.downcase.end_with?(i) }
13
- end
12
+ def self.processor_match?(filename)
13
+ %w[.docx .doc].any? { |i| filename.downcase.end_with?(i) }
14
+ end
14
15
 
15
- def self.processor_execute(input, options = {})
16
- image_dir = Dir.mktmpdir
17
- options = options.merge(sourcedir: image_dir)
18
- doc = WordToMarkdown.new(input, image_dir)
19
- doc = Coradoc::Input::HTML.cleaner.preprocess_word_html(doc.document.html)
20
- options = WordToMarkdown::REVERSE_MARKDOWN_OPTIONS.merge(options)
21
- Coradoc::Input::HTML.to_coradoc(doc, options)
22
- ensure
23
- FileUtils.rm_rf(image_dir)
24
- end
16
+ def self.processor_execute(input, options = {})
17
+ image_dir = Dir.mktmpdir
18
+ options = options.merge(sourcedir: image_dir)
19
+ doc = WordToMarkdown.new(input, image_dir)
20
+ doc = Coradoc::Input::Html.cleaner.preprocess_word_html(doc.document.html)
21
+ options = WordToMarkdown::REVERSE_MARKDOWN_OPTIONS.merge(options)
22
+ Coradoc::Input::Html.to_coradoc(doc, options)
23
+ ensure
24
+ FileUtils.rm_rf(image_dir)
25
+ end
25
26
 
26
- def self.processor_postprocess(data, options)
27
- Coradoc::Input::HTML.processor_postprocess(data, options)
28
- end
27
+ def self.processor_postprocess(data, options)
28
+ Coradoc::Input::Html.processor_postprocess(data, options)
29
+ end
29
30
 
30
- # This processor prefers to work on original files.
31
- def self.processor_wants_filenames; true; end
31
+ # This processor prefers to work on original files.
32
+ def self.processor_wants_filenames; true; end
32
33
 
33
- Coradoc::Input.define(self)
34
+ Coradoc::Input.define(self)
35
+ end
34
36
  end
35
37
  end
@@ -293,7 +293,7 @@ end
293
293
  require 'coradoc/input/html'
294
294
 
295
295
  # Options can be supplied as keyword arguments
296
- Coradoc::Input::HTML::HtmlConverter.to_coradoc("<b><i>Some input</i></b>")
296
+ Coradoc::Input::Html::HtmlConverter.to_coradoc("<b><i>Some input</i></b>")
297
297
  ----
298
298
 
299
299