asciidoctor-iso 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.tb.yml +20 -10
- data/.travis.yml +3 -1
- data/Gemfile.lock +11 -11
- data/README.adoc +13 -8
- data/lib/asciidoctor/iso/base.rb +3 -0
- data/lib/asciidoctor/iso/biblio.rng +43 -25
- data/lib/asciidoctor/iso/blocks.rb +2 -2
- data/lib/asciidoctor/iso/cleanup.rb +4 -4
- data/lib/asciidoctor/iso/cleanup_block.rb +20 -6
- data/lib/asciidoctor/iso/cleanup_ref.rb +5 -4
- data/lib/asciidoctor/iso/front.rb +10 -3
- data/lib/asciidoctor/iso/html/isodoc.scss +15 -1
- data/lib/asciidoctor/iso/html/word_iso_titlepage.html +1 -1
- data/lib/asciidoctor/iso/html/wordstyle.scss +7 -0
- data/lib/asciidoctor/iso/isodoc.rng +19 -30
- data/lib/asciidoctor/iso/isostandard.rng +52 -14
- data/lib/asciidoctor/iso/section.rb +12 -1
- data/lib/asciidoctor/iso/utils.rb +3 -0
- data/lib/asciidoctor/iso/validate.rb +6 -6
- data/lib/asciidoctor/iso/validate_section.rb +6 -6
- data/lib/asciidoctor/iso/validate_style.rb +1 -1
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/base_spec.rb +3 -2
- data/spec/asciidoctor-iso/blocks_spec.rb +3 -3
- data/spec/asciidoctor-iso/cleanup_spec.rb +18 -12
- data/spec/asciidoctor-iso/inline_spec.rb +2 -1
- data/spec/asciidoctor-iso/refs_spec.rb +14 -7
- data/spec/asciidoctor-iso/section_spec.rb +57 -30
- data/spec/asciidoctor-iso/validate_spec.rb +8 -8
- data/spec/examples/rice.adoc +4 -1
- data/spec/examples/rice.preview.html +10 -3
- metadata +2 -5
- data/spec/examples/rice.doc +0 -18053
- data/spec/examples/rice.html +0 -1112
- data/spec/examples/rice.xml +0 -965
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7daddca4e53f6799078868555fe51888f8ad0dd
|
4
|
+
data.tar.gz: 6d069238f149cc8fdb5e6caa49fc2ca92b35c2ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06dc788c44fbf112301e8fbb91159efaf44e6c87ac7dd7d108c25e5db7e472911d15099a09f30ed37cd02812c10f054fc1ae23b6fdd619500806c706ec29dff0
|
7
|
+
data.tar.gz: 98b8dac9dff88dcb2da02fde81481144729d525f2bc0745a07d0b2cbafe48c7400049af385c8f9584c777e6db3d9c4b9e52e14f612b4728981e08ae07a5e7b67
|
data/.rubocop.tb.yml
CHANGED
@@ -352,8 +352,18 @@ Style/TrailingCommaInArguments:
|
|
352
352
|
- no_comma
|
353
353
|
Enabled: true
|
354
354
|
|
355
|
-
Style/
|
356
|
-
Description: 'Checks for trailing comma in array
|
355
|
+
Style/TrailingCommaInArrayLiteral:
|
356
|
+
Description: 'Checks for trailing comma in array literals.'
|
357
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
358
|
+
EnforcedStyleForMultiline: comma
|
359
|
+
SupportedStylesForMultiline:
|
360
|
+
- comma
|
361
|
+
- consistent_comma
|
362
|
+
- no_comma
|
363
|
+
Enabled: true
|
364
|
+
|
365
|
+
Style/TrailingCommaInHashLiteral:
|
366
|
+
Description: 'Checks for trailing comma in hash literals.'
|
357
367
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
358
368
|
EnforcedStyleForMultiline: comma
|
359
369
|
SupportedStylesForMultiline:
|
@@ -398,6 +408,13 @@ Layout/AlignParameters:
|
|
398
408
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
|
399
409
|
Enabled: false
|
400
410
|
|
411
|
+
Layout/ConditionPosition:
|
412
|
+
Description: >-
|
413
|
+
Checks for condition placed in a confusing position relative to
|
414
|
+
the keyword.
|
415
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
|
416
|
+
Enabled: false
|
417
|
+
|
401
418
|
Layout/DotPosition:
|
402
419
|
Description: 'Checks the position of the dot in multi-line method calls.'
|
403
420
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
|
@@ -450,13 +467,6 @@ Lint/CircularArgumentReference:
|
|
450
467
|
Description: "Don't refer to the keyword argument in the default value."
|
451
468
|
Enabled: false
|
452
469
|
|
453
|
-
Lint/ConditionPosition:
|
454
|
-
Description: >-
|
455
|
-
Checks for condition placed in a confusing position relative to
|
456
|
-
the keyword.
|
457
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
|
458
|
-
Enabled: false
|
459
|
-
|
460
470
|
Lint/DeprecatedClassMethods:
|
461
471
|
Description: 'Check for deprecated class method calls.'
|
462
472
|
Enabled: false
|
@@ -523,7 +533,7 @@ Lint/UnderscorePrefixedVariableName:
|
|
523
533
|
Description: 'Do not use prefix `_` for a variable that is used.'
|
524
534
|
Enabled: false
|
525
535
|
|
526
|
-
Lint/
|
536
|
+
Lint/UnneededCopDisableDirective:
|
527
537
|
Description: >-
|
528
538
|
Checks for rubocop:disable comments that can be removed.
|
529
539
|
Note: this cop is not disabled when disabling all cops.
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/riboseinc/html2doc.git
|
3
|
-
revision:
|
3
|
+
revision: 06a521ffd8fad90149699ae768040d25bba50cee
|
4
4
|
specs:
|
5
|
-
html2doc (0.
|
5
|
+
html2doc (0.7.0)
|
6
6
|
asciimath
|
7
7
|
htmlentities (~> 4.3.4)
|
8
8
|
image_size
|
@@ -14,9 +14,9 @@ GIT
|
|
14
14
|
|
15
15
|
GIT
|
16
16
|
remote: https://github.com/riboseinc/isodoc.git
|
17
|
-
revision:
|
17
|
+
revision: 951d28f6904f506208af360b2b0e42f7dc0d5d18
|
18
18
|
specs:
|
19
|
-
isodoc (0.5.
|
19
|
+
isodoc (0.5.8)
|
20
20
|
asciimath
|
21
21
|
html2doc
|
22
22
|
htmlentities (~> 4.3.4)
|
@@ -46,7 +46,7 @@ PATH
|
|
46
46
|
GEM
|
47
47
|
remote: https://rubygems.org/
|
48
48
|
specs:
|
49
|
-
asciidoctor (1.5.
|
49
|
+
asciidoctor (1.5.7)
|
50
50
|
asciimath (1.0.4)
|
51
51
|
ast (2.4.0)
|
52
52
|
byebug (9.1.0)
|
@@ -72,14 +72,14 @@ GEM
|
|
72
72
|
guard-compat (~> 1.1)
|
73
73
|
rspec (>= 2.99.0, < 4.0)
|
74
74
|
htmlentities (4.3.4)
|
75
|
-
image_size (
|
75
|
+
image_size (2.0.0)
|
76
76
|
json (2.1.0)
|
77
77
|
liquid (4.0.0)
|
78
78
|
listen (3.1.5)
|
79
79
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
80
80
|
rb-inotify (~> 0.9, >= 0.9.7)
|
81
81
|
ruby_dep (~> 1.2)
|
82
|
-
lumberjack (1.0.
|
82
|
+
lumberjack (1.0.13)
|
83
83
|
method_source (0.9.0)
|
84
84
|
mime-types (3.1)
|
85
85
|
mime-types-data (~> 3.2015)
|
@@ -93,14 +93,14 @@ GEM
|
|
93
93
|
shellany (~> 0.0)
|
94
94
|
optout (0.0.2)
|
95
95
|
parallel (1.12.1)
|
96
|
-
parser (2.5.0
|
96
|
+
parser (2.5.1.0)
|
97
97
|
ast (~> 2.4.0)
|
98
98
|
powerpack (0.1.1)
|
99
99
|
pry (0.11.3)
|
100
100
|
coderay (~> 1.1.0)
|
101
101
|
method_source (~> 0.9.0)
|
102
102
|
rainbow (3.0.0)
|
103
|
-
rake (12.3.
|
103
|
+
rake (12.3.1)
|
104
104
|
rb-fsevent (0.10.3)
|
105
105
|
rb-inotify (0.9.10)
|
106
106
|
ffi (>= 0.5.0, < 2)
|
@@ -118,7 +118,7 @@ GEM
|
|
118
118
|
diff-lcs (>= 1.2.0, < 2.0)
|
119
119
|
rspec-support (~> 3.7.0)
|
120
120
|
rspec-support (3.7.1)
|
121
|
-
rubocop (0.
|
121
|
+
rubocop (0.55.0)
|
122
122
|
parallel (~> 1.10)
|
123
123
|
parser (>= 2.5)
|
124
124
|
powerpack (~> 0.1)
|
@@ -144,7 +144,7 @@ GEM
|
|
144
144
|
thor (0.20.0)
|
145
145
|
thread_safe (0.3.6)
|
146
146
|
timecop (0.9.1)
|
147
|
-
unicode-display_width (1.3.
|
147
|
+
unicode-display_width (1.3.2)
|
148
148
|
uuidtools (2.1.5)
|
149
149
|
|
150
150
|
PLATFORMS
|
data/README.adoc
CHANGED
@@ -345,6 +345,16 @@ example:
|
|
345
345
|
The references cannot contain spaces. Any text following the sequence of localities
|
346
346
|
will be displayed instead of the localities.
|
347
347
|
|
348
|
+
A custom locality can be entered by prefixing it with `locality:`:
|
349
|
+
|
350
|
+
[source,asciidoctor]
|
351
|
+
--
|
352
|
+
<<ISO712,locality:frontispiece 5, page 8-10>> # renders as: ISO 712, Frontispiece 5, Page 8-10
|
353
|
+
--
|
354
|
+
|
355
|
+
Custom localities may not contain commas, colons, or space. Localities with the `locality:`
|
356
|
+
prefix are recognised in internationalisation configuration files.
|
357
|
+
|
348
358
|
=== Additional warning types
|
349
359
|
|
350
360
|
Asciidoctor natively supports the ISO admonitions "Caution", "Warning", and "Important"
|
@@ -644,13 +654,8 @@ used for validation from the generic IsoDoc grammar
|
|
644
654
|
|
645
655
|
The gem has been tested to date against the
|
646
656
|
https://www.iso.org/publication/PUB100407.html["Rice document"], the ISO's
|
647
|
-
model document of an international standard.
|
648
|
-
|
649
|
-
|
650
|
-
* the link:spec/examples/rice.preview.html[AsciiISO rendering of the Rice document as an HTML preview]
|
651
|
-
(native Asciidoc rendering)
|
652
|
-
* the link:spec/examples/rice.xml[ISO XML rendering of the Rice document].
|
653
|
-
* the link:spec/examples/rice.doc[Word .doc rendering of the Rice document].
|
654
|
-
* the link:spec/examples/rice.html[HTML rendering of the Rice document].
|
657
|
+
model document of an international standard. Sample representation of the Rice document
|
658
|
+
in Asciidoctor, and output formats, are included in the https://github.com/riboseinc/isodoc-rice
|
659
|
+
repository.
|
655
660
|
|
656
661
|
See also `link:spec/asciidoctor-iso[]` for individual features.
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -38,6 +38,7 @@ module Asciidoctor
|
|
38
38
|
engine = Sass::Engine.new(@fontheader + stylesheet, syntax: :scss)
|
39
39
|
outname = File.basename(filename, ".*") + ".css"
|
40
40
|
File.open(outname, "w") { |f| f.write(engine.render) }
|
41
|
+
@files_to_delete << outname
|
41
42
|
outname
|
42
43
|
end
|
43
44
|
|
@@ -72,6 +73,7 @@ module Asciidoctor
|
|
72
73
|
@draft = node.attributes.has_key?("draft")
|
73
74
|
@novalid = node.attr("novalid")
|
74
75
|
@fontheader = default_fonts(node)
|
76
|
+
@files_to_delete = []
|
75
77
|
end
|
76
78
|
|
77
79
|
def default_fonts(node)
|
@@ -94,6 +96,7 @@ module Asciidoctor
|
|
94
96
|
File.open(filename, "w") { |f| f.write(ret) }
|
95
97
|
html_converter(node).convert filename unless node.attr("nodoc")
|
96
98
|
doc_converter(node).convert filename unless node.attr("nodoc")
|
99
|
+
@files_to_delete.each { |f| system "rm #{f}" }
|
97
100
|
ret
|
98
101
|
end
|
99
102
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
21
21
|
<define name="status">
|
22
22
|
<element name="status">
|
23
|
-
<ref name="
|
23
|
+
<ref name="LocalizedString"/>
|
24
24
|
</element>
|
25
25
|
</define>
|
26
26
|
<define name="language">
|
@@ -346,21 +346,9 @@
|
|
346
346
|
</define>
|
347
347
|
<define name="locality">
|
348
348
|
<element name="locality">
|
349
|
+
<!-- attribute type { ( "section" | "clause" | "part" | "paragraph" | "chapter" | "page" | "whole" | "table" | "annex" | "figure" | "note" | "example" | ("locality:", text) ) }, -->
|
349
350
|
<attribute name="type">
|
350
|
-
<
|
351
|
-
<value>section</value>
|
352
|
-
<value>clause</value>
|
353
|
-
<value>part</value>
|
354
|
-
<value>paragraph</value>
|
355
|
-
<value>chapter</value>
|
356
|
-
<value>page</value>
|
357
|
-
<value>whole</value>
|
358
|
-
<value>table</value>
|
359
|
-
<value>annex</value>
|
360
|
-
<value>figure</value>
|
361
|
-
<value>note</value>
|
362
|
-
<value>example</value>
|
363
|
-
</choice>
|
351
|
+
<ref name="LocalityType"/>
|
364
352
|
</attribute>
|
365
353
|
<ref name="referenceFrom"/>
|
366
354
|
<optional>
|
@@ -368,6 +356,11 @@
|
|
368
356
|
</optional>
|
369
357
|
</element>
|
370
358
|
</define>
|
359
|
+
<define name="LocalityType">
|
360
|
+
<data type="string">
|
361
|
+
<param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|example|locality:[a-zA-Z0-9_]+</param>
|
362
|
+
</data>
|
363
|
+
</define>
|
371
364
|
<define name="referenceFrom">
|
372
365
|
<element name="referenceFrom">
|
373
366
|
<text/>
|
@@ -420,7 +413,7 @@
|
|
420
413
|
<ref name="formattedref"/>
|
421
414
|
</choice>
|
422
415
|
<zeroOrMore>
|
423
|
-
<ref name="
|
416
|
+
<ref name="bsource"/>
|
424
417
|
</zeroOrMore>
|
425
418
|
<zeroOrMore>
|
426
419
|
<ref name="docidentifier"/>
|
@@ -437,9 +430,6 @@
|
|
437
430
|
<zeroOrMore>
|
438
431
|
<ref name="biblionote"/>
|
439
432
|
</zeroOrMore>
|
440
|
-
<zeroOrMore>
|
441
|
-
<ref name="partof"/>
|
442
|
-
</zeroOrMore>
|
443
433
|
<zeroOrMore>
|
444
434
|
<ref name="language"/>
|
445
435
|
</zeroOrMore>
|
@@ -464,6 +454,11 @@
|
|
464
454
|
<ref name="FormattedString"/>
|
465
455
|
</element>
|
466
456
|
</define>
|
457
|
+
<define name="bsource">
|
458
|
+
<element name="source">
|
459
|
+
<ref name="TypedUri"/>
|
460
|
+
</element>
|
461
|
+
</define>
|
467
462
|
<define name="formattedref">
|
468
463
|
<element name="formattedref">
|
469
464
|
<ref name="FormattedString"/>
|
@@ -487,8 +482,11 @@
|
|
487
482
|
<value>published</value>
|
488
483
|
<value>accessed</value>
|
489
484
|
<value>created</value>
|
490
|
-
<value>
|
485
|
+
<value>implemented</value>
|
491
486
|
<value>obsoleted</value>
|
487
|
+
<value>confirmed</value>
|
488
|
+
<value>updated</value>
|
489
|
+
<value>issued</value>
|
492
490
|
</choice>
|
493
491
|
</attribute>
|
494
492
|
<ref name="bfrom"/>
|
@@ -531,11 +529,6 @@
|
|
531
529
|
<ref name="FormattedString"/>
|
532
530
|
</element>
|
533
531
|
</define>
|
534
|
-
<define name="partof">
|
535
|
-
<element name="partof">
|
536
|
-
<ref name="BibliographicItem"/>
|
537
|
-
</element>
|
538
|
-
</define>
|
539
532
|
<define name="copyright">
|
540
533
|
<element name="copyright">
|
541
534
|
<ref name="from"/>
|
@@ -560,6 +553,31 @@
|
|
560
553
|
<ref name="ContributorInfo"/>
|
561
554
|
</element>
|
562
555
|
</define>
|
556
|
+
<define name="docrelation">
|
557
|
+
<element name="relation">
|
558
|
+
<attribute name="type">
|
559
|
+
<choice>
|
560
|
+
<value>parent</value>
|
561
|
+
<value>child</value>
|
562
|
+
<value>obsoletes</value>
|
563
|
+
<value>updates</value>
|
564
|
+
<value>updatedBy</value>
|
565
|
+
<value>complements</value>
|
566
|
+
<value>derivedFrom</value>
|
567
|
+
<value>adoptedFrom</value>
|
568
|
+
<value>equivalent</value>
|
569
|
+
<value>identical</value>
|
570
|
+
<value>nonequivalent</value>
|
571
|
+
</choice>
|
572
|
+
</attribute>
|
573
|
+
<element name="bibitem">
|
574
|
+
<ref name="BibliographicItem"/>
|
575
|
+
</element>
|
576
|
+
<zeroOrMore>
|
577
|
+
<ref name="locality"/>
|
578
|
+
</zeroOrMore>
|
579
|
+
</element>
|
580
|
+
</define>
|
563
581
|
<!--
|
564
582
|
Anycontents = mixed {
|
565
583
|
https://github.com/relaxng/jing-trang/issues/211
|
@@ -35,11 +35,11 @@ module Asciidoctor
|
|
35
35
|
|
36
36
|
def sidebar_attrs(node)
|
37
37
|
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
38
|
-
date += "
|
38
|
+
date += "T00:00:00Z" unless /T/.match? date
|
39
39
|
{
|
40
40
|
reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
|
41
41
|
id: Utils::anchor_or_uuid(node),
|
42
|
-
date: date
|
42
|
+
date: date,
|
43
43
|
from: node.attr("from"),
|
44
44
|
to: node.attr("to") || node.attr("from"),
|
45
45
|
}
|
@@ -15,9 +15,9 @@ module Asciidoctor
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def cleanup(xmldoc)
|
18
|
+
termdef_cleanup(xmldoc)
|
18
19
|
sections_cleanup(xmldoc)
|
19
20
|
obligations_cleanup(xmldoc)
|
20
|
-
termdef_cleanup(xmldoc)
|
21
21
|
table_cleanup(xmldoc)
|
22
22
|
formula_cleanup(xmldoc)
|
23
23
|
figure_cleanup(xmldoc)
|
@@ -128,14 +128,14 @@ module Asciidoctor
|
|
128
128
|
xmldoc.xpath("//terms/p | //terms/ul").each(&:remove)
|
129
129
|
end
|
130
130
|
|
131
|
-
def
|
131
|
+
def termdef_subclause_cleanup(xmldoc)
|
132
132
|
xmldoc.xpath("//terms[terms]").each do |t|
|
133
133
|
t.name = "clause"
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
def termdocsource_cleanup(xmldoc)
|
138
|
-
f = xmldoc.at("//
|
138
|
+
f = xmldoc.at("//preface | //sections")
|
139
139
|
xmldoc.xpath("//terms/termdocsource").each do |s|
|
140
140
|
f.previous = s.remove
|
141
141
|
end
|
@@ -147,7 +147,7 @@ module Asciidoctor
|
|
147
147
|
termdomain_cleanup(xmldoc)
|
148
148
|
termdefinition_cleanup(xmldoc)
|
149
149
|
termdef_boilerplate_cleanup(xmldoc)
|
150
|
-
|
150
|
+
termdef_subclause_cleanup(xmldoc)
|
151
151
|
termdocsource_cleanup(xmldoc)
|
152
152
|
end
|
153
153
|
|
@@ -110,13 +110,27 @@ module Asciidoctor
|
|
110
110
|
subfigure_cleanup(xmldoc)
|
111
111
|
end
|
112
112
|
|
113
|
+
def make_preface(x, s)
|
114
|
+
if x.at("//foreword | //introduction")
|
115
|
+
preface = s.add_previous_sibling("<preface/>").first
|
116
|
+
foreword = x.at("//foreword")
|
117
|
+
preface.add_child foreword.remove if foreword
|
118
|
+
introduction = x.at("//introduction")
|
119
|
+
preface.add_child introduction.remove if introduction
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def make_bibliography(x, s)
|
124
|
+
if x.at("//sections/references")
|
125
|
+
biblio = s.add_next_sibling("<bibliography/>").first
|
126
|
+
x.xpath("//sections/references").each { |r| biblio.add_child r.remove }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
113
130
|
def sections_cleanup(x)
|
114
131
|
s = x.at("//sections")
|
115
|
-
|
116
|
-
s
|
117
|
-
introduction = x.at("//introduction")
|
118
|
-
s.previous = introduction.remove if introduction
|
119
|
-
x.xpath("//sections/references").reverse_each { |r| s.next = r.remove }
|
132
|
+
make_preface(x, s)
|
133
|
+
make_bibliography(x, s)
|
120
134
|
x.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
|
121
135
|
end
|
122
136
|
|
@@ -144,7 +158,7 @@ module Asciidoctor
|
|
144
158
|
x.xpath("//annex | //clause").each do |r|
|
145
159
|
r["obligation"] = "normative" unless r["obligation"]
|
146
160
|
end
|
147
|
-
x.xpath(
|
161
|
+
x.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
|
148
162
|
r["obligation"] = r.at("./ancestor::*/@obligation").text
|
149
163
|
end
|
150
164
|
end
|
@@ -5,9 +5,10 @@ module Asciidoctor
|
|
5
5
|
# extending localities to cover ISO referencing
|
6
6
|
LOCALITY_REGEX_STR = <<~REGEXP.freeze
|
7
7
|
^((?<locality>section|clause|part|paragraph|chapter|page|
|
8
|
-
table|annex|figure|example|note|formula
|
8
|
+
table|annex|figure|example|note|formula|
|
9
|
+
locality:[^ \\t\\n\\r:,]+)\\s+
|
9
10
|
(?<ref>[^ \\t\\n,:-]+)(-(?<to>[^ \\t\\n,:-]+))?|
|
10
|
-
(?<
|
11
|
+
(?<locality2>whole|locality:[^ \\t\\n\\r:,]+))[,:]?\\s*
|
11
12
|
(?<text>.*)$
|
12
13
|
REGEXP
|
13
14
|
LOCALITY_RE = Regexp.new(LOCALITY_REGEX_STR.gsub(/\s/, ""),
|
@@ -18,8 +19,8 @@ module Asciidoctor
|
|
18
19
|
while (m = LOCALITY_RE.match text)
|
19
20
|
ref = m[:ref] ? "<referenceFrom>#{m[:ref]}</referenceFrom>" : ""
|
20
21
|
refto = m[:to] ? "<referenceTo>#{m[:to]}</referenceTo>" : ""
|
21
|
-
|
22
|
-
|
22
|
+
loc = m[:locality]&.downcase || m[:locality2]&.downcase
|
23
|
+
x.add_child("<locality type='#{loc}'>#{ref}#{refto}</locality>")
|
23
24
|
text = m[:text]
|
24
25
|
end
|
25
26
|
x.add_child(text)
|