metanorma-standoc 3.5.8 → 3.5.10
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/Gemfile +3 -4
- data/lib/metanorma/converter/anchor.rb +34 -1
- data/lib/metanorma/converter/macros.rb +0 -1
- data/lib/metanorma/converter/macros_nosub.rb +52 -4
- data/lib/metanorma/standoc/version.rb +1 -1
- data/link-break.doc +1102 -0
- data/link-break.html +282 -0
- data/link-break.pdf +0 -0
- data/link-break.pdf.err +1 -0
- data/link-break.presentation.xml +57 -0
- data/link-break.xml +13 -0
- data/metanorma-standoc.gemspec +1 -4
- data/test.err.html +53 -0
- metadata +12 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e370c3b33728b5d7e932bfd3ca83ce9745483dd20ba106f6421bbb912d74bf5e
|
|
4
|
+
data.tar.gz: 97a76845afeeda316331a47efd7d7df822fcb0aeab4f61c012612885087f2892
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90d40e857546db6a0ea0cc0c74dea05767f5d71e29e671ae69db47334ad06ff5d7850e32572ce2e7ae4c6283247bbeb951e195e2acfe411bb1da76d9b4ffaadc
|
|
7
|
+
data.tar.gz: 7b6c7c720b241dd67e912d4d51efa1b35501e9b482b60d60974d778b71d7449dfbd7fad9146573ff7b2438496b39f319ee16d9135837d471382505b0299dd464
|
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
|
-
|
|
32
|
-
gem "
|
|
33
|
-
gem "
|
|
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
|
|
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
|
|
|
@@ -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
|
-
|
|
9
|
+
out = []
|
|
10
|
+
buf = nil
|
|
11
|
+
reader.lines.each do |t|
|
|
10
12
|
p.process(t)
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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)
|