metanorma-standoc 3.5.9 → 3.5.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: ea3e2fa0c63ac0260f6d1d1d43b4d711494094c811a6784701977bdb3da5e746
4
- data.tar.gz: 00a47e62f0a808dff717048a0795d2b48c9e8c42ec61c16656899e8a8dd9ca4b
3
+ metadata.gz: 59b66af0a957fc5c8af49a88b81b59d7bb5d02edeb88beae9289696063e406ef
4
+ data.tar.gz: 560e72bd9e7f32ef4cce3e787a75522df36cda27c87df497dfbe72f91a6f483f
5
5
  SHA512:
6
- metadata.gz: f5f0a0f9a6f4508a28a9f59a31ef375cee6ad12218d12ad7db3a6f9575433e8234226d0fa5f9579e486cf49b41f0bb172d48ac57883ce5f945f41eb75d99b355
7
- data.tar.gz: 0a195fdf207ba3d6c25f6424ce8bfb3b4dc0584b6ef1180c06aba9283091a11e5e519a9f78ed4a53730bf9029f34917653d42bd6a8b97b31fa491cb9459ca332
6
+ metadata.gz: fde7a1d249a4070705f23f6fddfaa81bd95c198e697b955a81e4486cb72afb02636e7c412480588e9ac4240b7b078b8b9fa2c317258c64283e0dba569da0938a
7
+ data.tar.gz: c6fd770b5d164283c9192df960d16943efa2ba2978aa1e9146fbccf3bc6cbac930e093fa40d84cf407c6c3e557fdb2dc1cb9bc51d77537e120eb00e2b09a4f77
data/Gemfile CHANGED
@@ -28,10 +28,9 @@ gem "isodoc", github: "metanorma/isodoc", branch: "main"
28
28
  # release. Prefer the released gem over a git pin: relaton main has since
29
29
  # moved to lutaml-store ~> 0.3, which conflicts with glossarist 2.14's
30
30
  # lutaml-store ~> 0.2.0 and makes this bundle unresolvable.
31
- # parsanol 1.3.120 removed the pre-1.3.113 grammar-header alias (mode), breaking pubid 2.0.1's baked self-description grammar at compile (81 suite failures). Pin below the break until pubid regenerates its artifacts against the current compiler.
32
- gem "parsanol", "< 1.3.120"
33
- gem "relaton", "~> 3.0"
34
- gem "pubid", ">= 2.0.3" # 2.0.3: edition-2 iso artifact
31
+ gem "parsanol", "~> 1.3.123"
32
+ gem "relaton", "~> 3.1.1"
33
+ gem "pubid", "~> 2.0" # 2.0.3+: edition-2 iso artifact
35
34
 
36
35
  gem "metanorma-plugin-lutaml", github: "metanorma/metanorma-plugin-lutaml", branch: "main"
37
36
 
@@ -81,9 +81,42 @@ module Metanorma
81
81
  def inline_anchor_link(node)
82
82
  contents, attributes = inline_anchor_link_attrs(node)
83
83
  noko do |xml|
84
- xml.link **attr_code(attributes) do |l|
84
+ link_hardbreak_segments(xml, contents, attr_code(attributes))
85
+ end
86
+ end
87
+
88
+ # A hard break inside link macro text is a " +" at end of line
89
+ # (asciidoctor HardLineBreakRx). Inline macros are substituted
90
+ # before post-replacements, so the break still arrives here in
91
+ # the raw node text, and the anchor's own markup is already in
92
+ # the paragraph string when sub_post_replacements expands that
93
+ # break: the expansion re-emits the whole preceding line through
94
+ # the break node, and the fragment parse of that line closes the
95
+ # still-open <link> early, leaking the tail as text with an
96
+ # orphaned close (metanorma-pdfa#102). Consume the break here
97
+ # instead: emit one link per break-separated segment, reopening
98
+ # the same target after each break, so no " +" survives into
99
+ # post-replacements and the emitted markup is well-formed.
100
+ HARD_BREAK_RX = / \+\n| \+\z/.freeze
101
+
102
+ def link_hardbreak_segments(xml, contents, attributes)
103
+ segs = contents.split(HARD_BREAK_RX, -1)
104
+ if segs.size <= 1
105
+ xml.link **attributes do |l|
85
106
  l << contents
86
107
  end
108
+ return
109
+ end
110
+ trailing = segs.last.empty?
111
+ segs.pop if trailing
112
+ segs.each_with_index do |seg, i|
113
+ xml.link **attributes do |l|
114
+ l << seg
115
+ end
116
+ last = i == segs.size - 1
117
+ br = !last || trailing
118
+ xml.br if br
119
+ xml << "\n" if br && !last
87
120
  end
88
121
  end
89
122
 
@@ -23,8 +23,6 @@ module Metanorma
23
23
  class Converter
24
24
  Asciidoctor::Extensions.register do
25
25
  preprocessor Metanorma::Standoc::ResolveIncludePreprocessor
26
- treeprocessor Metanorma::Plugin::Asciichem::Extension::ChemTreeprocessor
27
- inline_macro Metanorma::Plugin::Asciichem::Extension::ChemInlineMacro, :chem
28
26
  preprocessor Metanorma::Plugin::Lutaml::LutamlDataPreprocessor
29
27
  preprocessor Metanorma::Plugin::Lutaml::LutamlXsdPreprocessor
30
28
  preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
@@ -9,7 +9,6 @@ require_relative "macros_embed"
9
9
  require_relative "macros_link"
10
10
  require_relative "macros_nosub"
11
11
  require_relative "macros_number"
12
- require "metanorma-plugin-asciichem"
13
12
  require "metanorma-plugin-glossarist"
14
13
  require "metanorma-plugin-lutaml"
15
14
  require "metanorma-plugin-plantuml"
@@ -6,12 +6,60 @@ module Metanorma
6
6
  class LinkProtectPreprocessor < Asciidoctor::Extensions::Preprocessor
7
7
  def process(document, reader)
8
8
  p = Metanorma::Utils::LineStatus.new
9
- lines = reader.lines.map do |t|
9
+ out = []
10
+ buf = nil
11
+ reader.lines.each do |t|
10
12
  p.process(t)
11
- !p.pass && t.include?(":") and t = inlinelinkmacro(inlinelink(t))
12
- t
13
+ if buf
14
+ buf = "#{buf}\n#{t}"
15
+ next unless bracket_closed?(buf)
16
+
17
+ out << escape_line(buf, p.pass)
18
+ buf = nil
19
+ elsif bracket_open?(t)
20
+ # an inline macro's bracketed text may span lines (a hard
21
+ # break inside the link text); hold the fragment so the
22
+ # escape pass sees the whole macro instead of the first
23
+ # line's unclosed bracket, which it rewrites as a bare
24
+ # empty-text link
25
+ buf = t
26
+ else
27
+ out << escape_line(t, p.pass)
28
+ end
13
29
  end
14
- ::Asciidoctor::PreprocessorReader.new document, lines
30
+ out << buf if buf
31
+ ::Asciidoctor::PreprocessorReader.new document, out
32
+ end
33
+
34
+ def escape_line(text, pass)
35
+ !pass && text.include?(":") ? inlinelinkmacro(inlinelink(text)) : text
36
+ end
37
+
38
+ # Buffer only lines that open a link macro's bracketed text:
39
+ # buffering any other open-bracket line would defer that line's
40
+ # own substitution passes (e.g. character expansions), so the
41
+ # bracket-unclosed test is reserved for the URL/link/mailto
42
+ # prefixes the escape pass below actually rewrites.
43
+ #
44
+ # NOTE: no /x mode or comments in this pattern — TruffleRuby's
45
+ # TRegex parser rejects /x-commented patterns in this file (see
46
+ # PASS_INLINE_MACRO_STR).
47
+ LINK_MACRO_OPEN_RX =
48
+ /(?:\b(?:https?|file|ftp|irc):\/\/|\blink:(?!\+)|\bmailto:)/.freeze
49
+
50
+ # the line opens a bracket it never closes: a multi-line link
51
+ # macro (or a genuinely unterminated fragment, flushed verbatim
52
+ # at EOF)
53
+ def bracket_open?(line)
54
+ LINK_MACRO_OPEN_RX.match?(line) or return false
55
+ open = line.index("[") or return false
56
+ !bracket_closed?(line)
57
+ end
58
+
59
+ def bracket_closed?(text)
60
+ open = text.index("[") or return false
61
+ close = text.index("]", open) or return false
62
+ text[close - 1] != "\\"
15
63
  end
16
64
 
17
65
  PASS_INLINE_MACROS = %w(pass pass-format identifier std-link stem)
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "3.5.9".freeze
22
+ VERSION = "3.5.11".freeze
23
23
  end
24
24
  end