Module: Metanorma::Standoc::Blocks

Included in:
Converter
Defined in:
lib/metanorma/converter/reqt.rb,
lib/metanorma/converter/blocks.rb,
lib/metanorma/converter/blocks_image.rb,
lib/metanorma/converter/blocks_notes.rb,
lib/metanorma/converter/blocks_examples.rb

Constant Summary collapse

PASSTHRU_ERR =
"keep-lines-together": node.attr("keep-lines-together") }
end

# We append each contained block to its parent
def open(node)
  role = open_role(node)
  reqt_subpart?(role) and return requirement_subpart(node)
  role == "form" and return form(node)
  role == "definition" and return termdefinition(node)
  role == "boilerplate" and return boilerplate_note(node)
  role == "key" and return key_block(node)
  role == "altmedia" and return altmedia_block(node)
  open1(node)
end

def open_role(node)
  node.option?("key") and return "key"
  node.role || node.attr("style")
end

def open1(node)
  result = []
  node.blocks.each { |b| result << send(b.context, b) }
  result
end

def key_block(node)
  ret = open1(node)
  ret = ret.map do |b|
    ret = Nokogiri::XML(b)
    ret.root["key"] = true
    to_xml(ret.root)
  end
  "<key>#{ret.join("\n")}</key>"
end

def block_title(node, out)
  node.title.nil? and return
  add_noko_elem(out, "name", node.title, id_attr(nil))
end

def form_attrs(node)
  attr_code(id_attr(node)
    .merge(class: node.attr("class"),
           name: node.attr("name"), action: node.attr("action")))
end

def form(node)
  noko do |xml|
    xml.form **form_attrs(node) do |f|
      f << node.content
    end
  end
end

def literal_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node)))
end

def literal(node)
  noko do |xml|
    xml.figure **literal_attrs(node) do |f|
      block_title(node, f)
      pre_attrs = id_attr(node).tap { |h| h.delete(:anchor) }
        .merge(alt: node.attr("alt"))
      f.pre node.lines.join("\n"), **attr_code(pre_attrs)
    end
  end
end

# NOTE: html escaping is performed by Nokogiri
def stem(node)
  noko do |xml|
    xml.formula **formula_attrs(node) do |s|
      stem_parse(node.lines.join("\n"), s, node.style.to_sym, node)
    end
  end
end

def para_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node)
    .merge(align: node.attr("align"),
           variant_title: node.role == "variant-title" ? true : nil,
           key: node.option?("key") ? "true" : nil,
           type: node.attr("type"))))
end

# TODO: term sources occasionally turning up as "source source"?
def paragraph(node)
  node.role&.sub(/ .*$/, "") == "source" and return termsource(node)
  content = node.content
  content.start_with?("TODO: ") and return todo_prefixed_para(node)
  content.start_with?("EDITOR: ") and return editor_prefixed_para(node)
  noko do |xml|
    xml.p **para_attrs(node) do |xml_t|
      xml_t << content
    end
  end
end

def quote_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node))
    .merge(align: node.attr("align")))
end

def quote_attribution(node, out)
  if node.attr("citetitle")
    m = /^(?<cite>[^,]+)(?:,(?<text>.*$))?$/m.match node.attr("citetitle")
    out.source **attr_code(target: m[:cite], type: "inline") do |s|
      s << m[:text]
    end
  end
  add_noko_elem(out, "author", node.attr("attribution"))
end

def quote(node)
  noko do |xml|
    xml.quote **quote_attrs(node) do |q|
      quote_attribution(node, q)
      wrap_in_para(node, q)
    end
  end
end

def listing_attrs(node)
  linenums = node.option?("linenums") || node.attributes[3] ||
    @source_linenums
  attr_code(id_attr(node).merge(keep_attrs(node)
            .merge(lang: node.attr("language"),
                   linenums: linenums ? "true" : nil,
                   unnumbered: node.option?("unnumbered") ? "true" : nil,
                   number: node.attr("number"),
                   filename: node.attr("filename"))))
end

def listing(node)
  fragment = ::Nokogiri::XML::Builder.new do |xml|
    xml.sourcecode **listing_attrs(node) do |s|
      block_title(node, s)
      s.body do |b|
        b << node.content
      end
    end
  end
  fragment.to_xml(encoding: "US-ASCII", save_with:
                  Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
end

def pass(node)
  format = node.attr("format") || "metanorma"
  noko do |xml|
    xml.passthrough **attr_code(formats: format) do |p|
      content = @c.encode(node.content, :basic, :hexadecimal)
      p << content
      format == "metanorma" and
        passthrough_validate(node, node.content, content)
    end
  end
end

PASSTHRU_ERR = <<~ERRMSG.freeze
  This is not valid Metanorma XML. If you intended a different format, such as HTML, you need to specify `format=` on the pass markup;
  refer to https://www.metanorma.org/author/topics/blocks/passthroughs/
ERRMSG

Instance Method Summary collapse

Instance Method Details

#admonition(node) ⇒ Object



107
108
109
110
111
112
113
114
115
# File 'lib/metanorma/converter/blocks_notes.rb', line 107

def admonition(node)
  ret = admonition_alternatives(node) and return ret
  noko do |xml|
    xml.admonition **admonition_attrs(node) do |a|
      block_title(node, a)
      wrap_in_para(node, a)
    end
  end
end

#admonition_alternatives(node) ⇒ Object



117
118
119
120
121
122
# File 'lib/metanorma/converter/blocks_notes.rb', line 117

def admonition_alternatives(node)
  in_terms? && node.attr("name") == "note" and return termnote(node)
  node.attr("name") == "note" and return note(node)
  node.attr("name") == "todo" and return todo(node)
  nil
end

#admonition_attrs(node) ⇒ Object



86
87
88
89
90
# File 'lib/metanorma/converter/blocks_notes.rb', line 86

def admonition_attrs(node)
  attr_code(keep_attrs(node).merge(id_attr(node)
    .merge(admonition_core_attrs(node)
    .merge(type: admonition_name(node)))))
end

#admonition_core_attrs(node) ⇒ Object



92
93
94
95
96
97
98
# File 'lib/metanorma/converter/blocks_notes.rb', line 92

def admonition_core_attrs(node)
  { notag: node.attr("notag") == "true" ? "true" : nil,
    coverpage: node.attr("coverpage") == "true" ? "true" : nil,
    beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
    unnumbered: node.attr("unnumbered") ||
      (node.attr("notag") == "true") || nil }
end

#admonition_name(node) ⇒ Object



100
101
102
103
104
105
# File 'lib/metanorma/converter/blocks_notes.rb', line 100

def admonition_name(node)
  ret = node.attr("type") || node.attr("name") or return
  ret = ret.downcase
  ret == "editor" and ret = "editorial"
  ret
end

#altmedia_block(node) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/metanorma/converter/blocks_image.rb', line 44

def altmedia_block(node)
  noko do |xml|
    xml.figure **figure_attrs(node) do |f|
      block_title(node, f)
      f.image **image_attributes(node, src: false, altmedia: true) do |i|
        i << node.content
      end
    end
  end
end

#block_title(node, out) ⇒ Object



71
72
73
74
# File 'lib/metanorma/converter/blocks.rb', line 71

def block_title(node, out)
  node.title.nil? and return
  add_noko_elem(out, "name", node.title, id_attr(nil))
end

#boilerplate_note(node) ⇒ Object



81
82
83
84
# File 'lib/metanorma/converter/blocks_notes.rb', line 81

def boilerplate_note(node)
  node.set_attr("type", "boilerplate")
  note(node)
end

#default_requirement_modelObject



12
13
14
# File 'lib/metanorma/converter/reqt.rb', line 12

def default_requirement_model
  :default
end

#editor_prefixed_para(node) ⇒ Object

EDITOR:



57
58
59
60
61
62
# File 'lib/metanorma/converter/blocks_notes.rb', line 57

def editor_prefixed_para(node)
  node.lines[0].sub!(/^EDITOR: /, "")
  node.set_attr("type", "editorial")
  node.assign_caption "EDITOR"
  admonition(node)
end

#example(node) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/metanorma/converter/blocks_examples.rb', line 13

def example(node)
  role = node.role || node.attr("style")
  ret = example_to_requirement(node, role) ||
    example_by_role(node, role) and return ret
  (in_terms? || node.option?("termexample")) and return term_example(node)
  reqt_subpart?(role) and return requirement_subpart(node)
  example_proper(node)
end

#example_attrs(node) ⇒ Object



51
52
53
# File 'lib/metanorma/converter/blocks_examples.rb', line 51

def example_attrs(node)
  attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
end

#example_by_role(node, role) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/metanorma/converter/blocks_examples.rb', line 22

def example_by_role(node, role)
  case role
  when "pseudocode" then pseudocode_example(node)
  when "svgmap" then svgmap_example(node)
  when "form" then form(node)
  when "definition" then termdefinition(node)
  when "figure" then figure_example(node)
  end
end

#example_proper(node) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/metanorma/converter/blocks_examples.rb', line 55

def example_proper(node)
  noko do |xml|
    xml.example **example_attrs(node) do |ex|
      block_title(node, xml)
      wrap_in_para(node, ex)
    end
  end
end

#example_to_requirement(node, role) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/metanorma/converter/blocks_examples.rb', line 32

def example_to_requirement(node, role)
  @reqt_models.requirement_roles.key?(role&.to_sym) or return
  # need to call here for proper recursion ordering
  select_requirement_model(node)
  requirement(node,
              @reqt_models.requirement_roles[role.to_sym], role)
end

#figure_attrs(node) ⇒ Object



28
29
30
31
32
33
# File 'lib/metanorma/converter/blocks_image.rb', line 28

def figure_attrs(node)
  attr_code(id_unnum_attrs(node).merge(keep_attrs(node))
    .merge(class: node.attr("class"),
           height: node.attr("height"),
           width: node.attr("width")))
end

#figure_example(node) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/metanorma/converter/blocks_image.rb', line 19

def figure_example(node)
  noko do |xml|
    xml.figure **figure_attrs(node) do |ex|
      block_title(node, ex)
      wrap_in_para(node, ex)
    end
  end
end

#form(node) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/metanorma/converter/blocks.rb', line 82

def form(node)
  noko do |xml|
    xml.form **form_attrs(node) do |f|
      f << node.content
    end
  end
end

#form_attrs(node) ⇒ Object



76
77
78
79
80
# File 'lib/metanorma/converter/blocks.rb', line 76

def form_attrs(node)
  attr_code(id_attr(node)
    .merge(class: node.attr("class"),
           name: node.attr("name"), action: node.attr("action")))
end

#formula_attrs(node) ⇒ Object



26
27
28
29
30
31
# File 'lib/metanorma/converter/blocks.rb', line 26

def formula_attrs(node)
  attr_code(id_unnum_attrs(node)
    .merge(keep_attrs(node).merge(
             inequality: node.option?("inequality") ? "true" : nil,
           )))
end

#id_attr(node = nil) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/metanorma/converter/blocks.rb', line 9

def id_attr(node = nil)
  anchor = node&.id
  { id: "_#{UUIDTools::UUID.random_create}",
    anchor: anchor && !anchor.empty? ? anchor : nil,
    tag: node&.attr("tag"), columns: node&.attr("columns"),
    "multilingual-rendering": node&.attr("multilingual-rendering") }
    .compact
end

#id_unnum_attrs(node) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/metanorma/converter/blocks.rb', line 18

def id_unnum_attrs(node)
  attr_code(id_attr(node).merge(
              unnumbered: node.option?("unnumbered") ? "true" : nil,
              number: node.attr("number"),
              subsequence: node.attr("subsequence"),
            ))
end

#image(node) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/metanorma/converter/blocks_image.rb', line 35

def image(node)
  noko do |xml|
    xml.figure **figure_attrs(node) do |f|
      block_title(node, f)
      f.image **image_attributes(node).tap { |h| h.delete(:anchor) }
    end
  end
end

#keep_attrs(node) ⇒ Object



33
34
35
36
# File 'lib/metanorma/converter/blocks.rb', line 33

def keep_attrs(node)
  { "keep-with-next": node.attr("keep-with-next"),
    "keep-lines-together": node.attr("keep-lines-together") }
end

#key_block(node) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/metanorma/converter/blocks.rb', line 61

def key_block(node)
  ret = open1(node)
  ret = ret.map do |b|
    ret = Nokogiri::XML(b)
    ret.root["key"] = true
    to_xml(ret.root)
  end
  "<key>#{ret.join("\n")}</key>"
end

#listing(node) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/metanorma/converter/blocks.rb', line 170

def listing(node)
  fragment = ::Nokogiri::XML::Builder.new do |xml|
    xml.sourcecode **listing_attrs(node) do |s|
      block_title(node, s)
      s.body do |b|
        b << node.content
      end
    end
  end
  fragment.to_xml(encoding: "US-ASCII", save_with:
                  Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
end

#listing_attrs(node) ⇒ Object



159
160
161
162
163
164
165
166
167
168
# File 'lib/metanorma/converter/blocks.rb', line 159

def listing_attrs(node)
  linenums = node.option?("linenums") || node.attributes[3] ||
    @source_linenums
  attr_code(id_attr(node).merge(keep_attrs(node)
            .merge(lang: node.attr("language"),
                   linenums: linenums ? "true" : nil,
                   unnumbered: node.option?("unnumbered") ? "true" : nil,
                   number: node.attr("number"),
                   filename: node.attr("filename"))))
end

#literal(node) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/metanorma/converter/blocks.rb', line 94

def literal(node)
  noko do |xml|
    xml.figure **literal_attrs(node) do |f|
      block_title(node, f)
      pre_attrs = id_attr(node).tap { |h| h.delete(:anchor) }
        .merge(alt: node.attr("alt"))
      f.pre node.lines.join("\n"), **attr_code(pre_attrs)
    end
  end
end

#literal_attrs(node) ⇒ Object



90
91
92
# File 'lib/metanorma/converter/blocks.rb', line 90

def literal_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node)))
end

#note(node) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/metanorma/converter/blocks_notes.rb', line 72

def note(node)
  node.option?("termnote") and return termnote(node)
  noko do |xml|
    xml.note **note_attrs(node) do |c|
      wrap_in_para(node, c)
    end
  end
end

#note_attrs(node) ⇒ Object



13
14
15
16
# File 'lib/metanorma/converter/blocks_notes.rb', line 13

def note_attrs(node)
  attr_code(termnote_attrs(node).merge(admonition_core_attrs(node)
    .merge(type: node.attr("type"))))
end

#open(node) ⇒ Object

We append each contained block to its parent



39
40
41
42
43
44
45
46
47
48
# File 'lib/metanorma/converter/blocks.rb', line 39

def open(node)
  role = open_role(node)
  reqt_subpart?(role) and return requirement_subpart(node)
  role == "form" and return form(node)
  role == "definition" and return termdefinition(node)
  role == "boilerplate" and return boilerplate_note(node)
  role == "key" and return key_block(node)
  role == "altmedia" and return altmedia_block(node)
  open1(node)
end

#open1(node) ⇒ Object



55
56
57
58
59
# File 'lib/metanorma/converter/blocks.rb', line 55

def open1(node)
  result = []
  node.blocks.each { |b| result << send(b.context, b) }
  result
end

#open_role(node) ⇒ Object



50
51
52
53
# File 'lib/metanorma/converter/blocks.rb', line 50

def open_role(node)
  node.option?("key") and return "key"
  node.role || node.attr("style")
end

#para_attrs(node) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/metanorma/converter/blocks.rb', line 114

def para_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node)
    .merge(align: node.attr("align"),
           variant_title: node.role == "variant-title" ? true : nil,
           key: node.option?("key") ? "true" : nil,
           type: node.attr("type"))))
end

#paragraph(node) ⇒ Object

TODO: term sources occasionally turning up as “source source”?



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/metanorma/converter/blocks.rb', line 123

def paragraph(node)
  node.role&.sub(/ .*$/, "") == "source" and return termsource(node)
  content = node.content
  content.start_with?("TODO: ") and return todo_prefixed_para(node)
  content.start_with?("EDITOR: ") and return editor_prefixed_para(node)
  noko do |xml|
    xml.p **para_attrs(node) do |xml_t|
      xml_t << content
    end
  end
end

#pass(node) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/metanorma/converter/blocks.rb', line 183

def pass(node)
  format = node.attr("format") || "metanorma"
  noko do |xml|
    xml.passthrough **attr_code(formats: format) do |p|
      content = @c.encode(node.content, :basic, :hexadecimal)
      p << content
      format == "metanorma" and
        passthrough_validate(node, node.content, content)
    end
  end
end

#passthrough_validate(node, content, encoded_content) ⇒ Object

need to validate Metanorma XML before it passes to textcleanup, where passthrough wrapper and escaped tags are removed: <passthrough formats=“metanorma>&lt;tag&gt</passthrough> => <tag> Do not treat not well-formed XML as invalid, as it may be fragment, e.g. unterminated start of element markup



205
206
207
208
209
# File 'lib/metanorma/converter/blocks.rb', line 205

def passthrough_validate(node, content, encoded_content)
  valid, = validate_document_fragment(content.dup)
  !valid and
    @log.add("STANDOC_42", node, params: [encoded_content])
end

#pseudocode_example(node) ⇒ Object

prevent A’s and other subs inappropriate for pseudocode



41
42
43
44
45
46
47
48
49
# File 'lib/metanorma/converter/blocks_examples.rb', line 41

def pseudocode_example(node)
  node.blocks.each { |b| b.remove_sub(:replacements) }
  noko do |xml|
    xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
      block_title(node, ex)
      wrap_in_para(node, ex)
    end
  end
end

#quote(node) ⇒ Object



150
151
152
153
154
155
156
157
# File 'lib/metanorma/converter/blocks.rb', line 150

def quote(node)
  noko do |xml|
    xml.quote **quote_attrs(node) do |q|
      quote_attribution(node, q)
      wrap_in_para(node, q)
    end
  end
end

#quote_attribution(node, out) ⇒ Object



140
141
142
143
144
145
146
147
148
# File 'lib/metanorma/converter/blocks.rb', line 140

def quote_attribution(node, out)
  if node.attr("citetitle")
    m = /^(?<cite>[^,]+)(?:,(?<text>.*$))?$/m.match node.attr("citetitle")
    out.source **attr_code(target: m[:cite], type: "inline") do |s|
      s << m[:text]
    end
  end
  add_noko_elem(out, "author", node.attr("attribution"))
end

#quote_attrs(node) ⇒ Object



135
136
137
138
# File 'lib/metanorma/converter/blocks.rb', line 135

def quote_attrs(node)
  attr_code(id_attr(node).merge(keep_attrs(node))
    .merge(align: node.attr("align")))
end

#reqt_subpart?(name) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/metanorma/converter/reqt.rb', line 4

def reqt_subpart?(name)
  @reqt_model&.reqt_subpart?(name)
end

#requirement(node, obligation, type) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/metanorma/converter/reqt.rb', line 23

def requirement(node, obligation, type)
  nested = @reqt_model
  !node.attr("type") &&
    !%w(requirement recommendation permission).include?(type) and
    node.set_attr("type", type)
  ret = @reqt_model.requirement(node, obligation, requirement_attrs(node))
  @reqt_model = nil unless nested
  ret
end

#requirement_attrs(node) ⇒ Object



33
34
35
36
37
38
# File 'lib/metanorma/converter/reqt.rb', line 33

def requirement_attrs(node)
  keep_attrs(node).merge(id_unnum_attrs(node))
    .merge({ model: @reqt_model_name,
             render: node.attr("render") || @default_requirement_render }
    .compact)
end

#requirement_subpart(node) ⇒ Object



8
9
10
# File 'lib/metanorma/converter/reqt.rb', line 8

def requirement_subpart(node)
  @reqt_model.requirement_subpart(node, keep_attrs(node))
end

#requirement_validate(docxml) ⇒ Object



40
41
42
43
44
45
# File 'lib/metanorma/converter/reqt.rb', line 40

def requirement_validate(docxml)
  docxml.xpath("//requirement | //recommendation | //permission")
    .each do |r|
    @reqt_models.model(r["model"]).validate(r, @log)
  end
end

#select_requirement_model(node) ⇒ Object



16
17
18
19
20
21
# File 'lib/metanorma/converter/reqt.rb', line 16

def select_requirement_model(node)
  return if @reqt_model

  @reqt_model_name = node.attr("model") || @default_requirement_model
  @reqt_model = @reqt_models.model(@reqt_model_name)
end


18
19
20
21
22
23
24
# File 'lib/metanorma/converter/blocks_notes.rb', line 18

def sidebar(node)
  noko do |xml|
    xml.annotation **sidebar_attrs(node) do |r|
      wrap_in_para(node, r)
    end
  end
end


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/metanorma/converter/blocks_notes.rb', line 26

def sidebar_attrs(node)
  date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
  date += "T00:00:00Z" unless date.include?("T")
  attr_code(id_attr(node)
    .merge(reviewer: node.attr("reviewer") || node.attr("source") ||
           "(Unknown)",
           from: node.attr("from"),
           to: node.attr("to") || node.attr("from"),
           type: node.attr("type") || "review",
           date:))
end

#stem(node) ⇒ Object

NOTE: html escaping is performed by Nokogiri



106
107
108
109
110
111
112
# File 'lib/metanorma/converter/blocks.rb', line 106

def stem(node)
  noko do |xml|
    xml.formula **formula_attrs(node) do |s|
      stem_parse(node.lines.join("\n"), s, node.style.to_sym, node)
    end
  end
end

#svgmap_attrs(node) ⇒ Object



4
5
6
# File 'lib/metanorma/converter/blocks_image.rb', line 4

def svgmap_attrs(node)
  attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
end

#svgmap_example(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/metanorma/converter/blocks_image.rb', line 8

def svgmap_example(node)
  noko do |xml|
    xml.svgmap **attr_code(svgmap_attrs(node).merge(
                             src: node.attr("src"), alt: node.attr("alt"),
                           )) do |ex|
      block_title(node, ex)
      ex << node.content
    end
  end
end

#term_example(node) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/metanorma/converter/blocks_examples.rb', line 4

def term_example(node)
  noko do |xml|
    xml.termexample **attr_code(id_attr(node)
      .merge(keepasterm: node.option?("termexample") || nil)) do |ex|
      wrap_in_para(node, ex)
    end
  end
end

#termnote(node) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/metanorma/converter/blocks_notes.rb', line 64

def termnote(node)
  noko do |xml|
    xml.termnote **termnote_attrs(node) do |ex|
      wrap_in_para(node, ex)
    end
  end
end

#termnote_attrs(node) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/metanorma/converter/blocks_notes.rb', line 4

def termnote_attrs(node)
  attr_code(id_unnum_attrs(node).merge(keep_attrs(node)
    .merge(
      "keep-separate": node.attr("keep-separate"),
      keepasterm: node.option?("termnote") ? "true" : nil,
      type: node.attr("type")
    )))
end

#todo(node) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/metanorma/converter/blocks_notes.rb', line 42

def todo(node)
  noko do |xml|
    xml.annotation **todo_attrs(node) do |r|
      wrap_in_para(node, r)
    end
  end
end

#todo_attrs(node) ⇒ Object



38
39
40
# File 'lib/metanorma/converter/blocks_notes.rb', line 38

def todo_attrs(node)
  sidebar_attrs(node).merge(type: "todo")
end

#todo_prefixed_para(node) ⇒ Object

-TO-DO :



51
52
53
54
# File 'lib/metanorma/converter/blocks_notes.rb', line 51

def todo_prefixed_para(node)
  node.lines[0].sub!(/^TODO: /, "")
  todo(node)
end