coradoc 1.1.6 → 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 (120) 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/README.adoc +5 -0
  8. data/coradoc.gemspec +5 -5
  9. data/exe/reverse_adoc +1 -1
  10. data/exe/w2a +1 -1
  11. data/flake.lock +114 -0
  12. data/flake.nix +135 -0
  13. data/lib/coradoc/cli.rb +1 -1
  14. data/lib/coradoc/converter.rb +4 -5
  15. data/lib/coradoc/element/attribute.rb +10 -1
  16. data/lib/coradoc/element/attribute_list.rb +4 -3
  17. data/lib/coradoc/element/audio.rb +1 -1
  18. data/lib/coradoc/element/author.rb +2 -2
  19. data/lib/coradoc/element/base.rb +14 -2
  20. data/lib/coradoc/element/bibliography.rb +1 -1
  21. data/lib/coradoc/element/bibliography_entry.rb +1 -1
  22. data/lib/coradoc/element/block/open.rb +1 -1
  23. data/lib/coradoc/element/block.rb +1 -1
  24. data/lib/coradoc/element/document_attributes.rb +8 -2
  25. data/lib/coradoc/element/image/block_image.rb +3 -2
  26. data/lib/coradoc/element/image/core.rb +5 -4
  27. data/lib/coradoc/element/inline/attribute_reference.rb +19 -0
  28. data/lib/coradoc/element/inline/cross_reference.rb +4 -3
  29. data/lib/coradoc/element/inline/footnote.rb +24 -0
  30. data/lib/coradoc/element/inline/small.rb +19 -0
  31. data/lib/coradoc/element/inline/span.rb +37 -0
  32. data/lib/coradoc/element/inline/underline.rb +19 -0
  33. data/lib/coradoc/element/inline.rb +5 -1
  34. data/lib/coradoc/element/list/core.rb +2 -2
  35. data/lib/coradoc/element/list/ordered.rb +1 -0
  36. data/lib/coradoc/element/list/unordered.rb +1 -0
  37. data/lib/coradoc/element/list_item.rb +19 -20
  38. data/lib/coradoc/element/table.rb +4 -2
  39. data/lib/coradoc/element/term.rb +1 -0
  40. data/lib/coradoc/element/text_element.rb +4 -1
  41. data/lib/coradoc/element/title.rb +1 -1
  42. data/lib/coradoc/element/video.rb +2 -2
  43. data/lib/coradoc/input/adoc.rb +20 -18
  44. data/lib/coradoc/input/docx.rb +25 -23
  45. data/lib/coradoc/input/html/README.adoc +1 -1
  46. data/lib/coradoc/input/html/cleaner.rb +121 -117
  47. data/lib/coradoc/input/html/config.rb +58 -56
  48. data/lib/coradoc/input/html/converters/a.rb +44 -39
  49. data/lib/coradoc/input/html/converters/aside.rb +12 -8
  50. data/lib/coradoc/input/html/converters/audio.rb +24 -20
  51. data/lib/coradoc/input/html/converters/base.rb +103 -99
  52. data/lib/coradoc/input/html/converters/blockquote.rb +18 -14
  53. data/lib/coradoc/input/html/converters/br.rb +11 -7
  54. data/lib/coradoc/input/html/converters/bypass.rb +77 -73
  55. data/lib/coradoc/input/html/converters/code.rb +18 -14
  56. data/lib/coradoc/input/html/converters/div.rb +15 -11
  57. data/lib/coradoc/input/html/converters/dl.rb +51 -44
  58. data/lib/coradoc/input/html/converters/drop.rb +21 -17
  59. data/lib/coradoc/input/html/converters/em.rb +16 -12
  60. data/lib/coradoc/input/html/converters/figure.rb +19 -15
  61. data/lib/coradoc/input/html/converters/h.rb +32 -30
  62. data/lib/coradoc/input/html/converters/head.rb +17 -13
  63. data/lib/coradoc/input/html/converters/hr.rb +11 -7
  64. data/lib/coradoc/input/html/converters/ignore.rb +15 -11
  65. data/lib/coradoc/input/html/converters/img.rb +98 -93
  66. data/lib/coradoc/input/html/converters/li.rb +13 -9
  67. data/lib/coradoc/input/html/converters/mark.rb +14 -10
  68. data/lib/coradoc/input/html/converters/markup.rb +22 -18
  69. data/lib/coradoc/input/html/converters/math.rb +24 -20
  70. data/lib/coradoc/input/html/converters/ol.rb +55 -50
  71. data/lib/coradoc/input/html/converters/p.rb +16 -12
  72. data/lib/coradoc/input/html/converters/pass_through.rb +12 -8
  73. data/lib/coradoc/input/html/converters/pre.rb +49 -45
  74. data/lib/coradoc/input/html/converters/q.rb +12 -8
  75. data/lib/coradoc/input/html/converters/strong.rb +15 -11
  76. data/lib/coradoc/input/html/converters/sub.rb +15 -11
  77. data/lib/coradoc/input/html/converters/sup.rb +15 -11
  78. data/lib/coradoc/input/html/converters/table.rb +21 -13
  79. data/lib/coradoc/input/html/converters/td.rb +64 -60
  80. data/lib/coradoc/input/html/converters/text.rb +24 -20
  81. data/lib/coradoc/input/html/converters/th.rb +13 -9
  82. data/lib/coradoc/input/html/converters/tr.rb +17 -13
  83. data/lib/coradoc/input/html/converters/video.rb +24 -20
  84. data/lib/coradoc/input/html/converters.rb +45 -43
  85. data/lib/coradoc/input/html/errors.rb +8 -6
  86. data/lib/coradoc/input/html/html_converter.rb +93 -90
  87. data/lib/coradoc/input/html/plugin.rb +104 -104
  88. data/lib/coradoc/input/html/plugins/plateau.rb +197 -190
  89. data/lib/coradoc/input/html/postprocessor.rb +188 -182
  90. data/lib/coradoc/input/html.rb +34 -32
  91. data/lib/coradoc/oscal.rb +18 -5
  92. data/lib/coradoc/output/adoc.rb +13 -11
  93. data/lib/coradoc/output/coradoc_tree_debug.rb +15 -13
  94. data/lib/coradoc/parser/asciidoc/admonition.rb +6 -6
  95. data/lib/coradoc/parser/asciidoc/attribute_list.rb +43 -27
  96. data/lib/coradoc/parser/asciidoc/base.rb +3 -6
  97. data/lib/coradoc/parser/asciidoc/bibliography.rb +5 -6
  98. data/lib/coradoc/parser/asciidoc/block.rb +30 -31
  99. data/lib/coradoc/parser/asciidoc/citation.rb +11 -29
  100. data/lib/coradoc/parser/asciidoc/content.rb +23 -33
  101. data/lib/coradoc/parser/asciidoc/document_attributes.rb +2 -3
  102. data/lib/coradoc/parser/asciidoc/header.rb +1 -2
  103. data/lib/coradoc/parser/asciidoc/inline.rb +165 -42
  104. data/lib/coradoc/parser/asciidoc/list.rb +27 -27
  105. data/lib/coradoc/parser/asciidoc/paragraph.rb +28 -19
  106. data/lib/coradoc/parser/asciidoc/section.rb +11 -17
  107. data/lib/coradoc/parser/asciidoc/table.rb +5 -5
  108. data/lib/coradoc/parser/asciidoc/term.rb +24 -8
  109. data/lib/coradoc/parser/asciidoc/text.rb +18 -21
  110. data/lib/coradoc/parser/base.rb +0 -3
  111. data/lib/coradoc/reverse_adoc.rb +3 -3
  112. data/lib/coradoc/transformer.rb +167 -137
  113. data/lib/coradoc/version.rb +1 -1
  114. data/lib/reverse_adoc.rb +1 -1
  115. data/utils/inspect_asciidoc.rb +29 -0
  116. data/utils/parser_analyzer.rb +14 -14
  117. data/utils/round_trip.rb +31 -15
  118. metadata +41 -31
  119. data/.hound.yml +0 -5
  120. data/lib/coradoc/element/inline/citation.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f44a34ea3abbb6cff77d55b6516b74400db157035c2134a674ad5fe49a11f94
4
- data.tar.gz: aa000ad423925a5e39f410e72e543071f5aa33e5a10c2cdefc10ee8e3bfa3c57
3
+ metadata.gz: 61351918127e3bddfa39198817d989d701b8acd4f12dac620953cbe774f225ad
4
+ data.tar.gz: 32f37a1ad17a8cf4ef39cd9d55c8c67fc20a9fd4cfa2bd45e7aa2182f2b4526c
5
5
  SHA512:
6
- metadata.gz: f8f0ddca5617607309d097195635f5b316b84f031c381cfe9dc8274e557beadb4d610ad990909d219e49297bdedb67034889902e7dcbcfdf2617ec578fc75f69
7
- data.tar.gz: 6a98d048011b6314b2c9ae457e43f10730b0238f1329d4cae7d38494966d23b2e13a75dc4f4df1cb4938e5451b3363c5514be15aa6f1f55a4dbfb26eab6c7307
6
+ metadata.gz: b3e881fb0c7dab5fb554d38fa216f5c3c22bff1be1488106b7831c137f2a841d733c234ca1f41b5fbad92940a33b175f19ea43435a4379a978ab96c73908cef9
7
+ data.tar.gz: d066670c69d78e1273aeb8b26307a06aa4a847b261dc6eb0175fd69d0443e2e4a2f23b78973a518e749f9f630a9fb14396c5617fd222aba8aa9f8ecd219ec64c
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
data/.irbrc ADDED
@@ -0,0 +1 @@
1
+ require "coradoc"
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  # Auto-generated by Cimas: Do not edit it manually!
2
2
  # See https://github.com/metanorma/cimas
3
3
  inherit_from:
4
+ - .rubocop_todo.yml
4
5
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
6
 
6
7
  # local repo-specific modifications
7
8
  # ...
8
9
 
9
10
  AllCops:
10
- TargetRubyVersion: 2.5
11
+ TargetRubyVersion: 3.1
12
+
13
+ Layout/HashAlignment:
14
+ EnforcedHashRocketStyle: table
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,179 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-03-23 04:57:22 UTC using RuboCop version 1.74.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
12
+ # SupportedStyles: with_first_argument, with_fixed_indentation
13
+ Layout/ArgumentAlignment:
14
+ Exclude:
15
+ - 'lib/coradoc/input/html/converters/table.rb'
16
+
17
+ # Offense count: 1
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ Layout/BlockEndNewline:
20
+ Exclude:
21
+ - 'lib/coradoc/input/html/converters/table.rb'
22
+
23
+ # Offense count: 1
24
+ # This cop supports safe autocorrection (--autocorrect).
25
+ # Configuration parameters: Width, AllowedPatterns.
26
+ Layout/IndentationWidth:
27
+ Exclude:
28
+ - 'lib/coradoc/input/html/converters/table.rb'
29
+
30
+ # Offense count: 236
31
+ # This cop supports safe autocorrection (--autocorrect).
32
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
33
+ # URISchemes: http, https
34
+ Layout/LineLength:
35
+ Enabled: false
36
+
37
+ # Offense count: 6
38
+ # Configuration parameters: AllowedMethods.
39
+ # AllowedMethods: enums
40
+ Lint/ConstantDefinitionInBlock:
41
+ Exclude:
42
+ - 'spec/coradoc/element/attribute_list_spec.rb'
43
+ - 'spec/coradoc/parser/asciidoc/document_attributes_spec.rb'
44
+ - 'spec/coradoc/parser/asciidoc/header_spec.rb'
45
+ - 'spec/coradoc/parser/asciidoc/section_spec.rb'
46
+
47
+ # Offense count: 1
48
+ # This cop supports safe autocorrection (--autocorrect).
49
+ # Configuration parameters: AutoCorrect, AllowComments.
50
+ Lint/EmptyConditionalBody:
51
+ Exclude:
52
+ - 'lib/coradoc/element/attribute_list.rb'
53
+
54
+ # Offense count: 53
55
+ # Configuration parameters: AllowedParentClasses.
56
+ Lint/MissingSuper:
57
+ Enabled: false
58
+
59
+ # Offense count: 85
60
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
61
+ Metrics/AbcSize:
62
+ Enabled: false
63
+
64
+ # Offense count: 7
65
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
66
+ # AllowedMethods: refine
67
+ Metrics/BlockLength:
68
+ Max: 40
69
+
70
+ # Offense count: 23
71
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
72
+ Metrics/CyclomaticComplexity:
73
+ Enabled: false
74
+
75
+ # Offense count: 57
76
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
77
+ Metrics/MethodLength:
78
+ Max: 187
79
+
80
+ # Offense count: 1
81
+ # Configuration parameters: Max, CountKeywordArgs.
82
+ Metrics/ParameterLists:
83
+ MaxOptionalParameters: 4
84
+
85
+ # Offense count: 20
86
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
87
+ Metrics/PerceivedComplexity:
88
+ Enabled: false
89
+
90
+ # Offense count: 1
91
+ # Configuration parameters: ForbiddenDelimiters.
92
+ # ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
93
+ Naming/HeredocDelimiterNaming:
94
+ Exclude:
95
+ - 'utils/inspect_asciidoc.rb'
96
+
97
+ # Offense count: 1
98
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
99
+ # NamePrefix: is_, has_, have_
100
+ # ForbiddenPrefixes: is_, has_, have_
101
+ # AllowedMethods: is_a?
102
+ # MethodDefinitionMacros: define_method, define_singleton_method
103
+ Naming/PredicateName:
104
+ Exclude:
105
+ - 'spec/**/*'
106
+ - 'utils/parser_analyzer.rb'
107
+
108
+ # Offense count: 3
109
+ # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
110
+ # SupportedStyles: snake_case, normalcase, non_integer
111
+ # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
112
+ Naming/VariableNumber:
113
+ Exclude:
114
+ - 'spec/coradoc/parser_spec.rb'
115
+
116
+ # Offense count: 2
117
+ # This cop supports safe autocorrection (--autocorrect).
118
+ # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames.
119
+ # RedundantRestArgumentNames: args, arguments
120
+ # RedundantKeywordRestArgumentNames: kwargs, options, opts
121
+ # RedundantBlockArgumentNames: blk, block, proc
122
+ Style/ArgumentsForwarding:
123
+ Exclude:
124
+ - 'lib/coradoc/element/base.rb'
125
+
126
+ # Offense count: 2
127
+ # This cop supports safe autocorrection (--autocorrect).
128
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
129
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
130
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
131
+ # FunctionalMethods: let, let!, subject, watch
132
+ # AllowedMethods: lambda, proc, it
133
+ Style/BlockDelimiters:
134
+ Exclude:
135
+ - 'lib/coradoc/input/html/converters/table.rb'
136
+
137
+ # Offense count: 1
138
+ # This cop supports unsafe autocorrection (--autocorrect-all).
139
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
140
+ # SupportedStyles: nested, compact
141
+ # SupportedStylesForClasses: , nested, compact
142
+ # SupportedStylesForModules: , nested, compact
143
+ Style/ClassAndModuleChildren:
144
+ Exclude:
145
+ - 'lib/coradoc/input/html/converters/table.rb'
146
+
147
+ # Offense count: 2
148
+ # Configuration parameters: MinBranchesCount.
149
+ Style/HashLikeCase:
150
+ Exclude:
151
+ - 'lib/coradoc/input/html/converters/ol.rb'
152
+ - 'lib/coradoc/input/html/converters/table.rb'
153
+
154
+ # Offense count: 1
155
+ # This cop supports unsafe autocorrection (--autocorrect-all).
156
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
157
+ # SupportedStyles: predicate, comparison
158
+ Style/NumericPredicate:
159
+ Exclude:
160
+ - 'spec/**/*'
161
+ - 'lib/coradoc/parser/asciidoc/paragraph.rb'
162
+
163
+ # Offense count: 4
164
+ # Configuration parameters: AllowedMethods.
165
+ # AllowedMethods: respond_to_missing?
166
+ Style/OptionalBooleanParameter:
167
+ Exclude:
168
+ - 'lib/coradoc/element/attribute_list.rb'
169
+ - 'lib/coradoc/element/table.rb'
170
+ - 'lib/coradoc/parser/asciidoc/content.rb'
171
+ - 'lib/coradoc/parser/asciidoc/paragraph.rb'
172
+
173
+ # Offense count: 2
174
+ # This cop supports unsafe autocorrection (--autocorrect-all).
175
+ # Configuration parameters: Mode.
176
+ Style/StringConcatenation:
177
+ Exclude:
178
+ - 'lib/coradoc/element/attribute_list.rb'
179
+ - 'lib/coradoc/element/document_attributes.rb'
data/README.adoc CHANGED
@@ -1,5 +1,10 @@
1
1
  = Coradoc: object-oriented AsciiDoc parser
2
2
 
3
+ image:https://img.shields.io/gem/v/coradoc.svg["Gem Version", link="https://rubygems.org/gems/coradoc"]
4
+ image:https://github.com/metanorma/coradoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/coradoc/actions?workflow=rake"]
5
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/coradoc.svg["Pull Requests", link="https://github.com/metanorma/coradoc/pulls"]
6
+ image:https://img.shields.io/github/commits-since/metanorma/coradoc/latest.svg["Commits since latest",link="https://github.com/metanorma/coradoc/releases"]
7
+
3
8
  Coradoc is a modern Parser for Asciidoc document. It defines a grammar for
4
9
  AsciiDoc, and then build the Parser for that grammar.
5
10
 
data/coradoc.gemspec CHANGED
@@ -26,15 +26,15 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
27
 
28
28
  spec.require_paths = ["lib"]
29
- spec.required_ruby_version = ">= 2.7.0"
29
+ spec.required_ruby_version = ">= 3.1.0"
30
30
 
31
+ spec.add_dependency "base64"
31
32
  spec.add_dependency "marcel", "~> 1.0.0"
32
- spec.add_dependency "plurimath"
33
- spec.add_dependency "unitsml"
34
33
  spec.add_dependency "nokogiri", "~> 1.13"
35
34
  spec.add_dependency "oscal", "~> 0.1.1"
36
35
  spec.add_dependency "parslet"
37
- spec.add_dependency "word-to-markdown"
38
- spec.add_dependency "base64"
36
+ spec.add_dependency "plurimath"
39
37
  spec.add_dependency "thor", ">= 1.3.0"
38
+ spec.add_dependency "unitsml"
39
+ spec.add_dependency "word-to-markdown"
40
40
  end
data/exe/reverse_adoc CHANGED
@@ -12,7 +12,7 @@ require "fileutils"
12
12
  config = {
13
13
  input_options: input_options = {},
14
14
  input_processor: :html,
15
- output_options: output_options = {},
15
+ output_options: {},
16
16
  output_processor: :adoc,
17
17
  }
18
18
  destination = nil
data/exe/w2a CHANGED
@@ -13,7 +13,7 @@ ARGV.push("-h") if ARGV.empty?
13
13
  config = {
14
14
  input_options: input_options = {},
15
15
  input_processor: :docx,
16
- output_options: output_options = {},
16
+ output_options: {},
17
17
  output_processor: :adoc,
18
18
  }
19
19
  destination = nil
data/flake.lock ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "nodes": {
3
+ "devshell": {
4
+ "inputs": {
5
+ "nixpkgs": "nixpkgs"
6
+ },
7
+ "locked": {
8
+ "lastModified": 1735644329,
9
+ "narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=",
10
+ "owner": "numtide",
11
+ "repo": "devshell",
12
+ "rev": "f7795ede5b02664b57035b3b757876703e2c3eac",
13
+ "type": "github"
14
+ },
15
+ "original": {
16
+ "owner": "numtide",
17
+ "ref": "main",
18
+ "repo": "devshell",
19
+ "type": "github"
20
+ }
21
+ },
22
+ "flake-compat": {
23
+ "flake": false,
24
+ "locked": {
25
+ "lastModified": 1733328505,
26
+ "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
27
+ "owner": "edolstra",
28
+ "repo": "flake-compat",
29
+ "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
30
+ "type": "github"
31
+ },
32
+ "original": {
33
+ "owner": "edolstra",
34
+ "repo": "flake-compat",
35
+ "type": "github"
36
+ }
37
+ },
38
+ "flake-utils": {
39
+ "inputs": {
40
+ "systems": "systems"
41
+ },
42
+ "locked": {
43
+ "lastModified": 1731533236,
44
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
45
+ "owner": "numtide",
46
+ "repo": "flake-utils",
47
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
48
+ "type": "github"
49
+ },
50
+ "original": {
51
+ "owner": "numtide",
52
+ "repo": "flake-utils",
53
+ "type": "github"
54
+ }
55
+ },
56
+ "nixpkgs": {
57
+ "locked": {
58
+ "lastModified": 1722073938,
59
+ "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
60
+ "owner": "NixOS",
61
+ "repo": "nixpkgs",
62
+ "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
63
+ "type": "github"
64
+ },
65
+ "original": {
66
+ "owner": "NixOS",
67
+ "ref": "nixpkgs-unstable",
68
+ "repo": "nixpkgs",
69
+ "type": "github"
70
+ }
71
+ },
72
+ "nixpkgs_2": {
73
+ "locked": {
74
+ "lastModified": 1740462281,
75
+ "narHash": "sha256-XBy4GxTPJRt/43Z4Ra7jud7vLFaElTW0veddAPGk8P0=",
76
+ "owner": "nixos",
77
+ "repo": "nixpkgs",
78
+ "rev": "521ddca6084dd8e203f68dbd36b392d890e2a85a",
79
+ "type": "github"
80
+ },
81
+ "original": {
82
+ "owner": "nixos",
83
+ "ref": "master",
84
+ "repo": "nixpkgs",
85
+ "type": "github"
86
+ }
87
+ },
88
+ "root": {
89
+ "inputs": {
90
+ "devshell": "devshell",
91
+ "flake-compat": "flake-compat",
92
+ "flake-utils": "flake-utils",
93
+ "nixpkgs": "nixpkgs_2"
94
+ }
95
+ },
96
+ "systems": {
97
+ "locked": {
98
+ "lastModified": 1681028828,
99
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
100
+ "owner": "nix-systems",
101
+ "repo": "default",
102
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
103
+ "type": "github"
104
+ },
105
+ "original": {
106
+ "owner": "nix-systems",
107
+ "repo": "default",
108
+ "type": "github"
109
+ }
110
+ }
111
+ },
112
+ "root": "root",
113
+ "version": 7
114
+ }
data/flake.nix ADDED
@@ -0,0 +1,135 @@
1
+ {
2
+ description = "Ruby Dev Env";
3
+ inputs = {
4
+ nixpkgs.url = "github:nixos/nixpkgs/master";
5
+ flake-utils.url = "github:numtide/flake-utils";
6
+ devshell.url = "github:numtide/devshell/main";
7
+ flake-compat = {
8
+ url = "github:edolstra/flake-compat";
9
+ flake = false;
10
+ };
11
+ };
12
+ outputs =
13
+ { self
14
+ , nixpkgs
15
+ , flake-utils
16
+ , devshell
17
+ , flake-compat
18
+ , ...
19
+ }:
20
+ flake-utils.lib.eachDefaultSystem (system:
21
+ let
22
+ cwd = builtins.toString ./.;
23
+ overlays = map (x: x.overlays.default) [
24
+ devshell
25
+ ];
26
+ pkgs = import nixpkgs { inherit system overlays; };
27
+ runtimeDependencies = with pkgs; [
28
+ graphviz
29
+ inkscape
30
+ jre
31
+ plantuml
32
+ xml2rfc
33
+ ];
34
+ in
35
+ rec {
36
+
37
+ # nix develop
38
+ devShell = pkgs.devshell.mkShell {
39
+
40
+ env = [
41
+ ];
42
+ commands = [
43
+ {
44
+ name = "soffice-test";
45
+ # name = "soffice"; # This for some reason will stall the shell.
46
+ command = "${pkgs.libreoffice-bin}/Applications/LibreOffice.app/Contents/MacOS/soffice \"$@\"";
47
+ help = "Run libreoffice CLI";
48
+ category = "App";
49
+ }
50
+ {
51
+ name = "reverse_adoc";
52
+ command = "exe/reverse_adoc \"$@\"";
53
+ help = "Run reverse_adoc CLI";
54
+ category = "App";
55
+ }
56
+ {
57
+ name = "coradoc";
58
+ command = "exe/coradoc \"$@\"";
59
+ help = "Run coradoc CLI";
60
+ category = "App";
61
+ }
62
+ {
63
+ name = "release";
64
+ command = "bundle exec rake release \"$@\"";
65
+ help = "Run rake release, which adds a tag and pushes to RubyGems";
66
+ category = "Ruby";
67
+ }
68
+ {
69
+ name = "lint";
70
+ command = "bundle exec rubocop \"$@\"";
71
+ help = "Run rubocop";
72
+ category = "Ruby";
73
+ }
74
+ {
75
+ name = "update-flakes";
76
+ command = "make update-flakes \"$@\"";
77
+ help = "Update all flakes";
78
+ category = "Nix";
79
+ }
80
+ ] ++
81
+ # Only append these if there is no .tool-verions file
82
+ # to avoid conflicts:
83
+ (if ! builtins.pathExists ./.tool-versions then
84
+ [{
85
+
86
+ name = "irb";
87
+ command = "bundle exec irb \"$@\"";
88
+ help = "Run console IRB (has completion menu)";
89
+ category = "Ruby";
90
+ }
91
+ {
92
+ name = "console";
93
+ command = "bundle exec irb \"$@\"";
94
+ help = "Run console IRB (has completion menu)";
95
+ category = "Ruby";
96
+ }
97
+ {
98
+ name = "pry";
99
+ command = "bundle exec pry \"$@\"";
100
+ help = "Run pry";
101
+ category = "Ruby";
102
+ }
103
+ {
104
+ name = "rspec";
105
+ command = "bundle exec rspec \"$@\"";
106
+ help = "Run test suite";
107
+ category = "Ruby";
108
+ }]
109
+ else [ ]);
110
+
111
+ packages = with pkgs; [
112
+ # rubocop # Install with your Gemfile / gemspec
113
+ # ruby # Install with your favourite Ruby version manager, etc.
114
+ # rubyPackages.solargraph # Bring your own
115
+ # rubyfmt # Broken
116
+ bash
117
+ curl
118
+ fd
119
+ gnused
120
+ jq
121
+ ripgrep
122
+ rubyPackages.ruby-lsp
123
+ rubyPackages.sorbet-runtime
124
+ wget
125
+ # libreoffice-still # unsupported in darwin
126
+ # libreoffice-unwrapped # unsupported in darwin
127
+ # libreoffice # unsupported in darwin
128
+ # libreoffice-bin # soffice returns nothing. Wrapper to call LibreOffice.App/Contents/MacOS/soffice implemented in devShell's command
129
+ pkg-config # for building native extensions
130
+ ] ++
131
+ runtimeDependencies;
132
+
133
+ };
134
+ });
135
+ }
data/lib/coradoc/cli.rb CHANGED
@@ -57,7 +57,7 @@ module Coradoc
57
57
  config = {
58
58
  input_options: input_options = {},
59
59
  input_processor: nil,
60
- output_options: output_options = {},
60
+ output_options: {},
61
61
  output_processor: nil,
62
62
  }
63
63
 
@@ -16,8 +16,8 @@ module Coradoc
16
16
  yield if block_given?
17
17
  end
18
18
 
19
- def self.call(*args, **kwargs, &block)
20
- new(*args, **kwargs, &block).convert
19
+ def self.call(...)
20
+ new(...).convert
21
21
  end
22
22
 
23
23
  def input_processor
@@ -37,7 +37,7 @@ module Coradoc
37
37
  end
38
38
 
39
39
  def convert(data = nil)
40
- input_id = input_processor.processor_id
40
+ input_processor.processor_id
41
41
  output_id = output_processor.processor_id
42
42
 
43
43
  unless data
@@ -51,8 +51,7 @@ module Coradoc
51
51
  if input_processor.respond_to? :processor_wants_filenames
52
52
  unless input.respond_to? :path
53
53
  raise NoInputPathError,
54
- "no input path given, but #{input_processor} wants that " +
55
- "form. Ensure you don't read from standard input."
54
+ "no input path given, but #{input_processor} wants that form. Ensure you don't read from standard input."
56
55
  end
57
56
 
58
57
  data = input.path
@@ -5,7 +5,16 @@ module Coradoc
5
5
 
6
6
  def initialize(key, value, _options = {})
7
7
  @key = key.to_s
8
- @value = build_values(value.to_s)
8
+ @value = if extensions_value?(value.to_s)
9
+ build_values(value.to_s)
10
+ else
11
+ value.to_s.strip
12
+ end
13
+ end
14
+
15
+ def extensions_value?(value)
16
+ v = value.split(",").map(&:strip)
17
+ v.intersect? %w[xml html pdf xml adoc rxl]
9
18
  end
10
19
 
11
20
  private
@@ -59,7 +59,7 @@ module Coradoc
59
59
  end
60
60
 
61
61
  def validate_named(validators)
62
- @named.each_with_index do |(name, value), i|
62
+ @named.each_with_index do |(name, value), _i|
63
63
  name = name.to_sym
64
64
  validator = validators[name]
65
65
 
@@ -82,8 +82,9 @@ module Coradoc
82
82
  adoc << "," if @positional.any? && @named.any?
83
83
  adoc << @named.map do |k, v|
84
84
  if v.is_a?(String)
85
- v = v.gsub("\"", "\\\"")
86
- if v.include?(",") || v.include?('"')
85
+ if (v[0] == '"' && v[-1] == '"') || (v[0] == "'" && v[-1] == "'")
86
+ elsif v.include?(",") || v.include?('"')
87
+ v = v.gsub("\"", "\\\"")
87
88
  v = "\"#{v}\""
88
89
  end
89
90
  elsif v.is_a?(Array)
@@ -27,7 +27,7 @@ module Coradoc
27
27
  end: Integer,
28
28
  options: many("nofollow", "noopener", "inline", "interactive"),
29
29
  opts: many("nofollow", "noopener", "inline", "interactive"),
30
- }
30
+ }.freeze
31
31
  end
32
32
  end
33
33
  end
@@ -13,9 +13,9 @@ module Coradoc
13
13
  end
14
14
 
15
15
  def to_adoc
16
- adoc = "#{@first_name}"
16
+ adoc = @first_name.to_s
17
17
  adoc << " #{@middle_name}" if @middle_name
18
- adoc << " #{@last_name.to_s}"
18
+ adoc << " #{@last_name}"
19
19
  adoc << " <#{@email}>\n" if @email
20
20
  adoc
21
21
  end
@@ -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