Module: IsoDoc::Function::Blocks
- Included in:
- Common
- Defined in:
- lib/isodoc/function/blocks.rb
Constant Summary collapse
- EXAMPLE_TBL_ATTR =
{ valign: "top", class: "example_label", style: "width:82.8pt;" }.freeze
Instance Method Summary collapse
- #admonition_parse(node, out) ⇒ Object
- #annotation_parse(node, out) ⇒ Object
-
#example_div_parse(node, out) ⇒ Object
used if we are boxing examples.
- #example_label(node) ⇒ Object
- #example_parse(node, out) ⇒ Object
- #figure_key(out) ⇒ Object
- #figure_name_parse(node, div, name) ⇒ Object
- #figure_parse(node, out) ⇒ Object
- #formula_parse(node, out) ⇒ Object
- #formula_where(dl, out) ⇒ Object
- #image_parse(node, out, caption) ⇒ Object
- #image_title_parse(out, caption) ⇒ Object
- #note_label(node) ⇒ Object
- #note_p_parse(node, div) ⇒ Object
- #note_parse(node, out) ⇒ Object
- #note_parse1(node, div) ⇒ Object
- #para_attrs(node) ⇒ Object
- #para_parse(node, out) ⇒ Object
- #quote_attribution(node, out) ⇒ Object
- #quote_parse(node, out) ⇒ Object
- #sourcecode_name_parse(_node, div, name) ⇒ Object
- #sourcecode_parse(node, out) ⇒ Object
Instance Method Details
#admonition_parse(node, out) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/isodoc/function/blocks.rb', line 131 def admonition_parse(node, out) name = node["type"] out.div **{ class: "Admonition" } do |t| t.title { |b| b << @admonition[name].upcase } if name node.children.each do |n| parse(n, t) end end end |
#annotation_parse(node, out) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/isodoc/function/blocks.rb', line 121 def annotation_parse(node, out) @sourcecode = false @annotation = true out.span **{ class: "zzMoveToFollowing" } do |s| s << "<#{node.at(ns("//callout[@target='#{node['id']}']")).text}> " end node.children.each { |n| parse(n, out) } @annotation = false end |
#example_div_parse(node, out) ⇒ Object
used if we are boxing examples
81 82 83 84 85 86 87 88 |
# File 'lib/isodoc/function/blocks.rb', line 81 def example_div_parse(node, out) out.div **attr_code(id: node["id"], class: "example") do |div| out.p { |p| p << example_label(node) } node.children.each do |n| parse(n, div) end end end |
#example_label(node) ⇒ Object
70 71 72 73 74 |
# File 'lib/isodoc/function/blocks.rb', line 70 def example_label(node) n = get_anchors[node["id"]] return @example_lbl if n.nil? || n[:label].empty? l10n("#{@example_lbl} #{n[:label]}") end |
#example_parse(node, out) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/isodoc/function/blocks.rb', line 90 def example_parse(node, out) out.table **attr_code(id: node["id"], class: "example") do |t| t.tr do |tr| tr.td **EXAMPLE_TBL_ATTR do |td| td << example_label(node) end tr.td **{ valign: "top", class: "example" } do |td| node.children.each { |n| parse(n, td) } end end end end |
#figure_key(out) ⇒ Object
51 52 53 54 55 |
# File 'lib/isodoc/function/blocks.rb', line 51 def figure_key(out) out.p do |p| p.b { |b| b << @key_lbl } end end |
#figure_name_parse(node, div, name) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/isodoc/function/blocks.rb', line 44 def figure_name_parse(node, div, name) div.p **{ class: "FigureTitle", align: "center" } do |p| p << l10n("#{@figure_lbl} #{get_anchors[node['id']][:label]}") p << " — #{name.text}" if name end end |
#figure_parse(node, out) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/isodoc/function/blocks.rb', line 57 def figure_parse(node, out) @in_figure = true name = node.at(ns("./name")) out.div **attr_code(id: node["id"], class: "figure") do |div| node.children.each do |n| figure_key(out) if n.name == "dl" parse(n, div) unless n.name == "name" end figure_name_parse(node, div, name) if name end @in_figure = false end |
#formula_parse(node, out) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/isodoc/function/blocks.rb', line 147 def formula_parse(node, out) out.div **attr_code(id: node["id"], class: "formula") do |div| parse(node.at(ns("./stem")), out) insert_tab(div, 1) div << "(#{get_anchors[node['id']][:label]})" end formula_where(node.at(ns("./dl")), out) node.children.each do |n| next if %w(stem dl).include? n.name parse(n, out) end end |
#formula_where(dl, out) ⇒ Object
141 142 143 144 145 |
# File 'lib/isodoc/function/blocks.rb', line 141 def formula_where(dl, out) return unless dl out.p { |p| p << @where_lbl } parse(dl, out) end |
#image_parse(node, out, caption) ⇒ Object
210 211 212 213 214 215 216 |
# File 'lib/isodoc/function/blocks.rb', line 210 def image_parse(node, out, caption) attrs = { src: node["src"], height: node["height"] || "auto", width: node["width"] || "auto" } out.img **attr_code(attrs) image_title_parse(out, caption) end |
#image_title_parse(out, caption) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/isodoc/function/blocks.rb', line 202 def image_title_parse(out, caption) unless caption.nil? out.p **{ class: "FigureTitle", align: "center" } do |p| p.b { |b| b << caption.to_s } end end end |
#note_label(node) ⇒ Object
5 6 7 8 9 |
# File 'lib/isodoc/function/blocks.rb', line 5 def note_label(node) n = get_anchors[node["id"]] return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty? l10n("#{@note_lbl} #{n[:label]}") end |
#note_p_parse(node, div) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/function/blocks.rb', line 11 def note_p_parse(node, div) div.p do |p| p.span **{ class: "note_label" } do |s| s << note_label(node) end insert_tab(p, 1) node.first_element_child.children.each { |n| parse(n, p) } end node.element_children[1..-1].each { |n| parse(n, div) } end |
#note_parse(node, out) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/isodoc/function/blocks.rb', line 32 def note_parse(node, out) @note = true out.div **{ id: node["id"], class: "Note" } do |div| if node.first_element_child.name == "p" note_p_parse(node, div) else note_parse1(node, div) end end @note = false end |
#note_parse1(node, div) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/isodoc/function/blocks.rb', line 22 def note_parse1(node, div) div.p do |p| p.span **{ class: "note_label" } do |s| s << note_label(node) end insert_tab(p, 1) end node.children.each { |n| parse(n, div) } end |
#para_attrs(node) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/isodoc/function/blocks.rb', line 160 def para_attrs(node) classtype = nil classtype = "MsoCommentText" if in_comment classtype = "Sourcecode" if @annotation attrs = { class: classtype, id: node["id"] } unless node["align"].nil? attrs[:align] = node["align"] unless node["align"] == "justify" attrs[:style] = "text-align:#{node['align']}" end attrs end |
#para_parse(node, out) ⇒ Object
172 173 174 175 176 177 178 179 180 |
# File 'lib/isodoc/function/blocks.rb', line 172 def para_parse(node, out) out.p **attr_code(para_attrs(node)) do |p| unless @termdomain.empty? p << "<#{@termdomain}> " @termdomain = "" end node.children.each { |n| parse(n, p) } end end |
#quote_attribution(node, out) ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/isodoc/function/blocks.rb', line 182 def quote_attribution(node, out) = node.at(ns("./author")) source = node.at(ns("./source")) out.p **{ class: "QuoteAttribution" } do |p| p << "— #{.text}, " if eref_parse(source, p) if source end end |
#quote_parse(node, out) ⇒ Object
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/isodoc/function/blocks.rb', line 191 def quote_parse(node, out) attrs = para_attrs(node) attrs[:class] = "Quote" out.div **attr_code(attrs) do |p| node.children.each do |n| parse(n, p) unless ["author", "source"].include? n.name end quote_attribution(node, out) end end |
#sourcecode_name_parse(_node, div, name) ⇒ Object
103 104 105 106 107 |
# File 'lib/isodoc/function/blocks.rb', line 103 def sourcecode_name_parse(_node, div, name) div.p **{ class: "FigureTitle", align: "center" } do |p| p << name.text end end |
#sourcecode_parse(node, out) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/isodoc/function/blocks.rb', line 109 def sourcecode_parse(node, out) name = node.at(ns("./name")) out.p **attr_code(id: node["id"], class: "Sourcecode") do |div| @sourcecode = true node.children.each do |n| parse(n, div) unless n.name == "name" end @sourcecode = false sourcecode_name_parse(node, div, name) if name end end |