Module: Metanorma::Standoc::Blocks

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

Constant Summary collapse

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

# We append each contained block to its parent
def open(node)
  role = node.role || node.attr("style")
  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)
  result = []
  node.blocks.each { |b| result << send(b.context, b) }
  result
end

def block_title(node, out)
  node.title.nil? and return
  out.name **attr_code(id_attr(nil)) do |name|
    name << node.title
  end
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 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

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

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

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

# prevent A's and other subs inappropriate for pseudocode
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

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

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

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,
           type: node.attr("type"))))
end

# term sources occasionally turning up as "source source"?
def paragraph(node)
  node.role&.sub(/ .*$/, "") == "source" and return termsource(node)
  noko do |xml|
    xml.p **para_attrs(node) do |xml_t|
      xml_t << node.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
  node.attr("attribution") and
    out.author { |a| a << 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

PASSTHROUGH_ERR = "This is not valid Metanorma XML. If you intended a different format, such as HTML, you need to specify `format=` on the pass markup;\nrefer to https://www.metanorma.org/author/topics/blocks/passthroughs/\n".freeze

Instance Method Summary collapse

Instance Method Details

#admonition(node) ⇒ Object



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

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



102
103
104
105
106
107
# File 'lib/metanorma/standoc/blocks_notes.rb', line 102

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



71
72
73
74
75
# File 'lib/metanorma/standoc/blocks_notes.rb', line 71

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



77
78
79
80
81
82
83
# File 'lib/metanorma/standoc/blocks_notes.rb', line 77

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



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

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

#block_title(node, out) ⇒ Object



50
51
52
53
54
55
# File 'lib/metanorma/standoc/blocks.rb', line 50

def block_title(node, out)
  node.title.nil? and return
  out.name **attr_code(id_attr(nil)) do |name|
    name << node.title
  end
end

#boilerplate_note(node) ⇒ Object



66
67
68
69
# File 'lib/metanorma/standoc/blocks_notes.rb', line 66

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

#default_requirement_modelObject



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

def default_requirement_model
  :default
end

#example(node) ⇒ Object



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

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



144
145
146
# File 'lib/metanorma/standoc/blocks.rb', line 144

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

#example_by_role(node, role) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/metanorma/standoc/blocks.rb', line 115

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



148
149
150
151
152
153
154
155
# File 'lib/metanorma/standoc/blocks.rb', line 148

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



125
126
127
128
129
130
131
# File 'lib/metanorma/standoc/blocks.rb', line 125

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
# File 'lib/metanorma/standoc/blocks_image.rb', line 28

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

#figure_example(node) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/metanorma/standoc/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



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

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

#form_attrs(node) ⇒ Object



57
58
59
60
61
# File 'lib/metanorma/standoc/blocks.rb', line 57

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/standoc/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



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

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/standoc/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



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

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/standoc/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

#listing(node) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/metanorma/standoc/blocks.rb', line 210

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



199
200
201
202
203
204
205
206
207
208
# File 'lib/metanorma/standoc/blocks.rb', line 199

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



75
76
77
78
79
80
81
82
83
84
# File 'lib/metanorma/standoc/blocks.rb', line 75

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



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

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

#note(node) ⇒ Object



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

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



12
13
14
15
# File 'lib/metanorma/standoc/blocks_notes.rb', line 12

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/standoc/blocks.rb', line 39

def open(node)
  role = node.role || node.attr("style")
  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)
  result = []
  node.blocks.each { |b| result << send(b.context, b) }
  result
end

#para_attrs(node) ⇒ Object



157
158
159
160
161
162
# File 'lib/metanorma/standoc/blocks.rb', line 157

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,
           type: node.attr("type"))))
end

#paragraph(node) ⇒ Object

term sources occasionally turning up as “source source”?



165
166
167
168
169
170
171
172
# File 'lib/metanorma/standoc/blocks.rb', line 165

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

#pass(node) ⇒ Object



223
224
225
226
227
228
229
230
231
232
233
# File 'lib/metanorma/standoc/blocks.rb', line 223

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



245
246
247
248
249
250
251
# File 'lib/metanorma/standoc/blocks.rb', line 245

def passthrough_validate(node, content, encoded_content)
  valid, = validate_document_fragment(content.dup)
  err =
    "Invalid passthrough content: #{encoded_content}\n#{PASSTHROUGH_ERR}"
  !valid and
    @log.add("Metanorma XML Syntax", node, err, severity: 0)
end

#pseudocode_example(node) ⇒ Object

prevent A’s and other subs inappropriate for pseudocode



134
135
136
137
138
139
140
141
142
# File 'lib/metanorma/standoc/blocks.rb', line 134

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



190
191
192
193
194
195
196
197
# File 'lib/metanorma/standoc/blocks.rb', line 190

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



179
180
181
182
183
184
185
186
187
188
# File 'lib/metanorma/standoc/blocks.rb', line 179

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
  node.attr("attribution") and
    out.author { |a| a << node.attr("attribution") }
end

#quote_attrs(node) ⇒ Object



174
175
176
177
# File 'lib/metanorma/standoc/blocks.rb', line 174

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

#reqt_subpart?(name) ⇒ Boolean



4
5
6
# File 'lib/metanorma/standoc/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
32
33
# File 'lib/metanorma/standoc/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)
  attrs = keep_attrs(node).merge(id_unnum_attrs(node))
    .merge(model: @reqt_model_name)
  ret = @reqt_model.requirement(node, obligation, attrs)
  @reqt_model = nil unless nested
  ret
end

#requirement_subpart(node) ⇒ Object



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

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

#requirement_validate(docxml) ⇒ Object



35
36
37
38
39
40
# File 'lib/metanorma/standoc/reqt.rb', line 35

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/standoc/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


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

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


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

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



87
88
89
90
91
92
93
# File 'lib/metanorma/standoc/blocks.rb', line 87

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/standoc/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/standoc/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



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

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



49
50
51
52
53
54
55
# File 'lib/metanorma/standoc/blocks_notes.rb', line 49

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
# File 'lib/metanorma/standoc/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,
    )))
end

#todo(node) ⇒ Object



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

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



37
38
39
# File 'lib/metanorma/standoc/blocks_notes.rb', line 37

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