metanorma-standoc 1.11.4 → 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/lib/asciidoctor/standoc/base.rb +2 -145
- data/lib/asciidoctor/standoc/blocks.rb +2 -238
- data/lib/asciidoctor/standoc/blocks_notes.rb +2 -100
- data/lib/asciidoctor/standoc/cleanup.rb +2 -208
- data/lib/asciidoctor/standoc/cleanup_amend.rb +2 -53
- data/lib/asciidoctor/standoc/cleanup_block.rb +2 -172
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -212
- 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 -189
- 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 -103
- 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 -139
- data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +2 -198
- 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 -223
- data/lib/asciidoctor/standoc/front_contributor.rb +2 -191
- data/lib/asciidoctor/standoc/inline.rb +2 -231
- 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 -251
- data/lib/asciidoctor/standoc/ref_sect.rb +2 -153
- data/lib/asciidoctor/standoc/ref_utility.rb +2 -0
- data/lib/asciidoctor/standoc/render.rb +2 -114
- data/lib/asciidoctor/standoc/reqt.rb +2 -89
- data/lib/asciidoctor/standoc/section.rb +2 -207
- 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 -159
- data/lib/asciidoctor/standoc/utils.rb +2 -100
- data/lib/asciidoctor/standoc/validate.rb +2 -157
- data/lib/asciidoctor/standoc/validate_section.rb +2 -54
- 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 +29 -0
- 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/{asciidoctor/standoc/ref_date_id.rb → metanorma/standoc/ref_utility.rb} +43 -5
- 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 +1 -1
- data/spec/{asciidoctor → metanorma}/base_spec.rb +27 -10
- data/spec/{asciidoctor → metanorma}/blank_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/cleanup_blocks_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/cleanup_sections_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +5 -5
- data/spec/{asciidoctor → metanorma}/cleanup_terms_spec.rb +2 -2
- data/spec/{asciidoctor → metanorma}/datamodel/attributes_table_preprocessor_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/datamodel/diagram_preprocessor_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/isobib_cache_spec.rb +1 -1
- 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 +6 -6
- 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 +399 -25
- data/spec/{asciidoctor → metanorma}/section_spec.rb +42 -17
- data/spec/{asciidoctor → metanorma}/table_spec.rb +1 -1
- data/spec/{asciidoctor → metanorma}/validate_spec.rb +2 -2
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +42 -42
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +21 -21
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +81 -81
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +10 -10
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +13 -13
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
- metadata +82 -32
- data/spec/asciidoctor/refs_dl_spec.rb +0 -864
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6821b17f6ce6a902c1413023414907d3fca23e9831c8f30eb2b9239577481e2
|
4
|
+
data.tar.gz: 88ab1712fe03b4f927240dd6237fe353353dd8cbd46f3a62f602b91493d93535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff45bc86d56ac270f2a91dcbd3473b91f4051466aea45cc8c0c5af607241dbebc9f54e7628bee5009a05b5d59704940312c64a8fa274c922dbcb4cc0d3a66280
|
7
|
+
data.tar.gz: 636e2808978f3f227ce50906b47180d3d96baf4fa667166a086be67cc1a5310b240f0c5dede99715faea6f99b8124739a1ab6a75a9784e6a5f90827c15595b4e
|
data/.github/workflows/rake.yml
CHANGED
@@ -10,34 +10,6 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
rake:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
strategy:
|
17
|
-
fail-fast: false
|
18
|
-
matrix:
|
19
|
-
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
|
-
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
-
experimental: [ false ]
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@master
|
24
|
-
|
25
|
-
- uses: ruby/setup-ruby@v1
|
26
|
-
with:
|
27
|
-
ruby-version: ${{ matrix.ruby }}
|
28
|
-
bundler-cache: true
|
29
|
-
|
30
|
-
- uses: metanorma/metanorma-build-scripts/plantuml-setup-action@master
|
31
|
-
|
32
|
-
- run: bundle exec rake
|
33
|
-
|
34
|
-
tests-passed:
|
35
|
-
needs: rake
|
36
|
-
runs-on: ubuntu-latest
|
37
|
-
steps:
|
38
|
-
- uses: peter-evans/repository-dispatch@v1
|
39
|
-
with:
|
40
|
-
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
41
|
-
repository: ${{ github.repository }}
|
42
|
-
event-type: tests-passed
|
43
|
-
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
13
|
+
uses: metanorma/metanorma-build-scripts/.github/workflows/plantuml-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
data/.gitignore
CHANGED
@@ -12,3 +12,26 @@ spec/examples/rice_files/
|
|
12
12
|
Gemfile.lock
|
13
13
|
|
14
14
|
.rubocop-https--*
|
15
|
+
|
16
|
+
/.err
|
17
|
+
/action_schemaexpg1.svg
|
18
|
+
/action_schemaexpg2.svg
|
19
|
+
/address_class_profile.presentation.xml
|
20
|
+
/address_component_profile.presentation.xml
|
21
|
+
/blank_definition_profile.presentation.xml
|
22
|
+
/common_models_diagram.presentation.xml
|
23
|
+
/plantuml/
|
24
|
+
/relaton/
|
25
|
+
/spec/assets/lutaml/
|
26
|
+
/spec/assets/plantuml*.png
|
27
|
+
/spec/assets/xref_error.*
|
28
|
+
/test.doc
|
29
|
+
/test.err
|
30
|
+
/test.html
|
31
|
+
/test.pdf
|
32
|
+
/test.presentation.xml
|
33
|
+
/test.xml
|
34
|
+
/test.xml.abort
|
35
|
+
/test/
|
36
|
+
/top_down_diagram.presentation.xml
|
37
|
+
/xref_error.*
|
@@ -1,146 +1,3 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "htmlentities"
|
4
|
-
require "json"
|
5
|
-
require "pathname"
|
6
|
-
require "isodoc"
|
7
|
-
require "relaton"
|
8
|
-
require "fileutils"
|
9
|
-
require "metanorma-utils"
|
10
|
-
require "isodoc/xslfo_convert"
|
11
|
-
require_relative "render"
|
1
|
+
require "asciidoctor/standoc/deprecated"
|
2
|
+
require "metanorma/standoc/base"
|
12
3
|
|
13
|
-
module Asciidoctor
|
14
|
-
module Standoc
|
15
|
-
module Base
|
16
|
-
XML_ROOT_TAG = "standard-document".freeze
|
17
|
-
XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
|
18
|
-
FONTS_MANIFEST = "fonts-manifest".freeze
|
19
|
-
|
20
|
-
def xml_root_tag
|
21
|
-
self.class::XML_ROOT_TAG
|
22
|
-
end
|
23
|
-
|
24
|
-
def xml_namespace
|
25
|
-
self.class::XML_NAMESPACE
|
26
|
-
end
|
27
|
-
|
28
|
-
def init(node)
|
29
|
-
@fn_number ||= 0
|
30
|
-
@draft = false
|
31
|
-
@refids = Set.new
|
32
|
-
@anchors = {}
|
33
|
-
@internal_eref_namespaces = []
|
34
|
-
@draft = node.attributes.has_key?("draft")
|
35
|
-
@novalid = node.attr("novalid")
|
36
|
-
@smartquotes = node.attr("smartquotes") != "false"
|
37
|
-
@keepasciimath = node.attr("mn-keep-asciimath") &&
|
38
|
-
node.attr("mn-keep-asciimath") != "false"
|
39
|
-
@fontheader = default_fonts(node)
|
40
|
-
@files_to_delete = []
|
41
|
-
@filename = if node.attr("docfile")
|
42
|
-
File.basename(node.attr("docfile"))&.gsub(/\.adoc$/, "")
|
43
|
-
else ""
|
44
|
-
end
|
45
|
-
@localdir = Metanorma::Utils::localdir(node)
|
46
|
-
@output_dir = outputdir node
|
47
|
-
@no_isobib_cache = node.attr("no-isobib-cache")
|
48
|
-
@no_isobib = node.attr("no-isobib")
|
49
|
-
@index_terms = node.attr("index-terms")
|
50
|
-
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
51
|
-
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
52
|
-
@bibdb = nil
|
53
|
-
@seen_headers = []
|
54
|
-
@datauriimage = node.attr("data-uri-image") != "false"
|
55
|
-
@boilerplateauthority = node.attr("boilerplate-authority")
|
56
|
-
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
57
|
-
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
58
|
-
@log = Metanorma::Utils::Log.new
|
59
|
-
init_bib_caches(node)
|
60
|
-
init_iev_caches(node)
|
61
|
-
@lang = (node.attr("language") || "en")
|
62
|
-
@script = (node.attr("script") ||
|
63
|
-
Metanorma::Utils.default_script(node.attr("language")))
|
64
|
-
@isodoc = isodoc(@lang, @script, node.attr("i18nyaml"))
|
65
|
-
@i18n = @isodoc.i18n
|
66
|
-
end
|
67
|
-
|
68
|
-
def document(node)
|
69
|
-
init(node)
|
70
|
-
ret = makexml(node).to_xml(encoding: "US-ASCII", indent: 2)
|
71
|
-
outputs(node, ret) unless node.attr("nodoc") || !node.attr("docfile")
|
72
|
-
clean_exit
|
73
|
-
ret
|
74
|
-
rescue StandardError => e
|
75
|
-
@log.add("Fatal Error", nil, e.message)
|
76
|
-
clean_exit
|
77
|
-
raise e
|
78
|
-
end
|
79
|
-
|
80
|
-
def version
|
81
|
-
flavour = self.class.name.sub(/::Converter$/, "").sub(/^.+::/, "")
|
82
|
-
Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
|
83
|
-
end
|
84
|
-
|
85
|
-
def clean_exit
|
86
|
-
@log.write("#{@output_dir}#{@filename}.err") unless @novalid
|
87
|
-
|
88
|
-
@files_to_delete.each { |f| FileUtils.rm f }
|
89
|
-
end
|
90
|
-
|
91
|
-
def clean_abort(msg, file = nil)
|
92
|
-
file and
|
93
|
-
File.open("#{@filename}.xml.abort", "w:UTF-8") { |f| f.write(file) }
|
94
|
-
clean_exit
|
95
|
-
abort(msg)
|
96
|
-
end
|
97
|
-
|
98
|
-
def makexml1(node)
|
99
|
-
result = ["<?xml version='1.0' encoding='UTF-8'?>",
|
100
|
-
"<#{xml_root_tag} type='semantic' version='#{version}'>"]
|
101
|
-
result << noko { |ixml| front node, ixml }
|
102
|
-
result << noko { |ixml| middle node, ixml }
|
103
|
-
result << "</#{xml_root_tag}>"
|
104
|
-
textcleanup(result)
|
105
|
-
end
|
106
|
-
|
107
|
-
def makexml(node)
|
108
|
-
result = makexml1(node)
|
109
|
-
ret1 = cleanup(Nokogiri::XML(result))
|
110
|
-
ret1.root.add_namespace(nil, xml_namespace)
|
111
|
-
validate(ret1) unless @novalid
|
112
|
-
ret1
|
113
|
-
end
|
114
|
-
|
115
|
-
def draft?
|
116
|
-
@draft
|
117
|
-
end
|
118
|
-
|
119
|
-
def doctype(node)
|
120
|
-
node.attr("doctype")&.gsub(/\s+/, "-")&.downcase
|
121
|
-
end
|
122
|
-
|
123
|
-
def front(node, xml)
|
124
|
-
xml.bibdata **attr_code(type: "standard") do |b|
|
125
|
-
metadata node, b
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def middle(node, xml)
|
130
|
-
xml.sections do |s|
|
131
|
-
s << node.content if node.blocks?
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
private
|
136
|
-
|
137
|
-
def outputdir(node)
|
138
|
-
if node.attr("output_dir").nil_or_empty?
|
139
|
-
Metanorma::Utils::localdir(node)
|
140
|
-
else
|
141
|
-
File.join(node.attr("output_dir"), "")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,239 +1,3 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require_relative "./blocks_notes"
|
1
|
+
require "asciidoctor/standoc/deprecated"
|
2
|
+
require "metanorma/standoc/blocks"
|
4
3
|
|
5
|
-
module Asciidoctor
|
6
|
-
module Standoc
|
7
|
-
module Blocks
|
8
|
-
def id_attr(node = nil)
|
9
|
-
{ id: Metanorma::Utils::anchor_or_uuid(node),
|
10
|
-
tag: node&.attr("tag"),
|
11
|
-
"multilingual-rendering": node&.attr("multilingual-rendering") }
|
12
|
-
end
|
13
|
-
|
14
|
-
def id_unnum_attrs(node)
|
15
|
-
attr_code(id_attr(node).merge(
|
16
|
-
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
17
|
-
number: node.attr("number"),
|
18
|
-
subsequence: node.attr("subsequence"),
|
19
|
-
))
|
20
|
-
end
|
21
|
-
|
22
|
-
def formula_attrs(node)
|
23
|
-
attr_code(id_unnum_attrs(node)
|
24
|
-
.merge(keep_attrs(node).merge(
|
25
|
-
inequality: node.option?("inequality") ? "true" : nil,
|
26
|
-
)))
|
27
|
-
end
|
28
|
-
|
29
|
-
def keep_attrs(node)
|
30
|
-
{ "keep-with-next": node.attr("keep-with-next"),
|
31
|
-
"keep-lines-together": node.attr("keep-lines-together") }
|
32
|
-
end
|
33
|
-
|
34
|
-
# We append each contained block to its parent
|
35
|
-
def open(node)
|
36
|
-
role = node.role || node.attr("style")
|
37
|
-
reqt_subpart(role) and return requirement_subpart(node)
|
38
|
-
role == "form" and return form(node)
|
39
|
-
role == "definition" and return termdefinition(node)
|
40
|
-
result = []
|
41
|
-
node.blocks.each do |b|
|
42
|
-
result << send(b.context, b)
|
43
|
-
end
|
44
|
-
result
|
45
|
-
end
|
46
|
-
|
47
|
-
def form(node)
|
48
|
-
noko do |xml|
|
49
|
-
xml.form **attr_code(id_attr(node)
|
50
|
-
.merge(class: node.attr("class"),
|
51
|
-
name: node.attr("name"), action: node.attr("action"))) do |f|
|
52
|
-
f << node.content
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def literal_attrs(node)
|
58
|
-
attr_code(id_attr(node).merge(keep_attrs(node)))
|
59
|
-
end
|
60
|
-
|
61
|
-
def literal(node)
|
62
|
-
noko do |xml|
|
63
|
-
xml.figure **literal_attrs(node) do |f|
|
64
|
-
figure_title(node, f)
|
65
|
-
f.pre node.lines.join("\n"),
|
66
|
-
**attr_code(id: Metanorma::Utils::anchor_or_uuid,
|
67
|
-
alt: node.attr("alt"))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# NOTE: html escaping is performed by Nokogiri
|
73
|
-
def stem(node)
|
74
|
-
noko do |xml|
|
75
|
-
xml.formula **formula_attrs(node) do |s|
|
76
|
-
stem_parse(node.lines.join("\n"), s, node.style.to_sym)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def term_example(node)
|
82
|
-
noko do |xml|
|
83
|
-
xml.termexample **attr_code(id_attr(node)) do |ex|
|
84
|
-
wrap_in_para(node, ex)
|
85
|
-
end
|
86
|
-
end.join("\n")
|
87
|
-
end
|
88
|
-
|
89
|
-
def example(node)
|
90
|
-
return term_example(node) if in_terms?
|
91
|
-
|
92
|
-
role = node.role || node.attr("style")
|
93
|
-
%w(recommendation requirement permission).include?(role) and
|
94
|
-
return requirement(node, role)
|
95
|
-
return pseudocode_example(node) if role == "pseudocode"
|
96
|
-
return svgmap_example(node) if role == "svgmap"
|
97
|
-
return form(node) if role == "form"
|
98
|
-
return termdefinition(node) if role == "definition"
|
99
|
-
|
100
|
-
reqt_subpart(role) and return requirement_subpart(node)
|
101
|
-
example_proper(node)
|
102
|
-
end
|
103
|
-
|
104
|
-
def svgmap_attrs(node)
|
105
|
-
attr_code(id_attr(node)
|
106
|
-
.merge(id: node.id,
|
107
|
-
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
108
|
-
number: node.attr("number"),
|
109
|
-
subsequence: node.attr("subsequence"))
|
110
|
-
.merge(keep_attrs(node)))
|
111
|
-
end
|
112
|
-
|
113
|
-
def svgmap_example(node)
|
114
|
-
noko do |xml|
|
115
|
-
xml.svgmap **attr_code(svgmap_attrs(node).merge(
|
116
|
-
src: node.attr("src"), alt: node.attr("alt"),
|
117
|
-
)) do |ex|
|
118
|
-
figure_title(node, ex)
|
119
|
-
ex << node.content
|
120
|
-
end
|
121
|
-
end.join("\n")
|
122
|
-
end
|
123
|
-
|
124
|
-
# prevent A's and other subs inappropriate for pseudocode
|
125
|
-
def pseudocode_example(node)
|
126
|
-
node.blocks.each { |b| b.remove_sub(:replacements) }
|
127
|
-
noko do |xml|
|
128
|
-
xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
|
129
|
-
figure_title(node, ex)
|
130
|
-
wrap_in_para(node, ex)
|
131
|
-
end
|
132
|
-
end.join("\n")
|
133
|
-
end
|
134
|
-
|
135
|
-
def example_attrs(node)
|
136
|
-
attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
|
137
|
-
end
|
138
|
-
|
139
|
-
def example_proper(node)
|
140
|
-
noko do |xml|
|
141
|
-
xml.example **example_attrs(node) do |ex|
|
142
|
-
node.title.nil? or ex.name { |name| name << node.title }
|
143
|
-
wrap_in_para(node, ex)
|
144
|
-
end
|
145
|
-
end.join("\n")
|
146
|
-
end
|
147
|
-
|
148
|
-
def figure_title(node, out)
|
149
|
-
return if node.title.nil?
|
150
|
-
|
151
|
-
out.name { |name| name << node.title }
|
152
|
-
end
|
153
|
-
|
154
|
-
def figure_attrs(node)
|
155
|
-
attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
|
156
|
-
end
|
157
|
-
|
158
|
-
def image(node)
|
159
|
-
noko do |xml|
|
160
|
-
xml.figure **figure_attrs(node) do |f|
|
161
|
-
figure_title(node, f)
|
162
|
-
f.image **image_attributes(node)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def para_attrs(node)
|
168
|
-
attr_code(id_attr(node).merge(keep_attrs(node)
|
169
|
-
.merge(align: node.attr("align"),
|
170
|
-
variant_title: node.role == "variant-title" ? true : nil,
|
171
|
-
type: node.attr("type"))))
|
172
|
-
end
|
173
|
-
|
174
|
-
def paragraph(node)
|
175
|
-
return termsource(node) if node.role == "source"
|
176
|
-
|
177
|
-
noko do |xml|
|
178
|
-
xml.p **para_attrs(node) do |xml_t|
|
179
|
-
xml_t << node.content
|
180
|
-
end
|
181
|
-
end.join("\n")
|
182
|
-
end
|
183
|
-
|
184
|
-
def quote_attrs(node)
|
185
|
-
attr_code(id_attr(node).merge(keep_attrs(node))
|
186
|
-
.merge(align: node.attr("align")))
|
187
|
-
end
|
188
|
-
|
189
|
-
def quote_attribution(node, out)
|
190
|
-
if node.attr("citetitle")
|
191
|
-
m = /^(?<cite>[^,]+)(,(?<text>.*$))?$/m.match node.attr("citetitle")
|
192
|
-
out.source **attr_code(target: m[:cite], type: "inline") do |s|
|
193
|
-
s << m[:text]
|
194
|
-
end
|
195
|
-
end
|
196
|
-
node.attr("attribution") and
|
197
|
-
out.author { |a| a << node.attr("attribution") }
|
198
|
-
end
|
199
|
-
|
200
|
-
def quote(node)
|
201
|
-
noko do |xml|
|
202
|
-
xml.quote **quote_attrs(node) do |q|
|
203
|
-
quote_attribution(node, q)
|
204
|
-
wrap_in_para(node, q)
|
205
|
-
end
|
206
|
-
end.join("\n")
|
207
|
-
end
|
208
|
-
|
209
|
-
def listing_attrs(node)
|
210
|
-
attr_code(id_attr(node).merge(keep_attrs(node)
|
211
|
-
.merge(lang: node.attr("language"),
|
212
|
-
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
213
|
-
number: node.attr("number"),
|
214
|
-
filename: node.attr("filename"))))
|
215
|
-
end
|
216
|
-
|
217
|
-
# NOTE: html escaping is performed by Nokogiri
|
218
|
-
def listing(node)
|
219
|
-
fragment = ::Nokogiri::XML::Builder.new do |xml|
|
220
|
-
xml.sourcecode **listing_attrs(node) do |s|
|
221
|
-
figure_title(node, s)
|
222
|
-
s << node.content
|
223
|
-
end
|
224
|
-
end
|
225
|
-
fragment.to_xml(encoding: "US-ASCII", save_with:
|
226
|
-
Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
|
227
|
-
end
|
228
|
-
|
229
|
-
def pass(node)
|
230
|
-
noko do |xml|
|
231
|
-
xml.passthrough **attr_code(formats:
|
232
|
-
node.attr("format") || "metanorma") do |p|
|
233
|
-
p << HTMLEntities.new.encode(node.content, :basic, :hexadecimal)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
@@ -1,101 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Blocks
|
4
|
-
def termnote_attrs(node)
|
5
|
-
attr_code(id_attr(node).merge(keep_attrs(node)
|
6
|
-
.merge(
|
7
|
-
unnumbered: node.attr("unnumbered"),
|
8
|
-
number: node.attr("number"),
|
9
|
-
subsequence: node.attr("subsequence"),
|
10
|
-
"keep-separate": node.attr("keep-separate"),
|
11
|
-
)))
|
12
|
-
end
|
1
|
+
require "asciidoctor/standoc/deprecated"
|
2
|
+
require "metanorma/standoc/blocks_notes"
|
13
3
|
|
14
|
-
def note_attrs(node)
|
15
|
-
attr_code(
|
16
|
-
termnote_attrs(node).merge(
|
17
|
-
type: node.attr("type"),
|
18
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
19
|
-
),
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def sidebar_attrs(node)
|
24
|
-
todo_attrs(node).merge(
|
25
|
-
attr_code(
|
26
|
-
from: node.attr("from"),
|
27
|
-
to: node.attr("to") || node.attr("from"),
|
28
|
-
),
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def sidebar(node)
|
33
|
-
return unless draft?
|
34
|
-
|
35
|
-
noko do |xml|
|
36
|
-
xml.review **sidebar_attrs(node) do |r|
|
37
|
-
wrap_in_para(node, r)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def todo_attrs(node)
|
43
|
-
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
44
|
-
date += "T00:00:00Z" unless /T/.match? date
|
45
|
-
attr_code(id_attr(node)
|
46
|
-
.merge(reviewer: node.attr("reviewer") || node.attr("source") ||
|
47
|
-
"(Unknown)",
|
48
|
-
date: date))
|
49
|
-
end
|
50
|
-
|
51
|
-
def todo(node)
|
52
|
-
noko do |xml|
|
53
|
-
xml.review **todo_attrs(node) do |r|
|
54
|
-
wrap_in_para(node, r)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def termnote(node)
|
60
|
-
noko do |xml|
|
61
|
-
xml.termnote **termnote_attrs(node) do |ex|
|
62
|
-
wrap_in_para(node, ex)
|
63
|
-
end
|
64
|
-
end.join("\n")
|
65
|
-
end
|
66
|
-
|
67
|
-
def note(node)
|
68
|
-
noko do |xml|
|
69
|
-
xml.note **note_attrs(node) do |c|
|
70
|
-
wrap_in_para(node, c)
|
71
|
-
end
|
72
|
-
end.join("\n")
|
73
|
-
end
|
74
|
-
|
75
|
-
def admonition_attrs(node)
|
76
|
-
name = node.attr("name")
|
77
|
-
a = node.attr("type") and ["danger", "safety precautions"].each do |t|
|
78
|
-
name = t if a.casecmp(t).zero?
|
79
|
-
end
|
80
|
-
attr_code(keep_attrs(node).merge(id_attr(node)
|
81
|
-
.merge(
|
82
|
-
type: name,
|
83
|
-
beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
|
84
|
-
)))
|
85
|
-
end
|
86
|
-
|
87
|
-
def admonition(node)
|
88
|
-
return termnote(node) if in_terms?
|
89
|
-
return note(node) if node.attr("name") == "note"
|
90
|
-
return todo(node) if node.attr("name") == "todo"
|
91
|
-
|
92
|
-
noko do |xml|
|
93
|
-
xml.admonition **admonition_attrs(node) do |a|
|
94
|
-
node.title.nil? or a.name { |name| name << node.title }
|
95
|
-
wrap_in_para(node, a)
|
96
|
-
end
|
97
|
-
end.join("\n")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|