Class SM::ToFlow
In: markup/simple_markup/to_flow.rb
Parent: Object

Methods

Constants

LIST_TYPE_TO_HTML = { SM::ListBase::BULLET => [ "<ul>", "</ul>" ], SM::ListBase::NUMBER => [ "<ol>", "</ol>" ], SM::ListBase::UPPERALPHA => [ "<ol>", "</ol>" ], SM::ListBase::LOWERALPHA => [ "<ol>", "</ol>" ], SM::ListBase::LABELED => [ "<dl>", "</dl>" ], SM::ListBase::NOTE => [ "<table>", "</table>" ], }
InlineTag = Struct.new(:bit, :on, :off)

Public Class methods

[Source]

    # File markup/simple_markup/to_flow.rb, line 37
37:     def initialize
38:       init_tags
39:     end

Public Instance methods

[Source]

     # File markup/simple_markup/to_flow.rb, line 111
111:     def accept_blank_line(am, fragment)
112:       # @res << annotate("<p />") << "\n"
113:     end

[Source]

     # File markup/simple_markup/to_flow.rb, line 115
115:     def accept_heading(am, fragment)
116:       @res << Flow::H.new(fragment.head_level, convert_flow(am.flow(fragment.txt)))
117:     end

[Source]

     # File markup/simple_markup/to_flow.rb, line 103
103:     def accept_list_end(am, fragment)
104:       @res = @list_stack.pop
105:     end

[Source]

     # File markup/simple_markup/to_flow.rb, line 107
107:     def accept_list_item(am, fragment)
108:       @res << Flow::LI.new(fragment.param, convert_flow(am.flow(fragment.txt)))
109:     end

[Source]

     # File markup/simple_markup/to_flow.rb, line 96
 96:     def accept_list_start(am, fragment)
 97:       @list_stack.push(@res)
 98:       list = Flow::LIST.new(fragment.type)
 99:       @res << list
100:       @res = list
101:     end

[Source]

    # File markup/simple_markup/to_flow.rb, line 82
82:     def accept_paragraph(am, fragment)
83:       @res << Flow::P.new((convert_flow(am.flow(fragment.txt))))
84:     end

[Source]

    # File markup/simple_markup/to_flow.rb, line 90
90:     def accept_rule(am, fragment)
91:       size = fragment.param
92:       size = 10 if size > 10
93:       @res << Flow::RULE.new(size)
94:     end

[Source]

    # File markup/simple_markup/to_flow.rb, line 86
86:     def accept_verbatim(am, fragment)
87:       @res << Flow::VERB.new((convert_flow(am.flow(fragment.txt))))
88:     end

Add a new set of HTML tags for an attribute. We allow separate start and end tags for flexibility

[Source]

    # File markup/simple_markup/to_flow.rb, line 56
56:     def add_tag(name, start, stop)
57:       @attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
58:     end

Given an HTML tag, decorate it with class information and the like if required. This is a no-op in the base class, but is overridden in HTML output classes that implement style sheets

[Source]

    # File markup/simple_markup/to_flow.rb, line 66
66:     def annotate(tag)
67:       tag
68:     end

[Source]

    # File markup/simple_markup/to_flow.rb, line 78
78:     def end_accepting
79:       @res
80:     end

Set up the standard mapping of attributes to HTML tags

[Source]

    # File markup/simple_markup/to_flow.rb, line 44
44:     def init_tags
45:       @attr_tags = [
46:         InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
47:         InlineTag.new(SM::Attribute.bitmap_for(:TT),   "<tt>", "</tt>"),
48:         InlineTag.new(SM::Attribute.bitmap_for(:EM),   "<em>", "</em>"),
49:       ]
50:     end

Here‘s the client side of the visitor pattern

[Source]

    # File markup/simple_markup/to_flow.rb, line 73
73:     def start_accepting
74:       @res = []
75:       @list_stack = []
76:     end

[Validate]