metanorma-standoc 1.11.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -31
- data/.gitignore +23 -0
- data/Gemfile +2 -0
- data/lib/asciidoctor/standoc/base.rb +2 -241
- data/lib/asciidoctor/standoc/blocks.rb +2 -238
- data/lib/asciidoctor/standoc/blocks_notes.rb +2 -100
- data/lib/asciidoctor/standoc/cleanup.rb +2 -207
- data/lib/asciidoctor/standoc/cleanup_amend.rb +2 -53
- data/lib/asciidoctor/standoc/cleanup_block.rb +2 -173
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -204
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +2 -108
- data/lib/asciidoctor/standoc/cleanup_image.rb +2 -69
- data/lib/asciidoctor/standoc/cleanup_inline.rb +2 -179
- data/lib/asciidoctor/standoc/cleanup_maths.rb +2 -221
- data/lib/asciidoctor/standoc/cleanup_ref.rb +2 -169
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +2 -93
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -110
- data/lib/asciidoctor/standoc/cleanup_section.rb +2 -184
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +2 -91
- data/lib/asciidoctor/standoc/cleanup_symbols.rb +2 -47
- data/lib/asciidoctor/standoc/cleanup_table.rb +2 -67
- data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -113
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +2 -161
- data/lib/asciidoctor/standoc/cleanup_text.rb +2 -95
- data/lib/asciidoctor/standoc/cleanup_toc.rb +3 -0
- data/lib/asciidoctor/standoc/cleanup_xref.rb +2 -106
- data/lib/asciidoctor/standoc/converter.rb +2 -123
- data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +2 -56
- data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +2 -102
- data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +3 -404
- data/lib/asciidoctor/standoc/deprecated.rb +5 -0
- data/lib/asciidoctor/standoc/front.rb +2 -219
- data/lib/asciidoctor/standoc/front_contributor.rb +2 -191
- data/lib/asciidoctor/standoc/inline.rb +2 -229
- data/lib/asciidoctor/standoc/lists.rb +2 -119
- data/lib/asciidoctor/standoc/macros.rb +2 -203
- data/lib/asciidoctor/standoc/macros_form.rb +2 -62
- data/lib/asciidoctor/standoc/macros_note.rb +2 -44
- data/lib/asciidoctor/standoc/macros_plantuml.rb +2 -112
- data/lib/asciidoctor/standoc/macros_terms.rb +2 -180
- data/lib/asciidoctor/standoc/ref.rb +2 -225
- data/lib/asciidoctor/standoc/ref_sect.rb +2 -143
- data/lib/asciidoctor/standoc/ref_utility.rb +2 -0
- data/lib/asciidoctor/standoc/render.rb +3 -0
- data/lib/asciidoctor/standoc/reqt.rb +2 -89
- data/lib/asciidoctor/standoc/section.rb +2 -190
- data/lib/asciidoctor/standoc/table.rb +2 -84
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +2 -178
- data/lib/asciidoctor/standoc/terms.rb +2 -153
- data/lib/asciidoctor/standoc/utils.rb +2 -116
- data/lib/asciidoctor/standoc/validate.rb +2 -157
- data/lib/asciidoctor/standoc/validate_section.rb +2 -54
- data/lib/isodoc/html/htmlstyle.css +20 -11
- data/lib/isodoc/html/htmlstyle.scss +11 -11
- data/lib/metanorma/standoc/base.rb +149 -0
- data/lib/{asciidoctor → metanorma}/standoc/basicdoc.rng +0 -0
- data/lib/{asciidoctor → metanorma}/standoc/biblio.rng +0 -0
- data/lib/metanorma/standoc/blocks.rb +239 -0
- data/lib/metanorma/standoc/blocks_notes.rb +101 -0
- data/lib/metanorma/standoc/cleanup.rb +146 -0
- data/lib/metanorma/standoc/cleanup_amend.rb +54 -0
- data/lib/metanorma/standoc/cleanup_block.rb +173 -0
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +213 -0
- data/lib/metanorma/standoc/cleanup_footnotes.rb +109 -0
- data/lib/metanorma/standoc/cleanup_image.rb +70 -0
- data/lib/metanorma/standoc/cleanup_inline.rb +190 -0
- data/lib/metanorma/standoc/cleanup_maths.rb +222 -0
- data/lib/metanorma/standoc/cleanup_ref.rb +170 -0
- data/lib/metanorma/standoc/cleanup_ref_dl.rb +104 -0
- data/lib/metanorma/standoc/cleanup_reqt.rb +111 -0
- data/lib/metanorma/standoc/cleanup_section.rb +212 -0
- data/lib/metanorma/standoc/cleanup_section_names.rb +92 -0
- data/lib/metanorma/standoc/cleanup_symbols.rb +48 -0
- data/lib/metanorma/standoc/cleanup_table.rb +68 -0
- data/lib/metanorma/standoc/cleanup_terms.rb +140 -0
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +199 -0
- data/lib/metanorma/standoc/cleanup_text.rb +96 -0
- data/lib/metanorma/standoc/cleanup_toc.rb +98 -0
- data/lib/metanorma/standoc/cleanup_xref.rb +107 -0
- data/lib/metanorma/standoc/converter.rb +124 -0
- data/lib/metanorma/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
- data/lib/metanorma/standoc/datamodel/diagram_preprocessor.rb +103 -0
- data/lib/metanorma/standoc/datamodel/plantuml_renderer.rb +409 -0
- data/lib/metanorma/standoc/front.rb +224 -0
- data/lib/metanorma/standoc/front_contributor.rb +192 -0
- data/lib/metanorma/standoc/inline.rb +232 -0
- data/lib/{asciidoctor → metanorma}/standoc/isodoc.rng +90 -18
- data/lib/metanorma/standoc/lists.rb +120 -0
- data/lib/metanorma/standoc/macros.rb +204 -0
- data/lib/metanorma/standoc/macros_form.rb +63 -0
- data/lib/metanorma/standoc/macros_note.rb +45 -0
- data/lib/metanorma/standoc/macros_plantuml.rb +113 -0
- data/lib/metanorma/standoc/macros_terms.rb +181 -0
- data/lib/metanorma/standoc/ref.rb +243 -0
- data/lib/metanorma/standoc/ref_sect.rb +153 -0
- data/lib/metanorma/standoc/ref_utility.rb +129 -0
- data/lib/metanorma/standoc/render.rb +115 -0
- data/lib/metanorma/standoc/reqt.rb +90 -0
- data/lib/{asciidoctor → metanorma}/standoc/reqt.rng +0 -0
- data/lib/metanorma/standoc/section.rb +209 -0
- data/lib/metanorma/standoc/table.rb +85 -0
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +179 -0
- data/lib/metanorma/standoc/terms.rb +160 -0
- data/lib/metanorma/standoc/utils.rb +101 -0
- data/lib/metanorma/standoc/validate.rb +158 -0
- data/lib/metanorma/standoc/validate_section.rb +55 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/lib/{asciidoctor → metanorma}/standoc/views/datamodel/model_representation.adoc.erb +0 -0
- data/lib/{asciidoctor → metanorma}/standoc/views/datamodel/plantuml_representation.adoc.erb +0 -0
- data/lib/metanorma-standoc.rb +1 -1
- data/metanorma-standoc.gemspec +4 -4
- data/spec/{asciidoctor → metanorma}/base_spec.rb +73 -8
- data/spec/{asciidoctor → metanorma}/blank_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/blocks_spec.rb +49 -20
- data/spec/{asciidoctor → metanorma}/cleanup_blocks_spec.rb +25 -1
- data/spec/{asciidoctor → metanorma}/cleanup_sections_spec.rb +2 -2
- data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +9 -9
- data/spec/{asciidoctor → metanorma}/cleanup_terms_spec.rb +528 -91
- data/spec/{asciidoctor → metanorma}/datamodel/attributes_table_preprocessor_spec.rb +22 -22
- data/spec/{asciidoctor → metanorma}/datamodel/diagram_preprocessor_spec.rb +17 -17
- data/spec/{asciidoctor → metanorma}/inline_spec.rb +175 -6
- data/spec/{asciidoctor → metanorma}/isobib_cache_spec.rb +5 -9
- data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/macros_json2text_spec.rb +0 -0
- data/spec/{asciidoctor → metanorma}/macros_plantuml_spec.rb +3 -3
- data/spec/{asciidoctor → metanorma}/macros_spec.rb +8 -8
- data/spec/{asciidoctor → metanorma}/macros_yaml2text_spec.rb +0 -0
- data/spec/metanorma/refs_dl_spec.rb +863 -0
- data/spec/{asciidoctor → metanorma}/refs_spec.rb +1277 -687
- data/spec/{asciidoctor → metanorma}/section_spec.rb +90 -3
- data/spec/{asciidoctor → metanorma}/table_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/validate_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +179 -179
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +98 -98
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +111 -111
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_124.yml +14 -14
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
- metadata +89 -38
- data/lib/asciidoctor/standoc/ref_date_id.rb +0 -62
- data/spec/asciidoctor/refs_dl_spec.rb +0 -864
@@ -32,6 +32,19 @@
|
|
32
32
|
<ref name="DocumentType"/>
|
33
33
|
</element>
|
34
34
|
</define>
|
35
|
+
<define name="bibitem">
|
36
|
+
<element name="bibitem">
|
37
|
+
<attribute name="id">
|
38
|
+
<data type="ID"/>
|
39
|
+
</attribute>
|
40
|
+
<optional>
|
41
|
+
<attribute name="hidden">
|
42
|
+
<data type="boolean"/>
|
43
|
+
</attribute>
|
44
|
+
</optional>
|
45
|
+
<ref name="BibliographicItem"/>
|
46
|
+
</element>
|
47
|
+
</define>
|
35
48
|
<define name="section-title">
|
36
49
|
<element name="title">
|
37
50
|
<zeroOrMore>
|
@@ -58,7 +71,7 @@
|
|
58
71
|
<attribute name="alt"/>
|
59
72
|
</optional>
|
60
73
|
<optional>
|
61
|
-
<attribute name="
|
74
|
+
<attribute name="update-type">
|
62
75
|
<data type="boolean"/>
|
63
76
|
</attribute>
|
64
77
|
</optional>
|
@@ -690,6 +703,7 @@
|
|
690
703
|
<ref name="terms"/>
|
691
704
|
<ref name="term-clause"/>
|
692
705
|
<ref name="definitions"/>
|
706
|
+
<ref name="floating-title"/>
|
693
707
|
</choice>
|
694
708
|
</oneOrMore>
|
695
709
|
</element>
|
@@ -1680,6 +1694,7 @@
|
|
1680
1694
|
<ref name="clause-subsection"/>
|
1681
1695
|
<ref name="terms"/>
|
1682
1696
|
<ref name="definitions"/>
|
1697
|
+
<ref name="floating-title"/>
|
1683
1698
|
</choice>
|
1684
1699
|
</oneOrMore>
|
1685
1700
|
</choice>
|
@@ -1722,6 +1737,7 @@
|
|
1722
1737
|
<ref name="terms"/>
|
1723
1738
|
<ref name="definitions"/>
|
1724
1739
|
<ref name="references"/>
|
1740
|
+
<ref name="floating-title"/>
|
1725
1741
|
</choice>
|
1726
1742
|
</zeroOrMore>
|
1727
1743
|
</group>
|
@@ -1796,6 +1812,20 @@
|
|
1796
1812
|
<data type="ID"/>
|
1797
1813
|
</attribute>
|
1798
1814
|
</optional>
|
1815
|
+
<optional>
|
1816
|
+
<attribute name="language"/>
|
1817
|
+
</optional>
|
1818
|
+
<optional>
|
1819
|
+
<attribute name="script"/>
|
1820
|
+
</optional>
|
1821
|
+
<optional>
|
1822
|
+
<attribute name="tag"/>
|
1823
|
+
</optional>
|
1824
|
+
<optional>
|
1825
|
+
<attribute name="multilingual-rendering">
|
1826
|
+
<ref name="MultilingualRenderingType"/>
|
1827
|
+
</attribute>
|
1828
|
+
</optional>
|
1799
1829
|
<oneOrMore>
|
1800
1830
|
<ref name="preferred"/>
|
1801
1831
|
</oneOrMore>
|
@@ -1814,9 +1844,6 @@
|
|
1814
1844
|
<optional>
|
1815
1845
|
<ref name="termsubject"/>
|
1816
1846
|
</optional>
|
1817
|
-
<optional>
|
1818
|
-
<ref name="termusage"/>
|
1819
|
-
</optional>
|
1820
1847
|
<oneOrMore>
|
1821
1848
|
<ref name="termdefinition"/>
|
1822
1849
|
</oneOrMore>
|
@@ -1880,17 +1907,37 @@
|
|
1880
1907
|
</attribute>
|
1881
1908
|
</optional>
|
1882
1909
|
<optional>
|
1883
|
-
<attribute name="
|
1910
|
+
<attribute name="geographic-area"/>
|
1884
1911
|
</optional>
|
1885
1912
|
<choice>
|
1886
1913
|
<ref name="expression_designation"/>
|
1887
1914
|
<ref name="letter_symbol_designation"/>
|
1888
1915
|
<ref name="graphical_symbol_designation"/>
|
1889
1916
|
</choice>
|
1917
|
+
<optional>
|
1918
|
+
<ref name="fieldofapplication"/>
|
1919
|
+
</optional>
|
1920
|
+
<optional>
|
1921
|
+
<ref name="usageinfo"/>
|
1922
|
+
</optional>
|
1890
1923
|
<zeroOrMore>
|
1891
1924
|
<ref name="termsource"/>
|
1892
1925
|
</zeroOrMore>
|
1893
1926
|
</define>
|
1927
|
+
<define name="fieldofapplication">
|
1928
|
+
<element name="field-of-application">
|
1929
|
+
<oneOrMore>
|
1930
|
+
<ref name="PureTextElement"/>
|
1931
|
+
</oneOrMore>
|
1932
|
+
</element>
|
1933
|
+
</define>
|
1934
|
+
<define name="usageinfo">
|
1935
|
+
<element name="usage-info">
|
1936
|
+
<oneOrMore>
|
1937
|
+
<ref name="PureTextElement"/>
|
1938
|
+
</oneOrMore>
|
1939
|
+
</element>
|
1940
|
+
</define>
|
1894
1941
|
<define name="letter_symbol_designation">
|
1895
1942
|
<element name="letter-symbol">
|
1896
1943
|
<optional>
|
@@ -1942,11 +1989,15 @@
|
|
1942
1989
|
</optional>
|
1943
1990
|
<element name="name">
|
1944
1991
|
<zeroOrMore>
|
1945
|
-
<
|
1992
|
+
<choice>
|
1993
|
+
<ref name="PureTextElement"/>
|
1994
|
+
<ref name="stem"/>
|
1995
|
+
<ref name="index"/>
|
1996
|
+
</choice>
|
1946
1997
|
</zeroOrMore>
|
1947
1998
|
</element>
|
1948
1999
|
<optional>
|
1949
|
-
<element name="
|
2000
|
+
<element name="abbreviation-type">
|
1950
2001
|
<ref name="AbbreviationType"/>
|
1951
2002
|
</element>
|
1952
2003
|
</optional>
|
@@ -1956,7 +2007,7 @@
|
|
1956
2007
|
</element>
|
1957
2008
|
</optional>
|
1958
2009
|
<optional>
|
1959
|
-
<element name="
|
2010
|
+
<element name="grammar">
|
1960
2011
|
<ref name="Grammar"/>
|
1961
2012
|
</element>
|
1962
2013
|
</optional>
|
@@ -1983,6 +2034,11 @@
|
|
1983
2034
|
<ref name="GrammarGender"/>
|
1984
2035
|
</element>
|
1985
2036
|
</zeroOrMore>
|
2037
|
+
<zeroOrMore>
|
2038
|
+
<element name="number">
|
2039
|
+
<ref name="GrammarNumber"/>
|
2040
|
+
</element>
|
2041
|
+
</zeroOrMore>
|
1986
2042
|
<optional>
|
1987
2043
|
<element name="isPreposition">
|
1988
2044
|
<data type="boolean"/>
|
@@ -2014,7 +2070,7 @@
|
|
2014
2070
|
</element>
|
2015
2071
|
</optional>
|
2016
2072
|
<zeroOrMore>
|
2017
|
-
<element name="
|
2073
|
+
<element name="grammar-value">
|
2018
2074
|
<text/>
|
2019
2075
|
</element>
|
2020
2076
|
</zeroOrMore>
|
@@ -2027,6 +2083,13 @@
|
|
2027
2083
|
<value>common</value>
|
2028
2084
|
</choice>
|
2029
2085
|
</define>
|
2086
|
+
<define name="GrammarNumber">
|
2087
|
+
<choice>
|
2088
|
+
<value>singular</value>
|
2089
|
+
<value>dual</value>
|
2090
|
+
<value>plural</value>
|
2091
|
+
</choice>
|
2092
|
+
</define>
|
2030
2093
|
<define name="termdomain">
|
2031
2094
|
<element name="domain">
|
2032
2095
|
<oneOrMore>
|
@@ -2041,13 +2104,6 @@
|
|
2041
2104
|
</oneOrMore>
|
2042
2105
|
</element>
|
2043
2106
|
</define>
|
2044
|
-
<define name="termusage">
|
2045
|
-
<element name="usageinfo">
|
2046
|
-
<oneOrMore>
|
2047
|
-
<ref name="BasicBlock"/>
|
2048
|
-
</oneOrMore>
|
2049
|
-
</element>
|
2050
|
-
</define>
|
2051
2107
|
<define name="termdefinition">
|
2052
2108
|
<element name="definition">
|
2053
2109
|
<choice>
|
@@ -2061,13 +2117,16 @@
|
|
2061
2117
|
</element>
|
2062
2118
|
</define>
|
2063
2119
|
<define name="verbaldefinition">
|
2064
|
-
<element name="
|
2120
|
+
<element name="verbal-definition">
|
2065
2121
|
<oneOrMore>
|
2066
2122
|
<choice>
|
2067
2123
|
<ref name="paragraph"/>
|
2068
2124
|
<ref name="dl"/>
|
2069
2125
|
<ref name="ol"/>
|
2070
2126
|
<ref name="ul"/>
|
2127
|
+
<ref name="table"/>
|
2128
|
+
<ref name="figure"/>
|
2129
|
+
<ref name="formula"/>
|
2071
2130
|
</choice>
|
2072
2131
|
</oneOrMore>
|
2073
2132
|
<zeroOrMore>
|
@@ -2076,7 +2135,7 @@
|
|
2076
2135
|
</element>
|
2077
2136
|
</define>
|
2078
2137
|
<define name="nonverbalrep">
|
2079
|
-
<element name="
|
2138
|
+
<element name="non-verbal-representation">
|
2080
2139
|
<oneOrMore>
|
2081
2140
|
<choice>
|
2082
2141
|
<ref name="table"/>
|
@@ -2491,4 +2550,17 @@
|
|
2491
2550
|
</oneOrMore>
|
2492
2551
|
</element>
|
2493
2552
|
</define>
|
2553
|
+
<define name="floating-title">
|
2554
|
+
<element name="floating-title">
|
2555
|
+
<attribute name="id">
|
2556
|
+
<data type="ID"/>
|
2557
|
+
</attribute>
|
2558
|
+
<attribute name="depth">
|
2559
|
+
<data type="int"/>
|
2560
|
+
</attribute>
|
2561
|
+
<zeroOrMore>
|
2562
|
+
<ref name="TextElement"/>
|
2563
|
+
</zeroOrMore>
|
2564
|
+
</element>
|
2565
|
+
</define>
|
2494
2566
|
</grammar>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module Lists
|
4
|
+
def li(xml_ul, item)
|
5
|
+
xml_ul.li do |xml_li|
|
6
|
+
if item.blocks?
|
7
|
+
xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
|
8
|
+
xml_li << item.content
|
9
|
+
else
|
10
|
+
xml_li.p(**attr_code(id_attr(item))) { |p| p << item.text }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def ul_li(xml_ul, item)
|
16
|
+
xml_ul.li **ul_li_attrs(item) do |xml_li|
|
17
|
+
xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
|
18
|
+
if item.blocks?
|
19
|
+
xml_li << item.content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ul_attrs(node)
|
25
|
+
attr_code(id_attr(node).merge(keep_attrs(node)))
|
26
|
+
end
|
27
|
+
|
28
|
+
def ul_li_attrs(node)
|
29
|
+
c = node.attr?("checked")
|
30
|
+
attr_code(
|
31
|
+
uncheckedcheckbox: node.attr?("checkbox") ? !c : nil,
|
32
|
+
checkedcheckbox: node.attr?("checkbox") ? c : nil,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def ulist(node)
|
37
|
+
return reference(node) if in_norm_ref? || in_biblio?
|
38
|
+
|
39
|
+
noko do |xml|
|
40
|
+
xml.ul **ul_attrs(node) do |xml_ul|
|
41
|
+
node.items.each do |item|
|
42
|
+
ul_li(xml_ul, item)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end.join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
def olist_style(style)
|
49
|
+
return "alphabet" if style == "loweralpha"
|
50
|
+
return "roman" if style == "lowerroman"
|
51
|
+
return "roman_upper" if style == "upperroman"
|
52
|
+
return "alphabet_upper" if style == "upperalpha"
|
53
|
+
|
54
|
+
style
|
55
|
+
end
|
56
|
+
|
57
|
+
def ol_attrs(node)
|
58
|
+
attr_code(id_attr(node).merge(keep_attrs(node)
|
59
|
+
.merge(type: olist_style(node.style))))
|
60
|
+
end
|
61
|
+
|
62
|
+
def olist(node)
|
63
|
+
noko do |xml|
|
64
|
+
xml.ol **ol_attrs(node) do |xml_ol|
|
65
|
+
node.items.each { |item| li(xml_ol, item) }
|
66
|
+
end
|
67
|
+
end.join("\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
def dt(terms, xml_dl)
|
71
|
+
terms.each_with_index do |dt, idx|
|
72
|
+
xml_dl.dt { |xml_dt| xml_dt << dt.text }
|
73
|
+
if idx < terms.size - 1
|
74
|
+
xml_dl.dd
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def dd(ddefn, xml_dl)
|
80
|
+
if ddefn.nil?
|
81
|
+
xml_dl.dd
|
82
|
+
return
|
83
|
+
end
|
84
|
+
xml_dl.dd do |xml_dd|
|
85
|
+
xml_dd.p { |t| t << ddefn.text } if ddefn.text?
|
86
|
+
xml_dd << ddefn.content if ddefn.blocks?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def dl_attrs(node)
|
91
|
+
attr_code(id_attr(node).merge(keep_attrs(node)
|
92
|
+
.merge(
|
93
|
+
metadata: node.option?("metadata") ? "true" : nil,
|
94
|
+
key: node.option?("key") ? "true" : nil,
|
95
|
+
)))
|
96
|
+
end
|
97
|
+
|
98
|
+
def dlist(node)
|
99
|
+
noko do |xml|
|
100
|
+
xml.dl **dl_attrs(node) do |xml_dl|
|
101
|
+
node.items.each do |terms, dd|
|
102
|
+
dt(terms, xml_dl)
|
103
|
+
dd(dd, xml_dl)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end.join("\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
def colist(node)
|
110
|
+
noko do |xml|
|
111
|
+
node.items.each_with_index do |item, i|
|
112
|
+
xml.annotation **attr_code(id: i + 1) do |xml_li|
|
113
|
+
xml_li.p { |p| p << item.text }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end.join("\n")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require "asciidoctor/extensions"
|
2
|
+
require "fileutils"
|
3
|
+
require "uuidtools"
|
4
|
+
require "yaml"
|
5
|
+
require "csv"
|
6
|
+
require_relative "./macros_plantuml"
|
7
|
+
require_relative "./macros_terms"
|
8
|
+
require_relative "./macros_form"
|
9
|
+
require_relative "./macros_note"
|
10
|
+
require_relative "./datamodel/attributes_table_preprocessor"
|
11
|
+
require_relative "./datamodel/diagram_preprocessor"
|
12
|
+
require "metanorma-plugin-datastruct"
|
13
|
+
require "metanorma-plugin-lutaml"
|
14
|
+
|
15
|
+
module Metanorma
|
16
|
+
module Standoc
|
17
|
+
class InheritInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
18
|
+
use_dsl
|
19
|
+
named :inherit
|
20
|
+
parse_content_as :text
|
21
|
+
using_format :short
|
22
|
+
|
23
|
+
def process(parent, _target, attrs)
|
24
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
25
|
+
%{<inherit>#{out}</inherit>}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class IndexXrefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
30
|
+
use_dsl
|
31
|
+
named :index
|
32
|
+
|
33
|
+
def preprocess_attrs(attrs)
|
34
|
+
return unless attrs.size > 1 && attrs.size < 5
|
35
|
+
|
36
|
+
ret = { primary: attrs[1], target: attrs[attrs.size] }
|
37
|
+
ret[:secondary] = attrs[2] if attrs.size > 2
|
38
|
+
ret[:tertiary] = attrs[3] if attrs.size > 3
|
39
|
+
ret
|
40
|
+
end
|
41
|
+
|
42
|
+
def process(_parent, target, attr)
|
43
|
+
args = preprocess_attrs(attr) or return
|
44
|
+
ret = "<index-xref also='#{target == 'also'}'>"\
|
45
|
+
"<primary>#{args[:primary]}</primary>"
|
46
|
+
ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
|
47
|
+
ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
|
48
|
+
ret + "<target>#{args[:target]}</target></index-xref>"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class IndexRangeInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
53
|
+
use_dsl
|
54
|
+
named :"index-range"
|
55
|
+
parse_content_as :text
|
56
|
+
|
57
|
+
def process(parent, target, attr)
|
58
|
+
text = attr["text"]
|
59
|
+
text = "((#{text}))" unless /^\(\(.+\)\)$/.match?(text)
|
60
|
+
out = parent.sub_macros(text)
|
61
|
+
out.sub(/<index>/, "<index to='#{target}'>")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class PseudocodeBlockMacro < Asciidoctor::Extensions::BlockProcessor
|
66
|
+
use_dsl
|
67
|
+
named :pseudocode
|
68
|
+
on_context :example, :sourcecode
|
69
|
+
|
70
|
+
def init_indent(line)
|
71
|
+
/^(?<prefix>[ \t]*)(?<suffix>.*)$/ =~ line
|
72
|
+
prefix = prefix.gsub(/\t/, "\u00a0\u00a0\u00a0\u00a0")
|
73
|
+
.gsub(/ /, "\u00a0")
|
74
|
+
prefix + suffix
|
75
|
+
end
|
76
|
+
|
77
|
+
def supply_br(lines)
|
78
|
+
ignore = false
|
79
|
+
lines.each_with_index do |l, i|
|
80
|
+
/^(--+|====+|\|===|\.\.\.\.+|\*\*\*\*+|\+\+\+\++|````+|____\+)$/
|
81
|
+
.match(l) && (ignore = !ignore)
|
82
|
+
next if l.empty? || l.match(/ \+$/) || /^\[.*\]$/.match?(l) || ignore
|
83
|
+
next if i == lines.size - 1 ||
|
84
|
+
i < lines.size - 1 && lines[i + 1].empty?
|
85
|
+
|
86
|
+
lines[i] += " +"
|
87
|
+
end
|
88
|
+
lines
|
89
|
+
end
|
90
|
+
|
91
|
+
def process(parent, reader, attrs)
|
92
|
+
attrs["role"] = "pseudocode"
|
93
|
+
lines = reader.lines.map { |m| init_indent(m) }
|
94
|
+
create_block(parent, :example, supply_br(lines),
|
95
|
+
attrs, content_model: :compound)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class HTML5RubyMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
100
|
+
use_dsl
|
101
|
+
named :ruby
|
102
|
+
parse_content_as :text
|
103
|
+
option :pos_attrs, %w(rpbegin rt rpend)
|
104
|
+
|
105
|
+
# for example, html5ruby:楽聖少女[がくせいしょうじょ]
|
106
|
+
def process(_parent, target, attributes)
|
107
|
+
rpbegin = "("
|
108
|
+
rpend = ")"
|
109
|
+
if (attributes.size == 1) && attributes.key?("text")
|
110
|
+
rt = attributes["text"]
|
111
|
+
elsif (attributes.size == 2) && attributes.key?(1) &&
|
112
|
+
attributes.key?("rpbegin")
|
113
|
+
rt = attributes[1] || ""
|
114
|
+
else
|
115
|
+
rpbegin = attributes["rpbegin"]
|
116
|
+
rt = attributes["rt"]
|
117
|
+
rpend = attributes["rpend"]
|
118
|
+
end
|
119
|
+
|
120
|
+
"<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>"\
|
121
|
+
"<rp>#{rpend}</rp></ruby>"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class AutonumberInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
126
|
+
use_dsl
|
127
|
+
named :autonumber
|
128
|
+
parse_content_as :text
|
129
|
+
|
130
|
+
def process(parent, target, attrs)
|
131
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
132
|
+
%{<autonumber type=#{target}>#{out}</autonumber>}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class VariantInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
137
|
+
use_dsl
|
138
|
+
named :lang
|
139
|
+
parse_content_as :text
|
140
|
+
|
141
|
+
def process(parent, target, attrs)
|
142
|
+
/^(?<lang>[^-]*)(-(?<script>.*))?$/ =~ target
|
143
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
144
|
+
if script
|
145
|
+
%{<variant lang=#{lang} script=#{script}>#{out}</variant>}
|
146
|
+
else
|
147
|
+
%{<variant lang=#{lang}>#{out}</variant>}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
class AddMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
153
|
+
use_dsl
|
154
|
+
named :add
|
155
|
+
parse_content_as :text
|
156
|
+
using_format :short
|
157
|
+
|
158
|
+
def process(parent, _target, attrs)
|
159
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
160
|
+
%{<add>#{out}</add>}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
class DelMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
165
|
+
use_dsl
|
166
|
+
named :del
|
167
|
+
parse_content_as :text
|
168
|
+
using_format :short
|
169
|
+
|
170
|
+
def process(parent, _target, attrs)
|
171
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
172
|
+
%{<del>#{out}</del>}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class ToCInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
177
|
+
use_dsl
|
178
|
+
named :toc
|
179
|
+
parse_content_as :text
|
180
|
+
using_format :short
|
181
|
+
|
182
|
+
def process(parent, _target, attrs)
|
183
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
184
|
+
content = CSV.parse_line(out).map do |x|
|
185
|
+
x.sub!(/^(["'])(.+)\1/, "\\2")
|
186
|
+
m = /^(.*?)(:\d+)?$/.match(x)
|
187
|
+
%{<toc-xpath depth='#{m[2]&.sub(/:/, '') || 1}'>#{m[1]}</toc-xpath>}
|
188
|
+
end.join
|
189
|
+
"<toc>#{content}</toc>"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
class PassInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
194
|
+
use_dsl
|
195
|
+
named :"pass-format"
|
196
|
+
|
197
|
+
def process(parent, target, attrs)
|
198
|
+
format = target || "metanorma"
|
199
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs[1]).convert
|
200
|
+
%{<passthrough formats="#{format}">#{out}</passthrough>}
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
class FormInputMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
4
|
+
use_dsl
|
5
|
+
named :input
|
6
|
+
|
7
|
+
def process(_parent, target, attr)
|
8
|
+
m = %w(id name value disabled readonly checked maxlength minlength)
|
9
|
+
.map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
|
10
|
+
%{<input type='#{target}' #{m.join}/>}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class FormLabelMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
15
|
+
use_dsl
|
16
|
+
named :label
|
17
|
+
parse_content_as :text
|
18
|
+
|
19
|
+
def process(parent, target, attr)
|
20
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
|
21
|
+
%{<label for="#{target}">#{out}</label>}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class FormTextareaMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
26
|
+
use_dsl
|
27
|
+
named :textarea
|
28
|
+
using_format :short
|
29
|
+
|
30
|
+
def process(_parent, _target, attr)
|
31
|
+
m = %w(id name rows cols value)
|
32
|
+
.map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
|
33
|
+
%{<textarea #{m.join}/>}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class FormSelectMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
38
|
+
use_dsl
|
39
|
+
named :select
|
40
|
+
using_format :short
|
41
|
+
|
42
|
+
def process(parent, _target, attr)
|
43
|
+
m = %w(id name size disabled multiple value)
|
44
|
+
.map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
|
45
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
|
46
|
+
%{<select #{m.join}>#{out}</select>}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class FormOptionMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
51
|
+
use_dsl
|
52
|
+
named :option
|
53
|
+
using_format :short
|
54
|
+
|
55
|
+
def process(parent, _target, attr)
|
56
|
+
m = %w(disabled value)
|
57
|
+
.map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
|
58
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
|
59
|
+
%{<option #{m.join}">#{out}</option>}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
class ToDoAdmonitionBlock < Asciidoctor::Extensions::BlockProcessor
|
4
|
+
use_dsl
|
5
|
+
named :TODO
|
6
|
+
on_contexts :example, :paragraph
|
7
|
+
|
8
|
+
def process(parent, reader, attrs)
|
9
|
+
attrs["name"] = "todo"
|
10
|
+
attrs["caption"] = "TODO"
|
11
|
+
create_block(parent, :admonition, reader.lines, attrs,
|
12
|
+
content_model: :compound)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ToDoInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
|
17
|
+
def process(document)
|
18
|
+
(document.find_by context: :paragraph).each do |para|
|
19
|
+
next unless /^TODO: /.match? para.lines[0]
|
20
|
+
|
21
|
+
parent = para.parent
|
22
|
+
para.set_attr("name", "todo")
|
23
|
+
para.set_attr("caption", "TODO")
|
24
|
+
para.lines[0].sub!(/^TODO: /, "")
|
25
|
+
todo = Asciidoctor::Block.new(parent, :admonition, attributes: para.attributes,
|
26
|
+
source: para.lines,
|
27
|
+
content_model: :compound)
|
28
|
+
parent.blocks[parent.blocks.index(para)] = todo
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
34
|
+
use_dsl
|
35
|
+
named :footnoteblock
|
36
|
+
parse_content_as :text
|
37
|
+
using_format :short
|
38
|
+
|
39
|
+
def process(parent, _target, attrs)
|
40
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
41
|
+
%{<footnoteblock>#{out}</footnoteblock>}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|