metanorma-standoc 1.10.8 → 1.11.0
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/Rakefile +1 -1
- data/lib/asciidoctor/standoc/base.rb +5 -4
- data/lib/asciidoctor/standoc/cleanup.rb +20 -11
- data/lib/asciidoctor/standoc/cleanup_inline.rb +20 -7
- data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
- data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
- data/lib/asciidoctor/standoc/cleanup_terms.rb +37 -77
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
- data/lib/asciidoctor/standoc/converter.rb +2 -0
- data/lib/asciidoctor/standoc/inline.rb +7 -5
- data/lib/asciidoctor/standoc/isodoc.rng +218 -27
- data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
- data/lib/asciidoctor/standoc/macros_terms.rb +49 -5
- data/lib/asciidoctor/standoc/ref_sect.rb +24 -17
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
- data/lib/asciidoctor/standoc/terms.rb +12 -2
- data/lib/asciidoctor/standoc/utils.rb +36 -23
- data/lib/asciidoctor/standoc/validate.rb +24 -15
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor/base_spec.rb +4 -3
- data/spec/asciidoctor/blocks_spec.rb +149 -21
- data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
- data/spec/asciidoctor/cleanup_spec.rb +21 -195
- data/spec/asciidoctor/cleanup_terms_spec.rb +990 -0
- data/spec/asciidoctor/inline_spec.rb +2 -2
- data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
- data/spec/asciidoctor/macros_spec.rb +189 -112
- data/spec/asciidoctor/refs_spec.rb +2 -24
- data/spec/asciidoctor/section_spec.rb +18 -18
- data/spec/asciidoctor/validate_spec.rb +59 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +46 -46
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +32 -32
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -65
- metadata +8 -5
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<grammar ns="https://www.metanorma.org/ns/standoc" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
20
|
+
<grammar ns="https://www.metanorma.org/ns/standoc" 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
|
<include href="reqt.rng"/>
|
22
22
|
<!-- include "biblio.rnc" { } -->
|
23
23
|
<include href="basicdoc.rng">
|
@@ -1803,17 +1803,20 @@
|
|
1803
1803
|
<ref name="admitted"/>
|
1804
1804
|
</zeroOrMore>
|
1805
1805
|
<zeroOrMore>
|
1806
|
-
<ref name="
|
1806
|
+
<ref name="deprecates"/>
|
1807
1807
|
</zeroOrMore>
|
1808
1808
|
<zeroOrMore>
|
1809
|
-
<ref name="
|
1809
|
+
<ref name="related"/>
|
1810
1810
|
</zeroOrMore>
|
1811
1811
|
<optional>
|
1812
1812
|
<ref name="termdomain"/>
|
1813
1813
|
</optional>
|
1814
|
-
<
|
1815
|
-
<ref name="
|
1816
|
-
</
|
1814
|
+
<optional>
|
1815
|
+
<ref name="termsubject"/>
|
1816
|
+
</optional>
|
1817
|
+
<optional>
|
1818
|
+
<ref name="termusage"/>
|
1819
|
+
</optional>
|
1817
1820
|
<oneOrMore>
|
1818
1821
|
<ref name="termdefinition"/>
|
1819
1822
|
</oneOrMore>
|
@@ -1830,41 +1833,200 @@
|
|
1830
1833
|
</define>
|
1831
1834
|
<define name="preferred">
|
1832
1835
|
<element name="preferred">
|
1833
|
-
<
|
1834
|
-
<ref name="TextElement"/>
|
1835
|
-
</oneOrMore>
|
1836
|
+
<ref name="Designation"/>
|
1836
1837
|
</element>
|
1837
1838
|
</define>
|
1838
1839
|
<define name="admitted">
|
1839
1840
|
<element name="admitted">
|
1840
|
-
<
|
1841
|
-
<ref name="TextElement"/>
|
1842
|
-
</oneOrMore>
|
1841
|
+
<ref name="Designation"/>
|
1843
1842
|
</element>
|
1844
1843
|
</define>
|
1845
1844
|
<define name="related">
|
1846
1845
|
<element name="related">
|
1846
|
+
<attribute name="type">
|
1847
|
+
<ref name="RelatedTermType"/>
|
1848
|
+
</attribute>
|
1849
|
+
<element name="preferred">
|
1850
|
+
<ref name="Designation"/>
|
1851
|
+
</element>
|
1852
|
+
<choice>
|
1853
|
+
<ref name="eref"/>
|
1854
|
+
<ref name="xref"/>
|
1855
|
+
<ref name="termref"/>
|
1856
|
+
</choice>
|
1857
|
+
</element>
|
1858
|
+
</define>
|
1859
|
+
<define name="RelatedTermType">
|
1860
|
+
<choice>
|
1861
|
+
<value>deprecates</value>
|
1862
|
+
<value>supersedes</value>
|
1863
|
+
<value>narrower</value>
|
1864
|
+
<value>broader</value>
|
1865
|
+
<value>equivalent</value>
|
1866
|
+
<value>compare</value>
|
1867
|
+
<value>contrast</value>
|
1868
|
+
<value>see</value>
|
1869
|
+
</choice>
|
1870
|
+
</define>
|
1871
|
+
<define name="deprecates">
|
1872
|
+
<element name="deprecates">
|
1873
|
+
<ref name="Designation"/>
|
1874
|
+
</element>
|
1875
|
+
</define>
|
1876
|
+
<define name="Designation">
|
1877
|
+
<optional>
|
1878
|
+
<attribute name="absent">
|
1879
|
+
<data type="boolean"/>
|
1880
|
+
</attribute>
|
1881
|
+
</optional>
|
1882
|
+
<optional>
|
1883
|
+
<attribute name="geographicArea"/>
|
1884
|
+
</optional>
|
1885
|
+
<choice>
|
1886
|
+
<ref name="expression_designation"/>
|
1887
|
+
<ref name="letter_symbol_designation"/>
|
1888
|
+
<ref name="graphical_symbol_designation"/>
|
1889
|
+
</choice>
|
1890
|
+
<zeroOrMore>
|
1891
|
+
<ref name="termsource"/>
|
1892
|
+
</zeroOrMore>
|
1893
|
+
</define>
|
1894
|
+
<define name="letter_symbol_designation">
|
1895
|
+
<element name="letter-symbol">
|
1847
1896
|
<optional>
|
1848
|
-
<attribute name="
|
1897
|
+
<attribute name="isInternational">
|
1898
|
+
<data type="boolean"/>
|
1899
|
+
</attribute>
|
1900
|
+
</optional>
|
1901
|
+
<element name="name">
|
1902
|
+
<oneOrMore>
|
1849
1903
|
<choice>
|
1850
|
-
<
|
1851
|
-
<
|
1852
|
-
<value>see</value>
|
1904
|
+
<ref name="PureTextElement"/>
|
1905
|
+
<ref name="stem"/>
|
1853
1906
|
</choice>
|
1907
|
+
</oneOrMore>
|
1908
|
+
</element>
|
1909
|
+
</element>
|
1910
|
+
</define>
|
1911
|
+
<define name="graphical_symbol_designation">
|
1912
|
+
<element name="graphical-symbol">
|
1913
|
+
<optional>
|
1914
|
+
<attribute name="isInternational">
|
1915
|
+
<data type="boolean"/>
|
1854
1916
|
</attribute>
|
1855
1917
|
</optional>
|
1856
|
-
<
|
1857
|
-
<ref name="TextElement"/>
|
1858
|
-
</oneOrMore>
|
1918
|
+
<ref name="figure"/>
|
1859
1919
|
</element>
|
1860
1920
|
</define>
|
1861
|
-
<define name="
|
1862
|
-
<element name="
|
1863
|
-
<
|
1864
|
-
<
|
1865
|
-
|
1921
|
+
<define name="expression_designation">
|
1922
|
+
<element name="expression">
|
1923
|
+
<optional>
|
1924
|
+
<attribute name="language">
|
1925
|
+
<a:documentation>ISO-639</a:documentation>
|
1926
|
+
</attribute>
|
1927
|
+
</optional>
|
1928
|
+
<optional>
|
1929
|
+
<attribute name="script">
|
1930
|
+
<a:documentation>ISO-15924</a:documentation>
|
1931
|
+
</attribute>
|
1932
|
+
</optional>
|
1933
|
+
<optional>
|
1934
|
+
<attribute name="type">
|
1935
|
+
<ref name="ExpressionDesignationType"/>
|
1936
|
+
</attribute>
|
1937
|
+
</optional>
|
1938
|
+
<optional>
|
1939
|
+
<attribute name="isInternational">
|
1940
|
+
<data type="boolean"/>
|
1941
|
+
</attribute>
|
1942
|
+
</optional>
|
1943
|
+
<element name="name">
|
1944
|
+
<zeroOrMore>
|
1945
|
+
<ref name="PureTextElement"/>
|
1946
|
+
</zeroOrMore>
|
1947
|
+
</element>
|
1948
|
+
<optional>
|
1949
|
+
<element name="abbreviationType">
|
1950
|
+
<ref name="AbbreviationType"/>
|
1951
|
+
</element>
|
1952
|
+
</optional>
|
1953
|
+
<optional>
|
1954
|
+
<element name="pronunciation">
|
1955
|
+
<ref name="LocalizedString"/>
|
1956
|
+
</element>
|
1957
|
+
</optional>
|
1958
|
+
<optional>
|
1959
|
+
<element name="grammarInfo">
|
1960
|
+
<ref name="Grammar"/>
|
1961
|
+
</element>
|
1962
|
+
</optional>
|
1866
1963
|
</element>
|
1867
1964
|
</define>
|
1965
|
+
<define name="ExpressionDesignationType">
|
1966
|
+
<choice>
|
1967
|
+
<value>prefix</value>
|
1968
|
+
<value>suffix</value>
|
1969
|
+
<value>abbreviation</value>
|
1970
|
+
<value>full</value>
|
1971
|
+
</choice>
|
1972
|
+
</define>
|
1973
|
+
<define name="AbbreviationType">
|
1974
|
+
<choice>
|
1975
|
+
<value>truncation</value>
|
1976
|
+
<value>acronym</value>
|
1977
|
+
<value>initialism</value>
|
1978
|
+
</choice>
|
1979
|
+
</define>
|
1980
|
+
<define name="Grammar">
|
1981
|
+
<zeroOrMore>
|
1982
|
+
<element name="gender">
|
1983
|
+
<ref name="GrammarGender"/>
|
1984
|
+
</element>
|
1985
|
+
</zeroOrMore>
|
1986
|
+
<optional>
|
1987
|
+
<element name="isPreposition">
|
1988
|
+
<data type="boolean"/>
|
1989
|
+
</element>
|
1990
|
+
</optional>
|
1991
|
+
<optional>
|
1992
|
+
<element name="isParticiple">
|
1993
|
+
<data type="boolean"/>
|
1994
|
+
</element>
|
1995
|
+
</optional>
|
1996
|
+
<optional>
|
1997
|
+
<element name="isAdjective">
|
1998
|
+
<data type="boolean"/>
|
1999
|
+
</element>
|
2000
|
+
</optional>
|
2001
|
+
<optional>
|
2002
|
+
<element name="isVerb">
|
2003
|
+
<data type="boolean"/>
|
2004
|
+
</element>
|
2005
|
+
</optional>
|
2006
|
+
<optional>
|
2007
|
+
<element name="isAdverb">
|
2008
|
+
<data type="boolean"/>
|
2009
|
+
</element>
|
2010
|
+
</optional>
|
2011
|
+
<optional>
|
2012
|
+
<element name="isNoun">
|
2013
|
+
<data type="boolean"/>
|
2014
|
+
</element>
|
2015
|
+
</optional>
|
2016
|
+
<zeroOrMore>
|
2017
|
+
<element name="grammarvalue">
|
2018
|
+
<text/>
|
2019
|
+
</element>
|
2020
|
+
</zeroOrMore>
|
2021
|
+
</define>
|
2022
|
+
<define name="GrammarGender">
|
2023
|
+
<choice>
|
2024
|
+
<value>masculine</value>
|
2025
|
+
<value>feminine</value>
|
2026
|
+
<value>neuter</value>
|
2027
|
+
<value>common</value>
|
2028
|
+
</choice>
|
2029
|
+
</define>
|
1868
2030
|
<define name="termdomain">
|
1869
2031
|
<element name="domain">
|
1870
2032
|
<oneOrMore>
|
@@ -1872,18 +2034,47 @@
|
|
1872
2034
|
</oneOrMore>
|
1873
2035
|
</element>
|
1874
2036
|
</define>
|
1875
|
-
<define name="
|
1876
|
-
<element name="
|
2037
|
+
<define name="termsubject">
|
2038
|
+
<element name="subject">
|
1877
2039
|
<oneOrMore>
|
1878
2040
|
<ref name="TextElement"/>
|
1879
2041
|
</oneOrMore>
|
1880
2042
|
</element>
|
1881
2043
|
</define>
|
2044
|
+
<define name="termusage">
|
2045
|
+
<element name="usageinfo">
|
2046
|
+
<oneOrMore>
|
2047
|
+
<ref name="BasicBlock"/>
|
2048
|
+
</oneOrMore>
|
2049
|
+
</element>
|
2050
|
+
</define>
|
1882
2051
|
<define name="termdefinition">
|
1883
2052
|
<element name="definition">
|
2053
|
+
<choice>
|
2054
|
+
<ref name="verbaldefinition"/>
|
2055
|
+
<ref name="nonverbalrep"/>
|
2056
|
+
<group>
|
2057
|
+
<ref name="verbaldefinition"/>
|
2058
|
+
<ref name="nonverbalrep"/>
|
2059
|
+
</group>
|
2060
|
+
</choice>
|
2061
|
+
</element>
|
2062
|
+
</define>
|
2063
|
+
<define name="verbaldefinition">
|
2064
|
+
<element name="verbaldefinition">
|
2065
|
+
<oneOrMore>
|
2066
|
+
<ref name="paragraph"/>
|
2067
|
+
</oneOrMore>
|
2068
|
+
<zeroOrMore>
|
2069
|
+
<ref name="termsource"/>
|
2070
|
+
</zeroOrMore>
|
2071
|
+
</element>
|
2072
|
+
</define>
|
2073
|
+
<define name="nonverbalrep">
|
2074
|
+
<element name="nonverbalrepresentation">
|
1884
2075
|
<oneOrMore>
|
1885
2076
|
<choice>
|
1886
|
-
<ref name="
|
2077
|
+
<ref name="table"/>
|
1887
2078
|
<ref name="figure"/>
|
1888
2079
|
<ref name="formula"/>
|
1889
2080
|
</choice>
|
@@ -28,32 +28,38 @@ module Asciidoctor
|
|
28
28
|
# sleep need for windows because dot works in separate process and
|
29
29
|
# plantuml process may finish earlier then dot, as result png file
|
30
30
|
# maybe not created yet after plantuml finish
|
31
|
+
#
|
32
|
+
# # Warning: metanorma/metanorma-standoc#187
|
33
|
+
# Windows Ruby 2.4 will crash if a Tempfile is "mv"ed.
|
34
|
+
# This is why we need to copy and then unlink.
|
31
35
|
def self.generate_file(parent, reader)
|
32
36
|
localdir = Metanorma::Utils::localdir(parent.document)
|
33
37
|
imagesdir = parent.document.attr("imagesdir")
|
34
38
|
umlfile, outfile = save_plantuml parent, reader, localdir
|
35
|
-
run(umlfile, outfile) or
|
39
|
+
run(umlfile, outfile) or
|
40
|
+
raise "No image output from PlantUML (#{umlfile}, #{outfile})!"
|
36
41
|
umlfile.unlink
|
37
42
|
|
38
|
-
path =
|
39
|
-
File.writable?(localdir) or raise "Destination path #{path} not writable for PlantUML!"
|
40
|
-
path.mkpath
|
41
|
-
File.writable?(path) or raise "Destination path #{path} not writable for PlantUML!"
|
42
|
-
# File.exist?(path) or raise "Destination path #{path} already exists for PlantUML!"
|
43
|
-
|
44
|
-
# Warning: metanorma/metanorma-standoc#187
|
45
|
-
# Windows Ruby 2.4 will crash if a Tempfile is "mv"ed.
|
46
|
-
# This is why we need to copy and then unlink.
|
43
|
+
path = path_prep(localdir, imagesdir)
|
47
44
|
filename = File.basename(outfile.to_s)
|
48
|
-
FileUtils.cp(outfile, path)
|
45
|
+
FileUtils.cp(outfile, path) and outfile.unlink
|
49
46
|
|
50
47
|
imagesdir ? filename : File.join(path, filename)
|
51
48
|
end
|
52
49
|
|
50
|
+
def self.path_prep(localdir, imagesdir)
|
51
|
+
path = Pathname.new(localdir) + (imagesdir || "plantuml")
|
52
|
+
File.writable?(localdir) or
|
53
|
+
raise "Destination path #{path} not writable for PlantUML!"
|
54
|
+
path.mkpath
|
55
|
+
File.writable?(path) or
|
56
|
+
raise "Destination path #{path} not writable for PlantUML!"
|
57
|
+
# File.exist?(path) or raise "Destination path #{path} already exists for PlantUML!"
|
58
|
+
path
|
59
|
+
end
|
60
|
+
|
53
61
|
def self.save_plantuml(_parent, reader, _localdir)
|
54
|
-
src = reader
|
55
|
-
reader.lines.first.sub(/\s+$/, "").match /^@startuml($| )/ or
|
56
|
-
src = "@startuml\n#{src}\n@enduml\n"
|
62
|
+
src = prep_source(reader)
|
57
63
|
/^@startuml (?<fn>[^\n]+)\n/ =~ src
|
58
64
|
Tempfile.open(["plantuml", ".pml"], encoding: "utf-8") do |f|
|
59
65
|
f.write(src)
|
@@ -62,6 +68,15 @@ module Asciidoctor
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
71
|
+
def self.prep_source(reader)
|
72
|
+
src = reader.source
|
73
|
+
reader.lines.first.sub(/\s+$/, "").match /^@startuml($| )/ or
|
74
|
+
src = "@startuml\n#{src}\n@enduml\n"
|
75
|
+
%r{@enduml\s*$}m.match?(src) or
|
76
|
+
raise "@startuml without matching @enduml in PlantUML!"
|
77
|
+
src
|
78
|
+
end
|
79
|
+
|
65
80
|
def self.generate_attrs(attrs)
|
66
81
|
%w(id align float title role width height alt)
|
67
82
|
.inject({}) do |memo, key|
|
@@ -2,6 +2,18 @@ require "csv"
|
|
2
2
|
|
3
3
|
module Asciidoctor
|
4
4
|
module Standoc
|
5
|
+
class PreferredTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
6
|
+
use_dsl
|
7
|
+
named :preferred
|
8
|
+
parse_content_as :text
|
9
|
+
using_format :short
|
10
|
+
|
11
|
+
def process(parent, _target, attrs)
|
12
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
13
|
+
%{<preferred><expression><name>#{out}</name></expression></preferred>}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
5
17
|
class AltTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
6
18
|
use_dsl
|
7
19
|
named :alt
|
@@ -9,8 +21,9 @@ module Asciidoctor
|
|
9
21
|
using_format :short
|
10
22
|
|
11
23
|
def process(parent, _target, attrs)
|
12
|
-
out = Asciidoctor::Inline.new(parent, :quoted,
|
13
|
-
|
24
|
+
out = Asciidoctor::Inline.new(parent, :quoted,
|
25
|
+
attrs["text"]).convert
|
26
|
+
%{<admitted><expression><name>#{out}</name></expression></admitted>}
|
14
27
|
end
|
15
28
|
end
|
16
29
|
|
@@ -21,8 +34,9 @@ module Asciidoctor
|
|
21
34
|
using_format :short
|
22
35
|
|
23
36
|
def process(parent, _target, attrs)
|
24
|
-
out = Asciidoctor::Inline.new(parent, :quoted,
|
25
|
-
|
37
|
+
out = Asciidoctor::Inline.new(parent, :quoted,
|
38
|
+
attrs["text"]).convert
|
39
|
+
%{<deprecates><expression><name>#{out}</name></expression></deprecates>}
|
26
40
|
end
|
27
41
|
end
|
28
42
|
|
@@ -33,7 +47,8 @@ module Asciidoctor
|
|
33
47
|
using_format :short
|
34
48
|
|
35
49
|
def process(parent, _target, attrs)
|
36
|
-
out = Asciidoctor::Inline.new(parent, :quoted,
|
50
|
+
out = Asciidoctor::Inline.new(parent, :quoted,
|
51
|
+
attrs["text"]).convert
|
37
52
|
%{<domain>#{out}</domain>}
|
38
53
|
end
|
39
54
|
end
|
@@ -133,5 +148,34 @@ module Asciidoctor
|
|
133
148
|
raise("processing {{#{target}}}: #{e.message}")
|
134
149
|
end
|
135
150
|
end
|
151
|
+
|
152
|
+
# Possibilities:
|
153
|
+
# related:relation[<<id>>, term]
|
154
|
+
# related:relation[<<termbase:id>>, term]
|
155
|
+
# related:relation[term] equivalent to a crossreference to term:[term]
|
156
|
+
class RelatedTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
157
|
+
use_dsl
|
158
|
+
named :related
|
159
|
+
parse_content_as :text
|
160
|
+
|
161
|
+
def preprocess_attrs(target)
|
162
|
+
m = /^(?<id><<.+?>>, ?)?(?<rest>.*)$/.match(target)
|
163
|
+
{ id: m[:id]&.sub(/^<</, "")&.sub(/>>, ?$/, ""),
|
164
|
+
term: m[:rest] }
|
165
|
+
end
|
166
|
+
|
167
|
+
def process(parent, target, attrs)
|
168
|
+
out = preprocess_attrs(attrs["text"])
|
169
|
+
term = Asciidoctor::Inline.new(parent, :quoted,
|
170
|
+
out[:term]).convert
|
171
|
+
if out[:id] then "<related type='#{target}' key='#{out[:id]}'>"\
|
172
|
+
"<refterm>#{term}</refterm></related>"
|
173
|
+
else "<related type='#{target}'><termxref>#{term}</termxref>"\
|
174
|
+
"<xrefrender>#{term}</xrefrender></related>"
|
175
|
+
end
|
176
|
+
rescue StandardError => e
|
177
|
+
raise("processing related:#{target}[#{attrs['text']}]: #{e.message}")
|
178
|
+
end
|
179
|
+
end
|
136
180
|
end
|
137
181
|
end
|
@@ -16,16 +16,14 @@ module Asciidoctor
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def bibliography_parse(attrs, xml, node)
|
19
|
-
|
20
|
-
node.attr("style") == "bibliography" or
|
21
|
-
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
19
|
+
x = biblio_prep(attrs, xml, node) and return x
|
22
20
|
@biblio = true
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
attrs = attrs.merge(normative: node.attr("normative") || false)
|
22
|
+
xml.references **attr_code(attrs) do |xml_section|
|
23
|
+
xml_section.title { |t| t << node.title }
|
24
|
+
xml_section << node.content
|
25
|
+
end
|
26
|
+
@biblio = false
|
29
27
|
end
|
30
28
|
|
31
29
|
def bibitem_parse(attrs, xml, node)
|
@@ -39,9 +37,7 @@ module Asciidoctor
|
|
39
37
|
end
|
40
38
|
|
41
39
|
def norm_ref_parse(attrs, xml, node)
|
42
|
-
|
43
|
-
node.attr("style") == "bibliography" or
|
44
|
-
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
40
|
+
x = biblio_prep(attrs, xml, node) and return x
|
45
41
|
@norm_ref = true
|
46
42
|
attrs = attrs.merge(normative: node.attr("normative") || true)
|
47
43
|
xml.references **attr_code(attrs) do |xml_section|
|
@@ -51,6 +47,17 @@ module Asciidoctor
|
|
51
47
|
@norm_ref = false
|
52
48
|
end
|
53
49
|
|
50
|
+
def biblio_prep(attrs, xml, node)
|
51
|
+
if node.option? "bibitem"
|
52
|
+
bibitem_parse(attrs, xml, node)
|
53
|
+
else
|
54
|
+
node.attr("style") == "bibliography" or
|
55
|
+
@log.add("AsciiDoc Input", node,
|
56
|
+
"Section not marked up as [bibliography]!")
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
54
61
|
def global_ievcache_name
|
55
62
|
"#{Dir.home}/.iev/cache"
|
56
63
|
end
|
@@ -74,7 +81,7 @@ module Asciidoctor
|
|
74
81
|
xml
|
75
82
|
rescue RelatonBib::RequestError
|
76
83
|
@log.add("Bibliography", nil, "Could not retrieve #{code}: "\
|
77
|
-
|
84
|
+
"no access to online site")
|
78
85
|
nil
|
79
86
|
end
|
80
87
|
|
@@ -87,10 +94,10 @@ module Asciidoctor
|
|
87
94
|
unless xml.at("/bibitem/title[text()]")
|
88
95
|
@log.add("Bibliography", nil,
|
89
96
|
"ERROR: No title retrieved for #{code}")
|
90
|
-
xml.root << "<title>#{title ||
|
97
|
+
xml.root << "<title>#{title || '(MISSING TITLE)'}</title>"
|
91
98
|
end
|
92
99
|
usrlbl and xml.at("/bibitem/docidentifier").next =
|
93
|
-
|
100
|
+
"<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
|
94
101
|
end
|
95
102
|
|
96
103
|
def smart_render_xml(xml, code, opts)
|
@@ -113,7 +120,7 @@ module Asciidoctor
|
|
113
120
|
@bibdb = Relaton::DbCache.init_bib_caches(
|
114
121
|
local_cache: local,
|
115
122
|
flush_caches: node.attr("flush-caches"),
|
116
|
-
global_cache: global
|
123
|
+
global_cache: global,
|
117
124
|
)
|
118
125
|
end
|
119
126
|
|
@@ -128,7 +135,7 @@ module Asciidoctor
|
|
128
135
|
FileUtils.rm_f @iev_localname unless @iev_localname.nil?
|
129
136
|
end
|
130
137
|
end
|
131
|
-
|
138
|
+
# @iev = Iev::Db.new(globalname, localname) unless @no_isobib
|
132
139
|
end
|
133
140
|
end
|
134
141
|
end
|