coradoc-markdown 1.0.10 → 1.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45a195eaddedba173983f2ba2ab08ce81044fe089124b8287b4a643262dbc6f8
4
- data.tar.gz: b163677948cdc8459692c411c2840f2bfa0cfe401e47453d61e88d156bbfc910
3
+ metadata.gz: 860562e968c6a646a564edac417a882d9d477ef09c7bb84c477a6ab13fcd6fd0
4
+ data.tar.gz: de5901c3b2e6eb123a718a14466d6bf688358e350ad95564abfcc17ebd62c660
5
5
  SHA512:
6
- metadata.gz: 3b6c63bf4e97c80a63c4f6289576f80577434d6aa8176aafd3067c026abbad4c9ab72fbe509e936933f60ef6cf02c7e3b6087efab353f541618ffe75d6c93ad1
7
- data.tar.gz: 0a7a78dc0d92fd3c03344df7a6063429b443dcacfc760686a7d3080b6df7daff9b873251a1576d73307bbacfa8e642e08e02561625f6cfcd2d493f524843dd4b
6
+ metadata.gz: 313e3f097c07329bfacd65ce3283c33087136a9e3d8f5259298c40781b76d10495b98dd89c3c3977b27e40d667d0a056ef9c012dc89165bcecc47293333e3442
7
+ data.tar.gz: 5125a17bab25bde3da034de5b898fd28214f9e18857a9ca471e03795683fd2a9f85d3d7c3bd2925d0abf1f4b36acf6e37c71ef6f4ce2aa7389a65c7e562f8bf3
@@ -390,7 +390,7 @@ module Coradoc
390
390
 
391
391
  # Pattern to match HTML tags with markdown attribute
392
392
  # Captures: tag name, markdown value, content, closing tag
393
- pattern = %r{<(#{HTML_TAG_PATTERN})\s+([^>]*?)markdown\s*=\s*["']([^"']+)["']([^>]*)>(.*?)</\1>}im
393
+ pattern = %r{<(#{HTML_TAG_PATTERN})\s+([^>]*?)markdown\s*=\s*["']([^"']+)["']([^>]*)>(.*?)</\1>}imo
394
394
 
395
395
  text.gsub(pattern) do |_match|
396
396
  tag_name = ::Regexp.last_match(1)
@@ -23,9 +23,9 @@ module Coradoc
23
23
 
24
24
  rule(:whitespace) { match[" \t"] }
25
25
  # NOTE: repeat(1) before EOF (any.absent?) because infinite loop otherwise
26
- rule(:blank_line) { (whitespace.repeat(1) >> any.absent? | whitespace.repeat >> line_ending).ignore }
26
+ rule(:blank_line) { ((whitespace.repeat(1) >> any.absent?) | (whitespace.repeat >> line_ending)).ignore }
27
27
  rule(:blank_line_verbatim) do
28
- whitespace.repeat(1).as(:ln) >> any.absent? | whitespace.repeat.as(:ln) >> line_ending
28
+ (whitespace.repeat(1).as(:ln) >> any.absent?) | (whitespace.repeat.as(:ln) >> line_ending)
29
29
  end
30
30
  rule(:line_char) { match["^\r\n"] }
31
31
  rule(:line_verbatim) { line_char.repeat(1).as(:ln) >> line_ending_or_eof }
@@ -222,7 +222,7 @@ module Coradoc
222
222
  end
223
223
 
224
224
  rule(:paragraph_line) do
225
- line_char.repeat(1).as(:ln) >> any.absent? | line_char.repeat.as(:ln) >> line_ending
225
+ (line_char.repeat(1).as(:ln) >> any.absent?) | (line_char.repeat.as(:ln) >> line_ending)
226
226
  end
227
227
 
228
228
  rule(:paragraph_continued_line) do
@@ -286,8 +286,8 @@ module Coradoc
286
286
  rule(:ial_key_value) do
287
287
  match['\\w\\-'].repeat(1) >> str('=') >>
288
288
  (
289
- str('"') >> match['^"'].repeat(0) >> str('"') |
290
- str("'") >> match["^'"].repeat(0) >> str("'") |
289
+ (str('"') >> match['^"'].repeat(0) >> str('"')) |
290
+ (str("'") >> match["^'"].repeat(0) >> str("'")) |
291
291
  match['^\\s\\}'].repeat(1)
292
292
  )
293
293
  end
@@ -322,8 +322,8 @@ module Coradoc
322
322
  rule(:extension_option) do
323
323
  match['\\w\\-'].repeat(1) >> str('=') >>
324
324
  (
325
- str('"') >> match['^"'].repeat(0) >> str('"') |
326
- str("'") >> match["^'"].repeat(0) >> str("'") |
325
+ (str('"') >> match['^"'].repeat(0) >> str('"')) |
326
+ (str("'") >> match["^'"].repeat(0) >> str("'")) |
327
327
  match['^\\s/\\}'].repeat(1)
328
328
  )
329
329
  end
@@ -466,11 +466,11 @@ module Coradoc
466
466
  # List item continuation line (indented content that's not a block)
467
467
  # Excludes lines that look like nested list markers
468
468
  rule(:list_continuation_line) do
469
- (str(' ') | str("\t")) >>
470
- nested_list_marker.absent? >>
471
- line_verbatim |
469
+ ((str(' ') | str("\t")) >>
472
470
  nested_list_marker.absent? >>
473
- line_verbatim
471
+ line_verbatim) |
472
+ (nested_list_marker.absent? >>
473
+ line_verbatim)
474
474
  end
475
475
 
476
476
  # Nested list marker detection (for 4-space indented lists)
@@ -513,8 +513,8 @@ module Coradoc
513
513
 
514
514
  # Nested block (indented list, etc.)
515
515
  rule(:nested_block) do
516
- (str(' ') | str("\t")) >> nested_unordered_list |
517
- (str(' ') | str("\t")) >> nested_ordered_list
516
+ ((str(' ') | str("\t")) >> nested_unordered_list) |
517
+ ((str(' ') | str("\t")) >> nested_ordered_list)
518
518
  end
519
519
 
520
520
  # Nested unordered list (4-space indented)
@@ -266,7 +266,7 @@ module Coradoc
266
266
  end
267
267
 
268
268
  def parse(io, options = {})
269
- process_emphasis(super(io, options))
269
+ process_emphasis(super)
270
270
  end
271
271
  end
272
272
  end
@@ -71,11 +71,11 @@ module Coradoc
71
71
  def self.extract_quoted_value(scanner, handle_escapes: false)
72
72
  if scanner.scan(/"([^"\\]*(?:\\.[^"\\]*)*)"/)
73
73
  value = scanner[1]
74
- value = value.gsub(/\\"/, '"') if handle_escapes
74
+ value = value.gsub('\"', '"') if handle_escapes
75
75
  value
76
76
  elsif scanner.scan(/'([^'\\]*(?:\\.[^'\\]*)*)'/)
77
77
  value = scanner[1]
78
- value = value.gsub(/\\'/, "'") if handle_escapes
78
+ value = value.gsub('\\\'', "'") if handle_escapes
79
79
  value
80
80
  elsif scanner.scan(/(\S+)/)
81
81
  scanner[1]
@@ -48,7 +48,7 @@ module Coradoc
48
48
  end
49
49
 
50
50
  def with(overrides)
51
- self.class.new(**to_h.merge(symbolize(overrides)))
51
+ self.class.new(**to_h, **symbolize(overrides))
52
52
  end
53
53
 
54
54
  private
@@ -58,15 +58,9 @@ module Coradoc
58
58
  end
59
59
 
60
60
  def validate_options!(resolved)
61
- unless %i[github container html gfm_alert].include?(resolved.fetch(:admonition_style))
62
- raise ArgumentError, "Unknown admonition_style: #{resolved[:admonition_style].inspect}"
63
- end
64
- unless %i[html flatten].include?(resolved.fetch(:definition_list_nested))
65
- raise ArgumentError, "Unknown definition_list_nested: #{resolved[:definition_list_nested].inspect}"
66
- end
67
- unless [true, false].include?(resolved.fetch(:suppress_comments))
68
- raise ArgumentError, 'suppress_comments must be boolean'
69
- end
61
+ raise ArgumentError, "Unknown admonition_style: #{resolved[:admonition_style].inspect}" unless %i[github container html gfm_alert].include?(resolved.fetch(:admonition_style))
62
+ raise ArgumentError, "Unknown definition_list_nested: #{resolved[:definition_list_nested].inspect}" unless %i[html flatten].include?(resolved.fetch(:definition_list_nested))
63
+ raise ArgumentError, 'suppress_comments must be boolean' unless [true, false].include?(resolved.fetch(:suppress_comments))
70
64
  return if [true, false].include?(resolved.fetch(:autolinks))
71
65
 
72
66
  raise ArgumentError, 'autolinks must be boolean'
@@ -39,7 +39,7 @@ module Coradoc
39
39
  def lookup!(element)
40
40
  lookup(element) || raise(ArgumentError,
41
41
  "Unknown element type for serialization: #{element.class}. " \
42
- 'Expected a known Markdown model type.')
42
+ 'Expected a known Markdown model type.')
43
43
  end
44
44
 
45
45
  private
@@ -40,7 +40,7 @@ module Coradoc
40
40
  else
41
41
  raise ArgumentError,
42
42
  "Unknown element type for serialization: #{element.class}. " \
43
- 'Expected a known Markdown model type.'
43
+ 'Expected a known Markdown model type.'
44
44
  end
45
45
  end
46
46
  end
@@ -55,6 +55,8 @@ module Coradoc
55
55
  Coradoc::Markdown::Text.new(content: model.title.to_s)
56
56
  when Coradoc::CoreModel::CommentLine
57
57
  Coradoc::Markdown::Comment.new(text: model.text.to_s)
58
+ when Coradoc::CoreModel::Include
59
+ transform_include(model)
58
60
  when Coradoc::CoreModel::TextContent
59
61
  model.text.to_s
60
62
  when Array
@@ -66,6 +68,17 @@ module Coradoc
66
68
 
67
69
  private
68
70
 
71
+ # Markdown has no transclusion — an unresolved include edge is
72
+ # preserved as an HTML comment so no information is lost and
73
+ # serialization never crashes on graph-mode documents.
74
+ def transform_include(element)
75
+ Coradoc::Markdown::Comment.new(text: include_directive_text(element))
76
+ end
77
+
78
+ def include_directive_text(element)
79
+ "include::#{element.target}[#{element.raw_options}]"
80
+ end
81
+
69
82
  def transform_structural_element(element)
70
83
  case element
71
84
  when CoreModel::DocumentElement
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module Markdown
5
- VERSION = '1.0.10'
5
+ VERSION = '1.0.11'
6
6
  end
7
7
  end
@@ -127,9 +127,9 @@ module Coradoc
127
127
  # @param filename [String] Path to the Markdown file
128
128
  # @param options [Hash] Parsing options (see #parse)
129
129
  # @return [Array] The parsed AST
130
- def from_file(filename, **options)
130
+ def from_file(filename, **)
131
131
  content = File.read(filename)
132
- parse(content, **options)
132
+ parse(content, **)
133
133
  end
134
134
 
135
135
  # Parse inline Markdown content
@@ -150,6 +150,13 @@ module Coradoc
150
150
  Serializer.serialize(document, options)
151
151
  end
152
152
 
153
+ # Markdown preserves unresolved include edges as HTML comments
154
+ # (Transform::FromCoreModel#transform_include) — lossy formatting,
155
+ # but never silent content loss.
156
+ def preserves_unresolved_includes?
157
+ true
158
+ end
159
+
153
160
  # Check if this format can transform the given model to CoreModel
154
161
  #
155
162
  # @param model [Object] The model to check
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -232,6 +232,7 @@ metadata:
232
232
  homepage_uri: https://github.com/metanorma/coradoc
233
233
  source_code_uri: https://github.com/metanorma/coradoc
234
234
  changelog_uri: https://github.com/metanorma/coradoc/releases
235
+ rubygems_mfa_required: 'true'
235
236
  rdoc_options: []
236
237
  require_paths:
237
238
  - lib