-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_builder.rb
79 lines (66 loc) · 1.47 KB
/
html_builder.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module Document
def toHtml(out)
elements.each {|element|
out.print(element.toHtml)
}
end
def toDesc(out)
elements.each {|element|
out.print(element.toDesc)
}
end
end
module Command
def toHtml
root = "http://minnenratta.files.wordpress.com/2010/11/"
return "<img src=\"" + root + parameters.get(0).toHtml + "\" />" if operation.toHtml == "includegraphics"
return "<h1>" + parameters.get(0).toHtml + "</h1>" if operation.toHtml == "section"
return "<h2>" + parameters.get(0).toHtml + "</h2>" if operation.toHtml == "subsection"
return "";
end
def toDesc
if defined?(options) && defined?(parameters)
return operation.toDesc + "[" + options.toDesc + "]" + "{" + parameters.toDesc + "}"
end
if defined? options
return operation.toDesc + "[" + options.toDesc + "]"
end
if defined? parameters
return operation.toDesc + "{" + parameters.toDesc + "}"
end
return operation.toDesc
end
end
module Parameters
def toHtml
return parameter.toHtml + '|' + parameters.toHtml
end
def toDesc
return parameter.toDesc + ',' + parameters.toDesc
end
def get(position)
return parameter if position <= 0
return parameters.get(--position)
end
end
module Parameter
def get(position)
return self
end
end
module Verbatim
def toHtml
return "<pre><code>" + verbatim_text.toHtml + "</code></pre>"
end
def toDesc
return verbatim_text.toDesc
end
end
module Text
def toHtml
return text_value
end
def toDesc
return text_value
end
end