metanorma-standoc 1.10.8 → 1.11.2
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/blocks.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup.rb +20 -11
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -20
- data/lib/asciidoctor/standoc/cleanup_inline.rb +20 -7
- data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +25 -15
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +2 -2
- data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
- data/lib/asciidoctor/standoc/cleanup_terms.rb +54 -79
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +179 -0
- data/lib/asciidoctor/standoc/cleanup_text.rb +23 -0
- data/lib/asciidoctor/standoc/converter.rb +2 -0
- data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +6 -6
- data/lib/asciidoctor/standoc/inline.rb +20 -16
- data/lib/asciidoctor/standoc/isodoc.rng +254 -27
- data/lib/asciidoctor/standoc/lists.rb +1 -3
- data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
- data/lib/asciidoctor/standoc/macros_terms.rb +49 -5
- data/lib/asciidoctor/standoc/ref.rb +101 -75
- data/lib/asciidoctor/standoc/ref_date_id.rb +30 -1
- data/lib/asciidoctor/standoc/ref_sect.rb +42 -24
- data/lib/asciidoctor/standoc/reqt.rb +1 -1
- data/lib/asciidoctor/standoc/section.rb +14 -13
- 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 +25 -16
- data/lib/isodoc/html/htmlstyle.css +1 -1
- data/lib/isodoc/html/htmlstyle.scss +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -3
- data/spec/asciidoctor/base_spec.rb +4 -3
- data/spec/asciidoctor/blocks_spec.rb +202 -21
- data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
- data/spec/asciidoctor/cleanup_spec.rb +23 -197
- data/spec/asciidoctor/cleanup_terms_spec.rb +1205 -0
- data/spec/asciidoctor/datamodel/attributes_table_preprocessor_spec.rb +21 -21
- data/spec/asciidoctor/datamodel/diagram_preprocessor_spec.rb +16 -16
- data/spec/asciidoctor/inline_spec.rb +7 -7
- data/spec/asciidoctor/isobib_cache_spec.rb +4 -8
- data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
- data/spec/asciidoctor/macros_spec.rb +189 -112
- data/spec/asciidoctor/refs_dl_spec.rb +4 -4
- data/spec/asciidoctor/refs_spec.rb +860 -522
- data/spec/asciidoctor/section_spec.rb +18 -18
- data/spec/asciidoctor/validate_spec.rb +59 -2
- data/spec/spec_helper.rb +3 -2
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +180 -180
- 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 +27 -27
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
- 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 +11 -8
@@ -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">
|
@@ -58,7 +58,7 @@
|
|
58
58
|
<attribute name="alt"/>
|
59
59
|
</optional>
|
60
60
|
<optional>
|
61
|
-
<attribute name="
|
61
|
+
<attribute name="update-type">
|
62
62
|
<data type="boolean"/>
|
63
63
|
</attribute>
|
64
64
|
</optional>
|
@@ -1803,17 +1803,17 @@
|
|
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
1817
|
<oneOrMore>
|
1818
1818
|
<ref name="termdefinition"/>
|
1819
1819
|
</oneOrMore>
|
@@ -1830,41 +1830,232 @@
|
|
1830
1830
|
</define>
|
1831
1831
|
<define name="preferred">
|
1832
1832
|
<element name="preferred">
|
1833
|
-
<
|
1834
|
-
<ref name="TextElement"/>
|
1835
|
-
</oneOrMore>
|
1833
|
+
<ref name="Designation"/>
|
1836
1834
|
</element>
|
1837
1835
|
</define>
|
1838
1836
|
<define name="admitted">
|
1839
1837
|
<element name="admitted">
|
1840
|
-
<
|
1841
|
-
<ref name="TextElement"/>
|
1842
|
-
</oneOrMore>
|
1838
|
+
<ref name="Designation"/>
|
1843
1839
|
</element>
|
1844
1840
|
</define>
|
1845
1841
|
<define name="related">
|
1846
1842
|
<element name="related">
|
1843
|
+
<attribute name="type">
|
1844
|
+
<ref name="RelatedTermType"/>
|
1845
|
+
</attribute>
|
1846
|
+
<element name="preferred">
|
1847
|
+
<ref name="Designation"/>
|
1848
|
+
</element>
|
1849
|
+
<choice>
|
1850
|
+
<ref name="eref"/>
|
1851
|
+
<ref name="xref"/>
|
1852
|
+
<ref name="termref"/>
|
1853
|
+
</choice>
|
1854
|
+
</element>
|
1855
|
+
</define>
|
1856
|
+
<define name="RelatedTermType">
|
1857
|
+
<choice>
|
1858
|
+
<value>deprecates</value>
|
1859
|
+
<value>supersedes</value>
|
1860
|
+
<value>narrower</value>
|
1861
|
+
<value>broader</value>
|
1862
|
+
<value>equivalent</value>
|
1863
|
+
<value>compare</value>
|
1864
|
+
<value>contrast</value>
|
1865
|
+
<value>see</value>
|
1866
|
+
</choice>
|
1867
|
+
</define>
|
1868
|
+
<define name="deprecates">
|
1869
|
+
<element name="deprecates">
|
1870
|
+
<ref name="Designation"/>
|
1871
|
+
</element>
|
1872
|
+
</define>
|
1873
|
+
<define name="Designation">
|
1874
|
+
<optional>
|
1875
|
+
<attribute name="absent">
|
1876
|
+
<data type="boolean"/>
|
1877
|
+
</attribute>
|
1878
|
+
</optional>
|
1879
|
+
<optional>
|
1880
|
+
<attribute name="geographic-area"/>
|
1881
|
+
</optional>
|
1882
|
+
<choice>
|
1883
|
+
<ref name="expression_designation"/>
|
1884
|
+
<ref name="letter_symbol_designation"/>
|
1885
|
+
<ref name="graphical_symbol_designation"/>
|
1886
|
+
</choice>
|
1887
|
+
<optional>
|
1888
|
+
<ref name="fieldofapplication"/>
|
1889
|
+
</optional>
|
1890
|
+
<optional>
|
1891
|
+
<ref name="usageinfo"/>
|
1892
|
+
</optional>
|
1893
|
+
<zeroOrMore>
|
1894
|
+
<ref name="termsource"/>
|
1895
|
+
</zeroOrMore>
|
1896
|
+
</define>
|
1897
|
+
<define name="fieldofapplication">
|
1898
|
+
<element name="field-of-application">
|
1899
|
+
<oneOrMore>
|
1900
|
+
<ref name="PureTextElement"/>
|
1901
|
+
</oneOrMore>
|
1902
|
+
</element>
|
1903
|
+
</define>
|
1904
|
+
<define name="usageinfo">
|
1905
|
+
<element name="usage-info">
|
1906
|
+
<oneOrMore>
|
1907
|
+
<ref name="PureTextElement"/>
|
1908
|
+
</oneOrMore>
|
1909
|
+
</element>
|
1910
|
+
</define>
|
1911
|
+
<define name="letter_symbol_designation">
|
1912
|
+
<element name="letter-symbol">
|
1847
1913
|
<optional>
|
1848
|
-
<attribute name="
|
1914
|
+
<attribute name="isInternational">
|
1915
|
+
<data type="boolean"/>
|
1916
|
+
</attribute>
|
1917
|
+
</optional>
|
1918
|
+
<element name="name">
|
1919
|
+
<oneOrMore>
|
1849
1920
|
<choice>
|
1850
|
-
<
|
1851
|
-
<
|
1852
|
-
<value>see</value>
|
1921
|
+
<ref name="PureTextElement"/>
|
1922
|
+
<ref name="stem"/>
|
1853
1923
|
</choice>
|
1924
|
+
</oneOrMore>
|
1925
|
+
</element>
|
1926
|
+
</element>
|
1927
|
+
</define>
|
1928
|
+
<define name="graphical_symbol_designation">
|
1929
|
+
<element name="graphical-symbol">
|
1930
|
+
<optional>
|
1931
|
+
<attribute name="isInternational">
|
1932
|
+
<data type="boolean"/>
|
1854
1933
|
</attribute>
|
1855
1934
|
</optional>
|
1856
|
-
<
|
1857
|
-
<ref name="TextElement"/>
|
1858
|
-
</oneOrMore>
|
1935
|
+
<ref name="figure"/>
|
1859
1936
|
</element>
|
1860
1937
|
</define>
|
1861
|
-
<define name="
|
1862
|
-
<element name="
|
1863
|
-
<
|
1864
|
-
<
|
1865
|
-
|
1938
|
+
<define name="expression_designation">
|
1939
|
+
<element name="expression">
|
1940
|
+
<optional>
|
1941
|
+
<attribute name="language">
|
1942
|
+
<a:documentation>ISO-639</a:documentation>
|
1943
|
+
</attribute>
|
1944
|
+
</optional>
|
1945
|
+
<optional>
|
1946
|
+
<attribute name="script">
|
1947
|
+
<a:documentation>ISO-15924</a:documentation>
|
1948
|
+
</attribute>
|
1949
|
+
</optional>
|
1950
|
+
<optional>
|
1951
|
+
<attribute name="type">
|
1952
|
+
<ref name="ExpressionDesignationType"/>
|
1953
|
+
</attribute>
|
1954
|
+
</optional>
|
1955
|
+
<optional>
|
1956
|
+
<attribute name="isInternational">
|
1957
|
+
<data type="boolean"/>
|
1958
|
+
</attribute>
|
1959
|
+
</optional>
|
1960
|
+
<element name="name">
|
1961
|
+
<zeroOrMore>
|
1962
|
+
<ref name="PureTextElement"/>
|
1963
|
+
</zeroOrMore>
|
1964
|
+
</element>
|
1965
|
+
<optional>
|
1966
|
+
<element name="abbreviation-type">
|
1967
|
+
<ref name="AbbreviationType"/>
|
1968
|
+
</element>
|
1969
|
+
</optional>
|
1970
|
+
<optional>
|
1971
|
+
<element name="pronunciation">
|
1972
|
+
<ref name="LocalizedString"/>
|
1973
|
+
</element>
|
1974
|
+
</optional>
|
1975
|
+
<optional>
|
1976
|
+
<element name="grammar-info">
|
1977
|
+
<ref name="Grammar"/>
|
1978
|
+
</element>
|
1979
|
+
</optional>
|
1866
1980
|
</element>
|
1867
1981
|
</define>
|
1982
|
+
<define name="ExpressionDesignationType">
|
1983
|
+
<choice>
|
1984
|
+
<value>prefix</value>
|
1985
|
+
<value>suffix</value>
|
1986
|
+
<value>abbreviation</value>
|
1987
|
+
<value>full</value>
|
1988
|
+
</choice>
|
1989
|
+
</define>
|
1990
|
+
<define name="AbbreviationType">
|
1991
|
+
<choice>
|
1992
|
+
<value>truncation</value>
|
1993
|
+
<value>acronym</value>
|
1994
|
+
<value>initialism</value>
|
1995
|
+
</choice>
|
1996
|
+
</define>
|
1997
|
+
<define name="Grammar">
|
1998
|
+
<zeroOrMore>
|
1999
|
+
<element name="gender">
|
2000
|
+
<ref name="GrammarGender"/>
|
2001
|
+
</element>
|
2002
|
+
</zeroOrMore>
|
2003
|
+
<zeroOrMore>
|
2004
|
+
<element name="number">
|
2005
|
+
<ref name="GrammarNumber"/>
|
2006
|
+
</element>
|
2007
|
+
</zeroOrMore>
|
2008
|
+
<optional>
|
2009
|
+
<element name="isPreposition">
|
2010
|
+
<data type="boolean"/>
|
2011
|
+
</element>
|
2012
|
+
</optional>
|
2013
|
+
<optional>
|
2014
|
+
<element name="isParticiple">
|
2015
|
+
<data type="boolean"/>
|
2016
|
+
</element>
|
2017
|
+
</optional>
|
2018
|
+
<optional>
|
2019
|
+
<element name="isAdjective">
|
2020
|
+
<data type="boolean"/>
|
2021
|
+
</element>
|
2022
|
+
</optional>
|
2023
|
+
<optional>
|
2024
|
+
<element name="isVerb">
|
2025
|
+
<data type="boolean"/>
|
2026
|
+
</element>
|
2027
|
+
</optional>
|
2028
|
+
<optional>
|
2029
|
+
<element name="isAdverb">
|
2030
|
+
<data type="boolean"/>
|
2031
|
+
</element>
|
2032
|
+
</optional>
|
2033
|
+
<optional>
|
2034
|
+
<element name="isNoun">
|
2035
|
+
<data type="boolean"/>
|
2036
|
+
</element>
|
2037
|
+
</optional>
|
2038
|
+
<zeroOrMore>
|
2039
|
+
<element name="grammar-value">
|
2040
|
+
<text/>
|
2041
|
+
</element>
|
2042
|
+
</zeroOrMore>
|
2043
|
+
</define>
|
2044
|
+
<define name="GrammarGender">
|
2045
|
+
<choice>
|
2046
|
+
<value>masculine</value>
|
2047
|
+
<value>feminine</value>
|
2048
|
+
<value>neuter</value>
|
2049
|
+
<value>common</value>
|
2050
|
+
</choice>
|
2051
|
+
</define>
|
2052
|
+
<define name="GrammarNumber">
|
2053
|
+
<choice>
|
2054
|
+
<value>singular</value>
|
2055
|
+
<value>dual</value>
|
2056
|
+
<value>plural</value>
|
2057
|
+
</choice>
|
2058
|
+
</define>
|
1868
2059
|
<define name="termdomain">
|
1869
2060
|
<element name="domain">
|
1870
2061
|
<oneOrMore>
|
@@ -1872,8 +2063,8 @@
|
|
1872
2063
|
</oneOrMore>
|
1873
2064
|
</element>
|
1874
2065
|
</define>
|
1875
|
-
<define name="
|
1876
|
-
<element name="
|
2066
|
+
<define name="termsubject">
|
2067
|
+
<element name="subject">
|
1877
2068
|
<oneOrMore>
|
1878
2069
|
<ref name="TextElement"/>
|
1879
2070
|
</oneOrMore>
|
@@ -1881,9 +2072,39 @@
|
|
1881
2072
|
</define>
|
1882
2073
|
<define name="termdefinition">
|
1883
2074
|
<element name="definition">
|
2075
|
+
<choice>
|
2076
|
+
<ref name="verbaldefinition"/>
|
2077
|
+
<ref name="nonverbalrep"/>
|
2078
|
+
<group>
|
2079
|
+
<ref name="verbaldefinition"/>
|
2080
|
+
<ref name="nonverbalrep"/>
|
2081
|
+
</group>
|
2082
|
+
</choice>
|
2083
|
+
</element>
|
2084
|
+
</define>
|
2085
|
+
<define name="verbaldefinition">
|
2086
|
+
<element name="verbal-definition">
|
1884
2087
|
<oneOrMore>
|
1885
2088
|
<choice>
|
1886
2089
|
<ref name="paragraph"/>
|
2090
|
+
<ref name="dl"/>
|
2091
|
+
<ref name="ol"/>
|
2092
|
+
<ref name="ul"/>
|
2093
|
+
<ref name="table"/>
|
2094
|
+
<ref name="figure"/>
|
2095
|
+
<ref name="formula"/>
|
2096
|
+
</choice>
|
2097
|
+
</oneOrMore>
|
2098
|
+
<zeroOrMore>
|
2099
|
+
<ref name="termsource"/>
|
2100
|
+
</zeroOrMore>
|
2101
|
+
</element>
|
2102
|
+
</define>
|
2103
|
+
<define name="nonverbalrep">
|
2104
|
+
<element name="non-verbal-representation">
|
2105
|
+
<oneOrMore>
|
2106
|
+
<choice>
|
2107
|
+
<ref name="table"/>
|
1887
2108
|
<ref name="figure"/>
|
1888
2109
|
<ref name="formula"/>
|
1889
2110
|
</choice>
|
@@ -1972,6 +2193,12 @@
|
|
1972
2193
|
<value>modified</value>
|
1973
2194
|
</choice>
|
1974
2195
|
</attribute>
|
2196
|
+
<attribute name="type">
|
2197
|
+
<choice>
|
2198
|
+
<value>authoritative</value>
|
2199
|
+
<value>lineage</value>
|
2200
|
+
</choice>
|
2201
|
+
</attribute>
|
1975
2202
|
<ref name="origin"/>
|
1976
2203
|
<optional>
|
1977
2204
|
<ref name="modification"/>
|
@@ -14,11 +14,9 @@ module Asciidoctor
|
|
14
14
|
|
15
15
|
def ul_li(xml_ul, item)
|
16
16
|
xml_ul.li **ul_li_attrs(item) do |xml_li|
|
17
|
+
xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
|
17
18
|
if item.blocks?
|
18
|
-
xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
|
19
19
|
xml_li << item.content
|
20
|
-
else
|
21
|
-
xml_li.p(**attr_code(id_attr(item))) { |p| p << item.text }
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -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
|