Module: Asciidoctor::ISO::Blocks
- Included in:
- Converter
- Defined in:
- lib/asciidoctor/iso/blocks.rb
Instance Method Summary collapse
- #admonition(node) ⇒ Object
- #example(node) ⇒ Object
- #image(node) ⇒ Object
- #listing(node) ⇒ Object
- #preamble(node) ⇒ Object
- #quote(node) ⇒ Object
- #section(node) ⇒ Object
- #sidebar(node) ⇒ Object
- #stem(node) ⇒ Object
- #term_example(node) ⇒ Object
- #termnote(node) ⇒ Object
Instance Method Details
#admonition(node) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/asciidoctor/iso/blocks.rb', line 48 def admonition(node) return termnote(node) if $term_def noko do |xml| xml.note **attr_code(anchor: node.id) do |xml_cref| if node.blocks? xml_cref << node.content else xml_cref.p { |p| p << node.content } end end end.join end |
#example(node) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/asciidoctor/iso/blocks.rb', line 69 def example(node) return term_example(node) if $term_def noko do |xml| xml.example **attr_code(anchor: node.id) do |ex| ex << node.content end end.join end |
#image(node) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/asciidoctor/iso/blocks.rb', line 145 def image(node) uri = node.image_uri node.attr("target") artwork_attributes = { anchor: node.id, src: uri, } noko do |xml| xml.figure **attr_code(artwork_attributes) do |f| f.name { |name| name << node.title } unless node.title.nil? end end end |
#listing(node) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/asciidoctor/iso/blocks.rb', line 171 def listing(node) # NOTE: html escaping is performed by Nokogiri noko do |xml| if node.parent.context != :example xml.figure do |xml_figure| xml_figure.sourcecode { |s| s << node.content } end else xml.sourcecode { |s| s << node.content } end end end |
#preamble(node) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/asciidoctor/iso/blocks.rb', line 78 def preamble(node) result = [] result << noko do |xml| xml.foreword do |xml_abstract| xml_abstract << node.content end end result end |
#quote(node) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/asciidoctor/iso/blocks.rb', line 159 def quote(node) noko do |xml| xml.quote **attr_code(anchor: node.id) do |xml_blockquote| if node.blocks? xml_blockquote << node.content else xml_blockquote.p { |p| p << node.content } end end end end |
#section(node) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/asciidoctor/iso/blocks.rb', line 88 def section(node) attr = { anchor: node.id.empty? ? nil : node.id } noko do |xml| case node.title.downcase when "introduction" xml.introduction **attr_code(attr) do |xml_section| xml_section << node.content end when "patent notice" xml.patent_notice **attr_code(attr) do |xml_section| xml_section << node.content end when "scope" xml.scope **attr_code(attr) do |xml_section| xml_section << node.content end when "normative references" $norm_ref = true xml.norm_ref **attr_code(attr) do |xml_section| xml_section << node.content end $norm_ref = false when "terms and definitions" $term_def = true xml.terms_defs **attr_code(attr) do |xml_section| xml_section << node.content end $term_def = false when "bibliography" $biblio = true xml.bibliography **attr_code(attr) do |xml_section| xml_section << node.content end $biblio = true else if $term_def xml.termdef **attr_code(attr) do |xml_section| xml_section.term { |name| name << node.title } xml_section << node.content end elsif node.attr("style") == "appendix" xml.annex **attr_code(attr) do |xml_section| xml_section.name { |name| name << node.title } xml_section << node.content end else xml.clause **attr_code(attr) do |xml_section| unless node.title.nil? xml_section.name { |name| name << node.title } end xml_section << node.content end end end end.join end |
#sidebar(node) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/asciidoctor/iso/blocks.rb', line 21 def (node) if $draft note_attributes = { color: node.attr("color") ? node.attr("color") : "red", } content = flatten_rawtext(node.content).join("\n") noko do |xml| xml.review_note content, **attr_code(note_attributes) end end end |
#stem(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/asciidoctor/iso/blocks.rb', line 7 def stem(node) stem_attributes = { anchor: node.id, } # NOTE: html escaping is performed by Nokogiri stem_content = node.lines.join("\n") noko do |xml| xml.formula **attr_code(stem_attributes) do |s| s.stem stem_content end end end |
#term_example(node) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/asciidoctor/iso/blocks.rb', line 61 def term_example(node) noko do |xml| xml.termexample **attr_code(anchor: node.id) do |ex| ex << node.content end end.join end |
#termnote(node) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/asciidoctor/iso/blocks.rb', line 33 def termnote(node) note_attributes = { anchor: node.id } warn <<~WARNING_MESSAGE if node.blocks? asciidoctor: WARNING (#{current_location(node)}): \ comment can not contain blocks of text in XML RFC:\n #{node.content} WARNING_MESSAGE noko do |xml| xml.termnote **attr_code(note_attributes) do |xml_cref| xml_cref << node.content end end.join end |