Class: Asciidoctor::Html::Converter

Inherits:
Object
  • Object
show all
Includes:
Figure
Defined in:
lib/asciidoctor/html/converter.rb

Overview

A custom HTML5 converter that plays nicely with Bootstrap CSS

Instance Method Summary collapse

Methods included from Figure

#convert_figlist, #display_figure, #display_image, #image_attrs

Instance Method Details

#convert_example(node) ⇒ Object



32
33
34
35
# File 'lib/asciidoctor/html/converter.rb', line 32

def convert_example(node)
  p node.context unless Utils.show_title?(node)
  Utils.wrap_node_with_title node.content, node, needs_prefix: true
end

#convert_image(node) ⇒ Object



37
38
39
40
41
42
# File 'lib/asciidoctor/html/converter.rb', line 37

def convert_image(node)
  return super if node.option?("inline") || node.option?("interactive")

  content = display_figure node
  Utils.wrap_id_classes content, node.id, ["figbox", node.role].compact.join(" ")
end

#convert_inline_image(node) ⇒ Object



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

def convert_inline_image(node)
  return super if node.option?("inline") || node.option?("interactive")

  target = node.target
  mark = node.parent.attr("mark")
  attrs = image_attrs node
  image = display_image node, target, attrs
  title = node.attr?("title") ? node.attr("title") : ""
  caption = mark ? %(<span class="li-mark">#{mark}</span>#{title}) : title
  %(    #{image}\n    <figcaption>#{caption}</figcaption>)
end

#convert_olist(node) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/asciidoctor/html/converter.rb', line 56

def convert_olist(node)
  return convert_figlist(node) if node.style == "figlist"

  depth = node.attr "list-depth"
  flat = node.attr? "flat-style"
  level = depth + 1
  classes = ["olist level-#{level}", flat ? "pseudocode" : node.style, node.role].compact.join(" ")
  result = [%(<ol#{Utils.dyn_id_class_attr_str node, classes}>)]
  node.items.each do |item|
    result << Olist.display_list_item(item)
  end
  result << %(</ol> <!-- .level-#{level} -->\n)
  Utils.wrap_id_classes_with_title result.join("\n"), node, node.id, "list-wrapper"
end

#convert_paragraph(node) ⇒ Object



27
28
29
30
# File 'lib/asciidoctor/html/converter.rb', line 27

def convert_paragraph(node)
  content = %(<p>#{node.content}</p>\n)
  Utils.wrap_node_with_title content, node
end

#convert_section(node) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/asciidoctor/html/converter.rb', line 16

def convert_section(node)
  document = node.document
  level = node.level
  show_sectnum = node.numbered && level <= (document.attr("sectnumlevels") || 1).to_i
  tag_name = %(h#{[level + 2, 6].min})
  sectnum = show_sectnum ? %(<span class="title-mark">#{node.sectnum ""}</span>) : ""
  content = %(<#{tag_name}>#{sectnum}#{node.title}) +
            %(</#{tag_name}>\n#{node.content})
  Utils.wrap_node content, node, :section
end