asciidoctor 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- data/Gemfile +2 -0
- data/README.asciidoc +35 -26
- data/Rakefile +9 -6
- data/asciidoctor.gemspec +27 -8
- data/bin/asciidoctor +1 -1
- data/lib/asciidoctor.rb +351 -63
- data/lib/asciidoctor/abstract_block.rb +218 -0
- data/lib/asciidoctor/abstract_node.rb +249 -0
- data/lib/asciidoctor/attribute_list.rb +211 -0
- data/lib/asciidoctor/backends/base_template.rb +99 -0
- data/lib/asciidoctor/backends/docbook45.rb +510 -0
- data/lib/asciidoctor/backends/html5.rb +585 -0
- data/lib/asciidoctor/block.rb +27 -254
- data/lib/asciidoctor/callouts.rb +117 -0
- data/lib/asciidoctor/debug.rb +7 -4
- data/lib/asciidoctor/document.rb +229 -77
- data/lib/asciidoctor/inline.rb +29 -0
- data/lib/asciidoctor/lexer.rb +1330 -502
- data/lib/asciidoctor/list_item.rb +33 -34
- data/lib/asciidoctor/reader.rb +305 -142
- data/lib/asciidoctor/renderer.rb +115 -19
- data/lib/asciidoctor/section.rb +100 -189
- data/lib/asciidoctor/substituters.rb +468 -0
- data/lib/asciidoctor/table.rb +499 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/test/attributes_test.rb +301 -87
- data/test/blocks_test.rb +568 -0
- data/test/document_test.rb +221 -24
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +1 -0
- data/test/fixtures/include-file.asciidoc +1 -0
- data/test/fixtures/tip.gif +0 -0
- data/test/headers_test.rb +411 -43
- data/test/lexer_test.rb +265 -45
- data/test/links_test.rb +144 -3
- data/test/lists_test.rb +2252 -74
- data/test/paragraphs_test.rb +21 -30
- data/test/preamble_test.rb +24 -0
- data/test/reader_test.rb +248 -12
- data/test/renderer_test.rb +22 -0
- data/test/substitutions_test.rb +414 -0
- data/test/tables_test.rb +484 -0
- data/test/test_helper.rb +70 -6
- data/test/text_test.rb +30 -6
- metadata +64 -10
- data/lib/asciidoctor/render_templates.rb +0 -317
- data/lib/asciidoctor/string.rb +0 -12
data/test/test_helper.rb
CHANGED
@@ -3,7 +3,11 @@ require 'test/unit'
|
|
3
3
|
|
4
4
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/asciidoctor.rb"
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
|
+
require 'mocha/setup'
|
8
|
+
rescue LoadError
|
9
|
+
require 'mocha'
|
10
|
+
end
|
7
11
|
require 'htmlentities'
|
8
12
|
require 'nokogiri'
|
9
13
|
require 'pending'
|
@@ -49,26 +53,86 @@ class Test::Unit::TestCase
|
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
56
|
+
def xmlnodes_at_css(css, content, count = nil)
|
57
|
+
xmlnodes_at_path(:css, css, content)
|
58
|
+
end
|
59
|
+
|
60
|
+
def xmlnodes_at_xpath(css, content, count = nil)
|
61
|
+
xmlnodes_at_path(:xpath, css, content)
|
62
|
+
end
|
63
|
+
|
64
|
+
def xmlnodes_at_path(type, path, content, count = nil)
|
65
|
+
doc = xmldoc_from_string content
|
66
|
+
case type
|
67
|
+
when :xpath
|
68
|
+
results = doc.xpath("#{path.sub('/', './')}")
|
69
|
+
when :css
|
70
|
+
results = doc.css(path)
|
71
|
+
end
|
72
|
+
count == 1 ? results.first : results
|
73
|
+
end
|
74
|
+
|
75
|
+
def assert_css(css, content, count = nil)
|
76
|
+
assert_path(:css, css, content, count)
|
77
|
+
end
|
78
|
+
|
79
|
+
def assert_xpath(xpath, content, count = nil)
|
80
|
+
assert_path(:xpath, xpath, content, count)
|
81
|
+
end
|
82
|
+
|
83
|
+
def assert_path(type, path, content, count = nil)
|
84
|
+
case type
|
85
|
+
when :xpath
|
86
|
+
type_name = 'XPath'
|
87
|
+
when :css
|
88
|
+
type_name = 'CSS'
|
89
|
+
end
|
90
|
+
|
91
|
+
results = xmlnodes_at_path type, path, content
|
55
92
|
|
56
93
|
if (count && results.length != count)
|
57
|
-
flunk "
|
94
|
+
flunk "#{type_name} #{path} yielded #{results.length} elements rather than #{count} for:\n#{content}"
|
58
95
|
elsif (count.nil? && results.empty?)
|
59
|
-
flunk "
|
96
|
+
flunk "#{type_name} #{path} not found in:\n#{content}"
|
60
97
|
else
|
61
98
|
assert true
|
62
99
|
end
|
63
100
|
end
|
64
101
|
|
102
|
+
def xmldoc_from_string(content)
|
103
|
+
match = content.match(/\s*<!DOCTYPE (.*)/)
|
104
|
+
if !match
|
105
|
+
doc = Nokogiri::HTML::DocumentFragment.parse(content)
|
106
|
+
elsif match[1].start_with? 'html'
|
107
|
+
doc = Nokogiri::HTML::Document.parse(content)
|
108
|
+
else
|
109
|
+
doc = Nokogiri::XML::Document.parse(content)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
65
113
|
def document_from_string(src, opts = {})
|
66
114
|
Asciidoctor::Document.new(src.lines.entries, opts)
|
67
115
|
end
|
68
116
|
|
117
|
+
def block_from_string(src, opts = {})
|
118
|
+
opts[:header_footer] = false
|
119
|
+
doc = Asciidoctor::Document.new(src.lines.entries, opts)
|
120
|
+
doc.blocks.first
|
121
|
+
end
|
122
|
+
|
69
123
|
def render_string(src, opts = {})
|
70
124
|
document_from_string(src, opts).render
|
71
125
|
end
|
126
|
+
|
127
|
+
def render_embedded_string(src, opts = {})
|
128
|
+
opts[:header_footer] = false
|
129
|
+
document_from_string(src, opts).render
|
130
|
+
end
|
131
|
+
|
132
|
+
def parse_header_metadata(source)
|
133
|
+
reader = Asciidoctor::Reader.new source.lines.entries
|
134
|
+
[Asciidoctor::Lexer.parse_header_metadata(reader), reader]
|
135
|
+
end
|
72
136
|
end
|
73
137
|
|
74
138
|
###
|
data/test/text_test.rb
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
context "Text" do
|
4
|
+
test "proper encoding to handle utf8 characters in document" do
|
5
|
+
assert_xpath "//p", example_document(:encoding).render, 1
|
6
|
+
end
|
7
|
+
|
8
|
+
test "proper encoding to handle utf8 characters in embedded document" do
|
9
|
+
assert_xpath "//p", example_document(:encoding).render(:header_footer => false), 1
|
10
|
+
end
|
11
|
+
|
12
|
+
# NOTE this test ensures we have the encoding line on block templates too
|
13
|
+
test "proper encoding to handle utf8 characters in arbitrary block" do
|
14
|
+
input = []
|
15
|
+
input << "[verse]\n"
|
16
|
+
input.concat(File.readlines(sample_doc_path(:encoding)))
|
17
|
+
doc = Asciidoctor::Document.new
|
18
|
+
reader = Asciidoctor::Reader.new input
|
19
|
+
block = Asciidoctor::Lexer.next_block(reader, doc)
|
20
|
+
assert_xpath '//pre', block.render.gsub(/^\s*\n/, ''), 1
|
21
|
+
end
|
22
|
+
|
4
23
|
test 'escaped text markup' do
|
5
|
-
|
24
|
+
assert_match(/All your <em>inline<\/em> markup belongs to <strong>us<\/strong>!/,
|
25
|
+
render_string('All your <em>inline</em> markup belongs to <strong>us</strong>!'))
|
6
26
|
end
|
7
27
|
|
8
28
|
test "line breaks" do
|
@@ -11,8 +31,8 @@ context "Text" do
|
|
11
31
|
|
12
32
|
test "single- and double-quoted text" do
|
13
33
|
rendered = render_string("``Where?,'' she said, flipping through her copy of `The New Yorker.'")
|
14
|
-
assert_match
|
15
|
-
assert_match
|
34
|
+
assert_match(/“Where\?,”/, rendered)
|
35
|
+
assert_match(/‘The New Yorker.’/, rendered)
|
16
36
|
end
|
17
37
|
|
18
38
|
test "separator" do
|
@@ -24,11 +44,15 @@ context "Text" do
|
|
24
44
|
assert_xpath "//em", render_string("An 'emphatic' no")
|
25
45
|
end
|
26
46
|
|
47
|
+
test "emphasized text with single quote" do
|
48
|
+
assert_xpath "//em[text()=\"Johnny#{[8217].pack('U*')}s\"]", render_string("It's 'Johnny's' phone")
|
49
|
+
end
|
50
|
+
|
27
51
|
test "emphasized text with escaped single quote" do
|
28
52
|
assert_xpath "//em[text()=\"Johnny's\"]", render_string("It's 'Johnny\\'s' phone")
|
29
53
|
end
|
30
54
|
|
31
|
-
test "escaped single quote is
|
55
|
+
test "escaped single quote is restored as single quote" do
|
32
56
|
assert_xpath "//p[contains(text(), \"Let's do it!\")]", render_string("Let\\'s do it!")
|
33
57
|
end
|
34
58
|
|
@@ -45,11 +69,11 @@ context "Text" do
|
|
45
69
|
end
|
46
70
|
|
47
71
|
test "unquoted text" do
|
48
|
-
assert_no_match
|
72
|
+
assert_no_match(/#/, render_string("An #unquoted# word"))
|
49
73
|
end
|
50
74
|
|
51
75
|
test "backtick-escaped text followed by single-quoted text" do
|
52
|
-
assert_match
|
76
|
+
assert_match(/<tt>foo<\/tt>/, render_string(%Q(run `foo` 'dog')))
|
53
77
|
end
|
54
78
|
|
55
79
|
context "basic styling" do
|
metadata
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Waldron
|
9
|
+
- Dan Allen
|
9
10
|
- Jeremy McAnally
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
+
name: coderay
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
18
19
|
none: false
|
19
20
|
requirements:
|
20
21
|
- - ! '>='
|
21
22
|
- !ruby/object:Gem::Version
|
22
23
|
version: '0'
|
23
|
-
type: :
|
24
|
+
type: :development
|
24
25
|
prerelease: false
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
26
27
|
none: false
|
@@ -29,14 +30,30 @@ dependencies:
|
|
29
30
|
- !ruby/object:Gem::Version
|
30
31
|
version: '0'
|
31
32
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
33
|
+
name: erubis
|
33
34
|
requirement: !ruby/object:Gem::Requirement
|
34
35
|
none: false
|
35
36
|
requirements:
|
36
37
|
- - ! '>='
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
|
-
type: :
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: htmlentities
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
40
57
|
prerelease: false
|
41
58
|
version_requirements: !ruby/object:Gem::Requirement
|
42
59
|
none: false
|
@@ -77,7 +94,7 @@ dependencies:
|
|
77
94
|
- !ruby/object:Gem::Version
|
78
95
|
version: '0'
|
79
96
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
97
|
+
name: pending
|
81
98
|
requirement: !ruby/object:Gem::Requirement
|
82
99
|
none: false
|
83
100
|
requirements:
|
@@ -93,7 +110,23 @@ dependencies:
|
|
93
110
|
- !ruby/object:Gem::Version
|
94
111
|
version: '0'
|
95
112
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
113
|
+
name: rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: tilt
|
97
130
|
requirement: !ruby/object:Gem::Requirement
|
98
131
|
none: false
|
99
132
|
requirements:
|
@@ -117,31 +150,45 @@ extensions: []
|
|
117
150
|
extra_rdoc_files:
|
118
151
|
- LICENSE
|
119
152
|
files:
|
153
|
+
- Gemfile
|
120
154
|
- LICENSE
|
121
155
|
- README.asciidoc
|
122
156
|
- Rakefile
|
123
157
|
- asciidoctor.gemspec
|
124
158
|
- bin/asciidoctor
|
125
159
|
- lib/asciidoctor.rb
|
160
|
+
- lib/asciidoctor/abstract_block.rb
|
161
|
+
- lib/asciidoctor/abstract_node.rb
|
162
|
+
- lib/asciidoctor/attribute_list.rb
|
163
|
+
- lib/asciidoctor/backends/base_template.rb
|
164
|
+
- lib/asciidoctor/backends/docbook45.rb
|
165
|
+
- lib/asciidoctor/backends/html5.rb
|
126
166
|
- lib/asciidoctor/block.rb
|
167
|
+
- lib/asciidoctor/callouts.rb
|
127
168
|
- lib/asciidoctor/debug.rb
|
128
169
|
- lib/asciidoctor/document.rb
|
129
170
|
- lib/asciidoctor/errors.rb
|
171
|
+
- lib/asciidoctor/inline.rb
|
130
172
|
- lib/asciidoctor/lexer.rb
|
131
173
|
- lib/asciidoctor/list_item.rb
|
132
174
|
- lib/asciidoctor/reader.rb
|
133
|
-
- lib/asciidoctor/render_templates.rb
|
134
175
|
- lib/asciidoctor/renderer.rb
|
135
176
|
- lib/asciidoctor/section.rb
|
136
|
-
- lib/asciidoctor/
|
177
|
+
- lib/asciidoctor/substituters.rb
|
178
|
+
- lib/asciidoctor/table.rb
|
137
179
|
- lib/asciidoctor/version.rb
|
138
180
|
- noof.rb
|
139
181
|
- test/attributes_test.rb
|
182
|
+
- test/blocks_test.rb
|
140
183
|
- test/document_test.rb
|
141
184
|
- test/fixtures/asciidoc.txt
|
142
185
|
- test/fixtures/asciidoc_index.txt
|
143
186
|
- test/fixtures/ascshort.txt
|
187
|
+
- test/fixtures/dot.gif
|
188
|
+
- test/fixtures/encoding.asciidoc
|
189
|
+
- test/fixtures/include-file.asciidoc
|
144
190
|
- test/fixtures/list_elements.asciidoc
|
191
|
+
- test/fixtures/tip.gif
|
145
192
|
- test/headers_test.rb
|
146
193
|
- test/lexer_test.rb
|
147
194
|
- test/links_test.rb
|
@@ -149,6 +196,9 @@ files:
|
|
149
196
|
- test/paragraphs_test.rb
|
150
197
|
- test/preamble_test.rb
|
151
198
|
- test/reader_test.rb
|
199
|
+
- test/renderer_test.rb
|
200
|
+
- test/substitutions_test.rb
|
201
|
+
- test/tables_test.rb
|
152
202
|
- test/test_helper.rb
|
153
203
|
- test/text_test.rb
|
154
204
|
homepage: http://github.com/erebor/asciidoctor
|
@@ -178,6 +228,7 @@ specification_version: 2
|
|
178
228
|
summary: Pure Ruby Asciidoc to HTML rendering.
|
179
229
|
test_files:
|
180
230
|
- test/attributes_test.rb
|
231
|
+
- test/blocks_test.rb
|
181
232
|
- test/document_test.rb
|
182
233
|
- test/headers_test.rb
|
183
234
|
- test/lexer_test.rb
|
@@ -186,4 +237,7 @@ test_files:
|
|
186
237
|
- test/paragraphs_test.rb
|
187
238
|
- test/preamble_test.rb
|
188
239
|
- test/reader_test.rb
|
240
|
+
- test/renderer_test.rb
|
241
|
+
- test/substitutions_test.rb
|
242
|
+
- test/tables_test.rb
|
189
243
|
- test/text_test.rb
|
@@ -1,317 +0,0 @@
|
|
1
|
-
class BaseTemplate
|
2
|
-
def initialize
|
3
|
-
end
|
4
|
-
|
5
|
-
def self.inherited(klass)
|
6
|
-
@template_classes ||= []
|
7
|
-
@template_classes << klass
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.template_classes
|
11
|
-
@template_classes
|
12
|
-
end
|
13
|
-
|
14
|
-
# We're ignoring locals for now. Shut up.
|
15
|
-
def render(obj = Object.new, locals = {})
|
16
|
-
output = template.result(obj.instance_eval {binding})
|
17
|
-
end
|
18
|
-
|
19
|
-
def template
|
20
|
-
raise "You chilluns need to make your own template"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class DocumentTemplate < BaseTemplate
|
25
|
-
def template
|
26
|
-
@template ||= ::ERB.new <<-EOF
|
27
|
-
<!DOCTYPE html>
|
28
|
-
<html lang='en'>
|
29
|
-
<head>
|
30
|
-
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
|
31
|
-
<meta name='generator' content='Asciidoctor <%= attr "asciidoctor-version" %>'>
|
32
|
-
<title><%= title ? title : (doctitle ? doctitle : '') %></title>
|
33
|
-
</head>
|
34
|
-
<body class='<%= attr :doctype %>'>
|
35
|
-
<div id='header'>
|
36
|
-
<% if doctitle %>
|
37
|
-
<h1><%= doctitle %></h1>
|
38
|
-
<% end %>
|
39
|
-
</div>
|
40
|
-
<div id='content'>
|
41
|
-
<%= content %>
|
42
|
-
</div>
|
43
|
-
<div id='footer'>
|
44
|
-
<div id='footer-text'>
|
45
|
-
Last updated <%= attr :localdatetime %>
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
</body>
|
49
|
-
</html>
|
50
|
-
EOF
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class SectionPreambleTemplate < BaseTemplate
|
55
|
-
def template
|
56
|
-
@template ||= ::ERB.new <<-EOF
|
57
|
-
<div id='preamble'>
|
58
|
-
<div class='sectionbody'>
|
59
|
-
<%= content %>
|
60
|
-
</div>
|
61
|
-
</div>
|
62
|
-
EOF
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class SectionTemplate < BaseTemplate
|
67
|
-
def template
|
68
|
-
@template ||= ERB.new <<-EOF
|
69
|
-
<div class='sect<%= level %>'>
|
70
|
-
<% if !anchor.nil? %>
|
71
|
-
<a name='<%= anchor %>'></a>
|
72
|
-
<% end %>
|
73
|
-
<h<%= level + 1 %> id='<%= section_id %>'><%= name %></h<%= level + 1 %>>
|
74
|
-
<% if level == 1 %>
|
75
|
-
<div class='sectionbody'><%= content %></div>
|
76
|
-
<% else %>
|
77
|
-
<%= content %>
|
78
|
-
<% end %>
|
79
|
-
</div>
|
80
|
-
EOF
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
class SectionAnchorTemplate < BaseTemplate
|
85
|
-
def template
|
86
|
-
@template ||= ERB.new <<-EOF
|
87
|
-
<a name='<%= content %>'></a>
|
88
|
-
EOF
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class SectionDlistTemplate < BaseTemplate
|
93
|
-
def template
|
94
|
-
@template ||= ERB.new <<-EOF
|
95
|
-
<div class='dlist'>
|
96
|
-
<dl>
|
97
|
-
<% content.each do |dt, dd| %>
|
98
|
-
<dt class='hdlist1'>
|
99
|
-
<% if !dt.anchor.nil? and !dt.anchor.empty? %>
|
100
|
-
<a id='<%= dt.anchor %>'></a>
|
101
|
-
<% end %>
|
102
|
-
<%= dt.text %>
|
103
|
-
</dt>
|
104
|
-
<% unless dd.nil? %>
|
105
|
-
<dd>
|
106
|
-
<p><%= dd.text %></p>
|
107
|
-
<% if !dd.blocks.empty? %>
|
108
|
-
<%= dd.content %>
|
109
|
-
<% end %>
|
110
|
-
</dd>
|
111
|
-
<% end %>
|
112
|
-
<% end %>
|
113
|
-
</dl>
|
114
|
-
</div>
|
115
|
-
EOF
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class SectionListingTemplate < BaseTemplate
|
120
|
-
def template
|
121
|
-
@template ||= ERB.new <<-EOF
|
122
|
-
<div class='listingblock'>
|
123
|
-
<div class='content'>
|
124
|
-
<div class='highlight'>
|
125
|
-
<pre><%= content %></pre>
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
EOF
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
class SectionLiteralTemplate < BaseTemplate
|
134
|
-
def template
|
135
|
-
@template ||= ERB.new <<-EOF
|
136
|
-
<div class='literalblock'>
|
137
|
-
<div class='content'>
|
138
|
-
<pre><tt><%= content %></tt></pre>
|
139
|
-
</div>
|
140
|
-
</div>
|
141
|
-
EOF
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class SectionAdmonitionTemplate < BaseTemplate
|
146
|
-
def template
|
147
|
-
@template ||= ERB.new <<-EOF
|
148
|
-
<div class='admonitionblock'>
|
149
|
-
<table>
|
150
|
-
<tr>
|
151
|
-
<td class='icon'>
|
152
|
-
<% if attr? :caption %>
|
153
|
-
<div class='title'><%= attr :caption %></div>
|
154
|
-
<% end %>
|
155
|
-
</td>
|
156
|
-
<td class='content'>
|
157
|
-
<% if !title.nil? %>
|
158
|
-
<div class='title'><%= title %></div>
|
159
|
-
<% end %>
|
160
|
-
<%= content %>
|
161
|
-
</td>
|
162
|
-
</tr>
|
163
|
-
</table>
|
164
|
-
</div>
|
165
|
-
EOF
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
class SectionParagraphTemplate < BaseTemplate
|
170
|
-
def template
|
171
|
-
@template ||= ERB.new <<-EOF
|
172
|
-
<div class='paragraph'>
|
173
|
-
<% if !title.nil? %>
|
174
|
-
<div class='title'><%= title %></div>
|
175
|
-
<% end %>
|
176
|
-
<p><%= content %></p>
|
177
|
-
</div>
|
178
|
-
EOF
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
class SectionSidebarTemplate < BaseTemplate
|
183
|
-
def template
|
184
|
-
@template ||= ERB.new <<-EOF
|
185
|
-
<div class='sidebarblock'>
|
186
|
-
<div class='content'>
|
187
|
-
<% if !title.nil? %>
|
188
|
-
<div class='title'><%= title %></div>
|
189
|
-
<% end %>
|
190
|
-
<%= content %>
|
191
|
-
</div>
|
192
|
-
</div>
|
193
|
-
EOF
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class SectionExampleTemplate < BaseTemplate
|
198
|
-
def template
|
199
|
-
@template ||= ERB.new <<-EOF
|
200
|
-
<div class='exampleblock'>
|
201
|
-
<div class='content'>
|
202
|
-
<% if !title.nil? %>
|
203
|
-
<div class='title'><%= title %></div>
|
204
|
-
<% end %>
|
205
|
-
<%= content %>
|
206
|
-
</div>
|
207
|
-
</div>
|
208
|
-
EOF
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
class SectionQuoteTemplate < BaseTemplate
|
213
|
-
def template
|
214
|
-
@template ||= ERB.new <<-EOF
|
215
|
-
<div class='quoteblock'>
|
216
|
-
<% if !title.nil? %>
|
217
|
-
<div class='title'><%= title %></div>
|
218
|
-
<% end %>
|
219
|
-
<div class='content'>
|
220
|
-
<%= content %>
|
221
|
-
</div>
|
222
|
-
<div class='attribution'>
|
223
|
-
<% if attr? :citetitle %>
|
224
|
-
<em><%= attr :citetitle %></em>
|
225
|
-
<% end %>
|
226
|
-
<% if attr? :attribution %>
|
227
|
-
<% if attr? :citetitle %>
|
228
|
-
<br/>
|
229
|
-
<% end %>
|
230
|
-
<%= "— " + attr(:attribution) %>
|
231
|
-
<% end %>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
EOF
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
class SectionVerseTemplate < BaseTemplate
|
239
|
-
def template
|
240
|
-
@template ||= ERB.new <<-EOF
|
241
|
-
<div class='verseblock'>
|
242
|
-
<% if !title.nil? %>
|
243
|
-
<div class='title'><%= title %></div>
|
244
|
-
<% end %>
|
245
|
-
<pre class='content'><%= content %></pre>
|
246
|
-
<div class='attribution'>
|
247
|
-
<% if attr? :citetitle %>
|
248
|
-
<em><%= attr :citetitle %></em>
|
249
|
-
<% end %>
|
250
|
-
<% if attr? :attribution %>
|
251
|
-
<% if attr? :citetitle %>
|
252
|
-
<br/>
|
253
|
-
<% end %>
|
254
|
-
<%= "— " + attr(:attribution) %>
|
255
|
-
<% end %>
|
256
|
-
</div>
|
257
|
-
</div>
|
258
|
-
EOF
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
class SectionUlistTemplate < BaseTemplate
|
263
|
-
def template
|
264
|
-
@template ||= ERB.new <<-EOF
|
265
|
-
<div class='ulist'>
|
266
|
-
<ul>
|
267
|
-
<% content.each do |li| %>
|
268
|
-
<li>
|
269
|
-
<p><%= li.text %></p>
|
270
|
-
<% if !li.blocks.empty? %>
|
271
|
-
<%= li.content %>
|
272
|
-
<% end %>
|
273
|
-
</li>
|
274
|
-
<% end %>
|
275
|
-
</ul>
|
276
|
-
</div>
|
277
|
-
EOF
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
class SectionOlistTemplate < BaseTemplate
|
282
|
-
def template
|
283
|
-
@template ||= ERB.new <<-EOF
|
284
|
-
<div class='olist arabic'>
|
285
|
-
<ol class='arabic'>
|
286
|
-
<% content.each do |li| %>
|
287
|
-
<li>
|
288
|
-
<p><%= li.text %></p>
|
289
|
-
<% if !li.blocks.empty? %>
|
290
|
-
<%= li.content %>
|
291
|
-
<% end %>
|
292
|
-
</li>
|
293
|
-
<% end %>
|
294
|
-
</ol>
|
295
|
-
</div>
|
296
|
-
EOF
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
class SectionImageTemplate < BaseTemplate
|
301
|
-
def template
|
302
|
-
@template ||= ERB.new <<-EOF
|
303
|
-
<div class='imageblock'>
|
304
|
-
<div class='content'>
|
305
|
-
<% if attr :link %>
|
306
|
-
<a class='image' href='<%= attr :link%>'><img src='<%= attr :target %>' alt='<%= attr :alt %>'/></a>
|
307
|
-
<% else %>
|
308
|
-
<img src='<%= attr :target %>' alt='<%= attr :alt %>'/>
|
309
|
-
<% end %>
|
310
|
-
</div>
|
311
|
-
<% if title %>
|
312
|
-
<div class='title'><%= title %></div>
|
313
|
-
<% end %>
|
314
|
-
</div>
|
315
|
-
EOF
|
316
|
-
end
|
317
|
-
end
|