asciidoctor 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/Guardfile +18 -0
- data/LICENSE +1 -1
- data/README.adoc +65 -21
- data/Rakefile +10 -0
- data/asciidoctor.gemspec +17 -35
- data/compat/asciidoc.conf +130 -13
- data/lib/asciidoctor.rb +107 -87
- data/lib/asciidoctor/abstract_block.rb +6 -2
- data/lib/asciidoctor/abstract_node.rb +21 -13
- data/lib/asciidoctor/attribute_list.rb +2 -5
- data/{stylesheets/asciidoctor.css → lib/asciidoctor/backends/_stylesheets.rb} +96 -46
- data/lib/asciidoctor/backends/base_template.rb +9 -4
- data/lib/asciidoctor/backends/docbook45.rb +246 -138
- data/lib/asciidoctor/backends/html5.rb +580 -381
- data/lib/asciidoctor/block.rb +2 -50
- data/lib/asciidoctor/cli/options.rb +9 -8
- data/lib/asciidoctor/document.rb +35 -45
- data/lib/asciidoctor/helpers.rb +10 -0
- data/lib/asciidoctor/lexer.rb +456 -148
- data/lib/asciidoctor/list_item.rb +0 -21
- data/lib/asciidoctor/path_resolver.rb +18 -12
- data/lib/asciidoctor/reader.rb +71 -26
- data/lib/asciidoctor/renderer.rb +2 -19
- data/lib/asciidoctor/section.rb +0 -1
- data/lib/asciidoctor/substituters.rb +150 -36
- data/lib/asciidoctor/table.rb +30 -24
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -16
- data/man/asciidoctor.ad +24 -16
- data/test/attributes_test.rb +50 -0
- data/test/blocks_test.rb +660 -9
- data/test/document_test.rb +191 -14
- data/test/fixtures/encoding.asciidoc +8 -0
- data/test/invoker_test.rb +47 -0
- data/test/lexer_test.rb +172 -0
- data/test/links_test.rb +28 -0
- data/test/lists_test.rb +172 -13
- data/test/options_test.rb +29 -2
- data/test/paragraphs_test.rb +105 -47
- data/test/paths_test.rb +3 -3
- data/test/reader_test.rb +46 -0
- data/test/sections_test.rb +365 -12
- data/test/substitutions_test.rb +127 -11
- data/test/tables_test.rb +81 -14
- data/test/test_helper.rb +18 -7
- data/test/text_test.rb +17 -5
- metadata +9 -36
@@ -1,147 +1,171 @@
|
|
1
|
+
require 'asciidoctor/backends/_stylesheets'
|
2
|
+
|
1
3
|
module Asciidoctor
|
2
4
|
class BaseTemplate
|
3
5
|
|
4
6
|
# create template matter to insert a style class from the role attribute if specified
|
5
7
|
def role_class
|
6
|
-
attrvalue(
|
8
|
+
attrvalue('role')
|
7
9
|
end
|
8
10
|
|
9
11
|
# create template matter to insert a style class from the style attribute if specified
|
10
12
|
def style_class(sibling = true)
|
11
|
-
attrvalue(
|
13
|
+
attrvalue('style', sibling, false)
|
12
14
|
end
|
13
15
|
|
14
16
|
def title_div(opts = {})
|
15
|
-
|
17
|
+
if opts.has_key? :caption
|
18
|
+
%q(<% if title? %><div class="title"><%= @caption %><%= title %></div><% end %>)
|
19
|
+
else
|
20
|
+
%q(<% if title? %><div class="title"><%= title %></div><% end %>)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
25
|
module HTML5
|
26
|
+
|
20
27
|
class DocumentTemplate < BaseTemplate
|
21
28
|
def self.outline(node, to_depth = 2)
|
22
29
|
toc_level = nil
|
23
30
|
sections = node.sections
|
24
31
|
unless sections.empty?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
nested = node.level > 0
|
31
|
-
else
|
32
|
-
indent = ' ' * node.level
|
33
|
-
end
|
32
|
+
# FIXME the level for special sections should be set correctly in the model
|
33
|
+
# sec_level will only be 0 if we have a book doctype with parts
|
34
|
+
sec_level = sections.first.level
|
35
|
+
if sec_level == 0 && sections.first.special
|
36
|
+
sec_level = 1
|
34
37
|
end
|
35
|
-
toc_level
|
38
|
+
toc_level = %(<ol type="none" class="sectlevel#{sec_level}">\n)
|
39
|
+
numbered = node.document.attr? 'numbered'
|
36
40
|
sections.each do |section|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
toc_level << "#{indent}#{child_toc_level}\n"
|
41
|
+
# need to check playback attributes for change in numbered setting
|
42
|
+
# FIXME encapsulate me
|
43
|
+
if section.attributes.has_key? :attribute_entries
|
44
|
+
if (numbered_override = section.attributes[:attribute_entries].find {|entry| entry.name == 'numbered'})
|
45
|
+
numbered = numbered_override.negate ? false : true
|
43
46
|
end
|
44
47
|
end
|
48
|
+
section_num = numbered && !section.special && section.level > 0 && section.level < 4 ? %(#{section.sectnum} ) : nil
|
49
|
+
toc_level = %(#{toc_level}<li><a href=\"##{section.id}\">#{section_num}#{section.caption}#{section.title}</a></li>\n)
|
50
|
+
if section.level < to_depth && (child_toc_level = outline(section, to_depth))
|
51
|
+
toc_level = %(#{toc_level}<li>\n#{child_toc_level}\n</li>\n)
|
52
|
+
end
|
45
53
|
end
|
46
|
-
toc_level
|
54
|
+
toc_level = %(#{toc_level}</ol>)
|
47
55
|
end
|
48
56
|
toc_level
|
49
57
|
end
|
50
58
|
|
51
|
-
# Internal: Generate the default stylesheet for CodeRay
|
52
|
-
#
|
53
|
-
# returns the default CodeRay stylesheet as a String
|
54
|
-
def self.default_coderay_stylesheet
|
55
|
-
Helpers.require_library 'coderay'
|
56
|
-
::CodeRay::Encoders[:html]::CSS.new(:default).stylesheet
|
57
|
-
end
|
58
|
-
|
59
59
|
def template
|
60
60
|
@template ||= @eruby.new <<-EOS
|
61
61
|
<%#encoding:UTF-8%><!DOCTYPE html>
|
62
|
-
<html
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<%=
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<%= read_asset normalize_system_path(attr
|
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
|
-
|
62
|
+
<html<%= !(attr? 'nolang') ? %( lang="\#{attr 'lang', 'en'}") : nil %>>
|
63
|
+
<head>
|
64
|
+
<meta http-equiv="Content-Type" content="text/html; charset=<%= attr :encoding %>">
|
65
|
+
<meta name="generator" content="Asciidoctor <%= attr 'asciidoctor-version' %>">
|
66
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"><%
|
67
|
+
if attr? :description %>
|
68
|
+
<meta name="description" content="<%= attr :description %>"><%
|
69
|
+
end
|
70
|
+
if attr? :keywords %>
|
71
|
+
<meta name="keywords" content="<%= attr :keywords %>"><%
|
72
|
+
end %>
|
73
|
+
<title><%= doctitle %></title><%
|
74
|
+
if DEFAULT_STYLESHEET_KEYS.include?(attr 'stylesheet')
|
75
|
+
if @safe >= SafeMode::SECURE || (attr? 'linkcss') %>
|
76
|
+
<link rel="stylesheet" href="<%= normalize_web_path(DEFAULT_STYLESHEET_NAME, (attr :stylesdir, '')) %>"><%
|
77
|
+
else %>
|
78
|
+
<style>
|
79
|
+
<%= ::Asciidoctor::HTML5.default_asciidoctor_stylesheet %>
|
80
|
+
</style><%
|
81
|
+
end
|
82
|
+
elsif attr? :stylesheet
|
83
|
+
if attr? 'linkcss' %>
|
84
|
+
<link rel="stylesheet" href="<%= normalize_web_path((attr :stylesheet), (attr :stylesdir, '')) %>"><%
|
85
|
+
else %>
|
86
|
+
<style>
|
87
|
+
<%= read_asset normalize_system_path((attr :stylesheet), (attr :stylesdir, '')), true %>
|
88
|
+
</style><%
|
89
|
+
end
|
90
|
+
end
|
91
|
+
if attr? 'icons', 'font'
|
92
|
+
if !(attr 'iconfont-remote', '').nil? %>
|
93
|
+
<link rel="stylesheet" href="<%= attr 'iconfont-cdn', 'http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css' %>/<%= attr 'iconfont-name', 'font-awesome' %>.min.css"><%
|
94
|
+
else %>
|
95
|
+
<link rel="stylesheet" href="<%= normalize_web_path(%(\#{attr 'iconfont-name', 'font-awesome'}.css), (attr 'stylesdir', '')) %>"><%
|
96
|
+
end
|
97
|
+
end
|
98
|
+
case attr 'source-highlighter'
|
99
|
+
when 'coderay'
|
100
|
+
if (attr 'coderay-css', 'class') == 'class' %>
|
101
|
+
<style>
|
102
|
+
<%= ::Asciidoctor::HTML5.default_coderay_stylesheet %>
|
103
|
+
</style><%
|
104
|
+
end
|
105
|
+
when 'highlightjs', 'highlight.js' %>
|
106
|
+
<link rel="stylesheet" href="<%= attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3' %>/styles/<%= attr 'highlightjs-theme', 'default' %>.min.css">
|
107
|
+
<script src="<%= attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3' %>/highlight.min.js"></script>
|
108
|
+
<script>hljs.initHighlightingOnLoad()</script><%
|
109
|
+
when 'prettify' %>
|
110
|
+
<link rel="stylesheet" href="<%= attr 'prettifydir', 'http://cdnjs.cloudflare.com/ajax/libs/prettify/r298' %>/<%= attr 'prettify-theme', 'prettify' %>.min.css">
|
111
|
+
<script src="<%= attr 'prettifydir', 'http://cdnjs.cloudflare.com/ajax/libs/prettify/r298' %>/prettify.min.js"></script>
|
112
|
+
<script>document.addEventListener('DOMContentLoaded', prettyPrint)</script><%
|
113
|
+
end %><%= (docinfo_content = docinfo).empty? ? nil : %(
|
114
|
+
\#{docinfo_content}) %>
|
115
|
+
</head>
|
116
|
+
<body#{id} class="<%= doctype %><%= (attr? 'toc-class') && (attr? 'toc') && (attr? 'toc-placement', 'auto') ? %( \#{attr 'toc-class'}) : nil %>"<%= (attr? 'max-width') ? %( style="max-width: \#{attr 'max-width'};") : nil %>><%
|
117
|
+
unless noheader %>
|
118
|
+
<div id="header"><%
|
119
|
+
if has_header?
|
120
|
+
unless notitle %>
|
121
|
+
<h1><%= @header.title %></h1><%
|
122
|
+
end %><%
|
123
|
+
if attr? :author %>
|
124
|
+
<span id="author"><%= attr :author %></span><br><%
|
125
|
+
if attr? :email %>
|
126
|
+
<span id="email"><%= sub_macros(attr :email) %></span><br><%
|
127
|
+
end
|
128
|
+
end
|
129
|
+
if attr? :revnumber %>
|
130
|
+
<span id="revnumber">version <%= attr :revnumber %><%= (attr? :revdate) ? ',' : '' %></span><%
|
131
|
+
end
|
132
|
+
if attr? :revdate %>
|
133
|
+
<span id="revdate"><%= attr :revdate %></span><%
|
134
|
+
end
|
135
|
+
if attr? :revremark %>
|
136
|
+
<br><span id="revremark"><%= attr :revremark %></span><%
|
137
|
+
end
|
138
|
+
end
|
139
|
+
if (attr? :toc) && (attr? 'toc-placement', 'auto') %>
|
140
|
+
<div id="toc" class="<%= attr 'toc-class', 'toc' %>">
|
141
|
+
<div id="toctitle"><%= attr 'toc-title' %></div>
|
121
142
|
<%= template.class.outline(self, (attr :toclevels, 2).to_i) %>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
143
|
+
</div><%
|
144
|
+
end %>
|
145
|
+
</div><%
|
146
|
+
end %>
|
147
|
+
<div id="content">
|
127
148
|
<%= content %>
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
149
|
+
</div><%
|
150
|
+
unless !footnotes? || (attr? :nofootnotes) %>
|
151
|
+
<div id="footnotes">
|
152
|
+
<hr><%
|
153
|
+
footnotes.each do |fn| %>
|
154
|
+
<div class="footnote" id="_footnote_<%= fn.index %>">
|
155
|
+
<a href="#_footnoteref_<%= fn.index %>"><%= fn.index %></a>. <%= fn.text %>
|
156
|
+
</div><%
|
157
|
+
end %>
|
158
|
+
</div><%
|
159
|
+
end %>
|
160
|
+
<div id="footer">
|
161
|
+
<div id="footer-text"><%
|
162
|
+
if attr? :revnumber %>
|
163
|
+
Version <%= attr :revnumber %><br><%
|
164
|
+
end %>
|
165
|
+
Last updated <%= attr :docdatetime %>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</body>
|
145
169
|
</html>
|
146
170
|
EOS
|
147
171
|
end
|
@@ -152,7 +176,7 @@ class EmbeddedTemplate < BaseTemplate
|
|
152
176
|
@template ||= @eruby.new <<-EOS
|
153
177
|
<%#encoding:UTF-8%><% unless notitle || !has_header? %><h1#{id}><%= header.title %></h1>
|
154
178
|
<% end %><%= content %>
|
155
|
-
<% unless !footnotes? || attr?
|
179
|
+
<% unless !footnotes? || (attr? :nofootnotes) %><div id="footnotes">
|
156
180
|
<hr>
|
157
181
|
<% footnotes.each do |fn| %>
|
158
182
|
<div class="footnote" id="_footnote_<%= fn.index %>">
|
@@ -168,12 +192,12 @@ class BlockTocTemplate < BaseTemplate
|
|
168
192
|
def result(node)
|
169
193
|
doc = node.document
|
170
194
|
|
171
|
-
return '' unless doc.attr?
|
195
|
+
return '' unless (doc.attr? 'toc')
|
172
196
|
|
173
197
|
if node.id
|
174
198
|
id_attr = %( id="#{node.id}")
|
175
199
|
title_id_attr = ''
|
176
|
-
elsif doc.embedded? || !doc.attr?
|
200
|
+
elsif doc.embedded? || !(doc.attr? 'toc-placement')
|
177
201
|
id_attr = ' id="toc"'
|
178
202
|
title_id_attr = ' id="toctitle"'
|
179
203
|
else
|
@@ -181,13 +205,13 @@ class BlockTocTemplate < BaseTemplate
|
|
181
205
|
title_id_attr = ''
|
182
206
|
end
|
183
207
|
title = node.title? ? node.title : (doc.attr 'toc-title')
|
184
|
-
levels = node.attr?
|
185
|
-
role = node.attr?
|
208
|
+
levels = (node.attr? 'levels') ? (node.attr 'levels').to_i : (doc.attr 'toclevels', 2).to_i
|
209
|
+
role = (node.attr? 'role') ? (node.attr 'role') : (doc.attr 'toc-class', 'toc')
|
186
210
|
|
187
|
-
%(
|
211
|
+
%(<div#{id_attr} class="#{role}">
|
188
212
|
<div#{title_id_attr} class="title">#{title}</div>
|
189
213
|
#{DocumentTemplate.outline(doc, levels)}
|
190
|
-
</div
|
214
|
+
</div>\n)
|
191
215
|
end
|
192
216
|
|
193
217
|
def template
|
@@ -196,12 +220,23 @@ class BlockTocTemplate < BaseTemplate
|
|
196
220
|
end
|
197
221
|
|
198
222
|
class BlockPreambleTemplate < BaseTemplate
|
223
|
+
def toc(node)
|
224
|
+
if (node.attr? 'toc') && (node.attr? 'toc-placement', 'preamble')
|
225
|
+
%(\n<div id="toc" class="#{node.attr 'toc-class', 'toc'}">
|
226
|
+
<div id="toctitle">#{node.attr 'toc-title'}</div>
|
227
|
+
#{DocumentTemplate.outline(node.document, (node.attr 'toclevels', 2).to_i)}
|
228
|
+
</div>)
|
229
|
+
else
|
230
|
+
''
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
199
234
|
def template
|
200
235
|
@template ||= @eruby.new <<-EOS
|
201
236
|
<%#encoding:UTF-8%><div id="preamble">
|
202
|
-
|
237
|
+
<div class="sectionbody">
|
203
238
|
<%= content %>
|
204
|
-
|
239
|
+
</div><%= template.toc(self) %>
|
205
240
|
</div>
|
206
241
|
EOS
|
207
242
|
end
|
@@ -215,30 +250,43 @@ class SectionTemplate < BaseTemplate
|
|
215
250
|
slevel = 1
|
216
251
|
end
|
217
252
|
htag = "h#{slevel + 1}"
|
218
|
-
id =
|
253
|
+
id = anchor = link_start = link_end = nil
|
254
|
+
if sec.id
|
255
|
+
id = %( id="#{sec.id}")
|
256
|
+
if sec.document.attr? 'sectanchors'
|
257
|
+
#if sec.document.attr? 'icons', 'font'
|
258
|
+
# anchor = %(<a class="anchor" href="##{sec.id}"><i class="icon-anchor"></i></a>)
|
259
|
+
#else
|
260
|
+
anchor = %(<a class="anchor" href="##{sec.id}"></a>)
|
261
|
+
#end
|
262
|
+
elsif sec.document.attr? 'sectlinks'
|
263
|
+
link_start = %(<a class="link" href="##{sec.id}">)
|
264
|
+
link_end = '</a>'
|
265
|
+
end
|
266
|
+
end
|
219
267
|
|
220
268
|
if slevel == 0
|
221
|
-
%(<h1#{id}>#{sec.title}</h1>
|
222
|
-
#{sec.content})
|
269
|
+
%(<h1#{id} class="sect0">#{anchor}#{link_start}#{sec.title}#{link_end}</h1>
|
270
|
+
#{sec.content}\n)
|
223
271
|
else
|
224
|
-
role = sec.attr?
|
225
|
-
if !sec.special && (sec.attr? 'numbered') && slevel < 4
|
272
|
+
role = (sec.attr? 'role') ? " #{sec.attr 'role'}" : nil
|
273
|
+
if !sec.special && (sec.document.attr? 'numbered') && slevel < 4
|
226
274
|
sectnum = "#{sec.sectnum} "
|
227
275
|
else
|
228
276
|
sectnum = nil
|
229
277
|
end
|
230
278
|
|
231
279
|
if slevel == 1
|
232
|
-
content = %(
|
280
|
+
content = %(<div class="sectionbody">
|
233
281
|
#{sec.content}
|
234
|
-
|
282
|
+
</div>)
|
235
283
|
else
|
236
284
|
content = sec.content
|
237
285
|
end
|
238
286
|
%(<div class="sect#{slevel}#{role}">
|
239
|
-
|
287
|
+
<#{htag}#{id}>#{anchor}#{link_start}#{sectnum}#{sec.caption}#{sec.title}#{link_end}</#{htag}>
|
240
288
|
#{content}
|
241
|
-
</div
|
289
|
+
</div>\n)
|
242
290
|
end
|
243
291
|
end
|
244
292
|
|
@@ -259,69 +307,103 @@ class BlockDlistTemplate < BaseTemplate
|
|
259
307
|
def template
|
260
308
|
@template ||= @eruby.new <<-EOS
|
261
309
|
<%#encoding:UTF-8%><%
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
<%
|
304
|
-
<
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
310
|
+
continuing = false
|
311
|
+
entries = content
|
312
|
+
last_index = entries.length - 1
|
313
|
+
if attr? 'style', 'qanda', false
|
314
|
+
%><div#{id} class="qlist#{style_class}#{role_class}"><%
|
315
|
+
if title? %>
|
316
|
+
<div class="title"><%= title %></div><%
|
317
|
+
end %>
|
318
|
+
<ol><%
|
319
|
+
entries.each_with_index do |(dt, dd), index|
|
320
|
+
last = (index == last_index)
|
321
|
+
unless continuing %>
|
322
|
+
<li><%
|
323
|
+
end %>
|
324
|
+
<p><em><%= dt.text %></em></p><%
|
325
|
+
if !last && dd.nil?
|
326
|
+
continuing = true
|
327
|
+
next
|
328
|
+
else
|
329
|
+
continuing = false
|
330
|
+
end
|
331
|
+
unless dd.nil?
|
332
|
+
if dd.text? %>
|
333
|
+
<p><%= dd.text %></p><%
|
334
|
+
end
|
335
|
+
if dd.blocks? %>
|
336
|
+
<%= dd.content %><%
|
337
|
+
end
|
338
|
+
end %>
|
339
|
+
</li><%
|
340
|
+
end %>
|
341
|
+
</ol>
|
342
|
+
</div><%
|
343
|
+
elsif attr? 'style', 'horizontal', false
|
344
|
+
%><div#{id} class="hdlist#{role_class}"><%
|
345
|
+
if title? %>
|
346
|
+
<div class="title"><%= title %></div><%
|
347
|
+
end %>
|
348
|
+
<table><%
|
349
|
+
if (attr? :labelwidth) || (attr? :itemwidth) %>
|
350
|
+
<colgroup>
|
351
|
+
<col<% if attr? :labelwidth %> style="width:<%= (attr :labelwidth).chomp('%') %>%;"<% end %>>
|
352
|
+
<col<% if attr? :itemwidth %> style="width:<%= (attr :itemwidth).chomp('%') %>%;"<% end %>>
|
353
|
+
</colgroup><%
|
354
|
+
end %><%
|
355
|
+
entries.each_with_index do |(dt, dd), index|
|
356
|
+
last = (index == last_index)
|
357
|
+
unless continuing %>
|
358
|
+
<tr>
|
359
|
+
<td class="hdlist1<%= (attr? 'strong-option') ? 'strong' : nil %>"><%
|
360
|
+
end %>
|
361
|
+
<%= dt.text %>
|
362
|
+
<br><%
|
363
|
+
if !last && dd.nil?
|
364
|
+
continuing = true
|
365
|
+
next
|
366
|
+
else
|
367
|
+
continuing = false
|
368
|
+
end %>
|
369
|
+
</td>
|
370
|
+
<td class="hdlist2"><%
|
371
|
+
unless dd.nil?
|
372
|
+
if dd.text? %>
|
373
|
+
<p><%= dd.text %></p><%
|
374
|
+
end
|
375
|
+
if dd.blocks? %>
|
376
|
+
<%= dd.content %><%
|
377
|
+
end
|
378
|
+
end %>
|
379
|
+
</td>
|
380
|
+
</tr><%
|
381
|
+
end %>
|
382
|
+
</table>
|
383
|
+
</div><%
|
384
|
+
else
|
385
|
+
%><div#{id} class="dlist#{style_class}#{role_class}"><%
|
386
|
+
if title? %>
|
387
|
+
<div class="title"><%= title %></div><%
|
388
|
+
end %>
|
389
|
+
<dl><%
|
390
|
+
entries.each_with_index do |(dt, dd), index|
|
391
|
+
last = (index == last_index) %>
|
392
|
+
<dt<%= !(attr? 'style', nil, false) ? %( class="hdlist1") : nil %>><%= dt.text %></dt><%
|
393
|
+
unless dd.nil? %>
|
394
|
+
<dd><%
|
395
|
+
if dd.text? %>
|
396
|
+
<p><%= dd.text %></p><%
|
397
|
+
end %><%
|
398
|
+
if dd.blocks? %>
|
399
|
+
<%= dd.content %><%
|
400
|
+
end %>
|
401
|
+
</dd><%
|
402
|
+
end
|
403
|
+
end %>
|
404
|
+
</dl>
|
405
|
+
</div><%
|
406
|
+
end %>
|
325
407
|
EOS
|
326
408
|
end
|
327
409
|
end
|
@@ -330,14 +412,30 @@ class BlockListingTemplate < BaseTemplate
|
|
330
412
|
def template
|
331
413
|
@template ||= @eruby.new <<-EOS
|
332
414
|
<%#encoding:UTF-8%><div#{id} class="listingblock#{role_class}">
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
415
|
+
#{title_div :caption => true}
|
416
|
+
<div class="content monospaced"><%
|
417
|
+
if attr? 'style', 'source', false
|
418
|
+
language = (language = (attr 'language')) ? %(\#{language} language-\#{language}) : nil
|
419
|
+
case attr 'source-highlighter'
|
420
|
+
when 'coderay'
|
421
|
+
pre_class = ' class="CodeRay"'
|
422
|
+
code_class = language ? %( class="\#{language}") : nil
|
423
|
+
when 'highlightjs', 'highlight.js'
|
424
|
+
pre_class = ' class="highlight"'
|
425
|
+
code_class = language ? %( class="\#{language}") : nil
|
426
|
+
when 'prettify'
|
427
|
+
pre_class = %( class="prettyprint\#{(attr? 'linenums') ? ' linenums' : nil})
|
428
|
+
pre_class = language ? %(\#{pre_class} \#{language}") : %(\#{pre_class}")
|
429
|
+
code_class = nil
|
430
|
+
else
|
431
|
+
pre_class = ' class="highlight"'
|
432
|
+
code_class = language ? %( class="\#{language}") : nil
|
433
|
+
end %>
|
434
|
+
<pre<%= pre_class %>><code<%= code_class %>><%= template.preserve_endlines(content, self) %></code></pre><%
|
435
|
+
else %>
|
436
|
+
<pre><%= template.preserve_endlines(content, self) %></pre><%
|
437
|
+
end %>
|
438
|
+
</div>
|
341
439
|
</div>
|
342
440
|
EOS
|
343
441
|
end
|
@@ -347,10 +445,10 @@ class BlockLiteralTemplate < BaseTemplate
|
|
347
445
|
def template
|
348
446
|
@template ||= @eruby.new <<-EOS
|
349
447
|
<%#encoding:UTF-8%><div#{id} class="literalblock#{role_class}">
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
448
|
+
#{title_div}
|
449
|
+
<div class="content monospaced">
|
450
|
+
<pre><%= template.preserve_endlines(content, self) %></pre>
|
451
|
+
</div>
|
354
452
|
</div>
|
355
453
|
EOS
|
356
454
|
end
|
@@ -360,21 +458,23 @@ class BlockAdmonitionTemplate < BaseTemplate
|
|
360
458
|
def template
|
361
459
|
@template ||= @eruby.new <<-EOS
|
362
460
|
<%#encoding:UTF-8%><div#{id} class="admonitionblock <%= attr :name %>#{role_class}">
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
461
|
+
<table>
|
462
|
+
<tr>
|
463
|
+
<td class="icon"><%
|
464
|
+
if attr? 'icons', 'font' %>
|
465
|
+
<i class="icon-<%= attr :name %>" title="<%= @caption %>"></i><%
|
466
|
+
elsif attr? 'icons' %>
|
467
|
+
<img src="<%= icon_uri(attr :name) %>" alt="<%= @caption %>"><%
|
468
|
+
else %>
|
469
|
+
<div class="title"><%= @caption %></div><%
|
470
|
+
end %>
|
471
|
+
</td>
|
472
|
+
<td class="content">
|
473
|
+
#{title_div}
|
474
|
+
<%= content %>
|
475
|
+
</td>
|
476
|
+
</tr>
|
477
|
+
</table>
|
378
478
|
</div>
|
379
479
|
EOS
|
380
480
|
end
|
@@ -382,14 +482,14 @@ end
|
|
382
482
|
|
383
483
|
class BlockParagraphTemplate < BaseTemplate
|
384
484
|
def paragraph(id, role, title, content)
|
385
|
-
%(<div#{id && " id=\"#{id}\""} class
|
386
|
-
|
387
|
-
|
388
|
-
</div
|
485
|
+
%(<div#{id && " id=\"#{id}\""} class="paragraph#{role && " #{role}"}">#{title && "
|
486
|
+
<div class=\"title\">#{title}</div>"}
|
487
|
+
<p>#{content}</p>
|
488
|
+
</div>\n)
|
389
489
|
end
|
390
490
|
|
391
491
|
def result(node)
|
392
|
-
paragraph(node.id, node.attr
|
492
|
+
paragraph(node.id, (node.attr 'role'), (node.title? ? node.title : nil), node.content)
|
393
493
|
end
|
394
494
|
|
395
495
|
def template
|
@@ -401,10 +501,10 @@ class BlockSidebarTemplate < BaseTemplate
|
|
401
501
|
def template
|
402
502
|
@template ||= @eruby.new <<-EOS
|
403
503
|
<%#encoding:UTF-8%><div#{id} class="sidebarblock#{role_class}">
|
404
|
-
|
405
|
-
|
504
|
+
<div class="content">
|
505
|
+
#{title_div}
|
406
506
|
<%= content %>
|
407
|
-
|
507
|
+
</div>
|
408
508
|
</div>
|
409
509
|
EOS
|
410
510
|
end
|
@@ -414,25 +514,48 @@ class BlockExampleTemplate < BaseTemplate
|
|
414
514
|
def template
|
415
515
|
@template ||= @eruby.new <<-EOS
|
416
516
|
<%#encoding:UTF-8%><div#{id} class="exampleblock#{role_class}">
|
417
|
-
|
418
|
-
|
517
|
+
#{title_div :caption => true}
|
518
|
+
<div class="content">
|
419
519
|
<%= content %>
|
420
|
-
|
520
|
+
</div>
|
421
521
|
</div>
|
422
522
|
EOS
|
423
523
|
end
|
424
524
|
end
|
425
525
|
|
426
526
|
class BlockOpenTemplate < BaseTemplate
|
427
|
-
def
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
527
|
+
def result(node)
|
528
|
+
open_block(node, node.id, (node.attr 'style', nil, false), (node.attr 'role'), node.title? ? node.title : nil, node.content)
|
529
|
+
end
|
530
|
+
|
531
|
+
def open_block(node, id, style, role, title, content)
|
532
|
+
if style == 'abstract'
|
533
|
+
if node.parent == node.document && node.document.attr?('doctype', 'book')
|
534
|
+
puts 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
|
535
|
+
''
|
536
|
+
else
|
537
|
+
%(<div#{id && " id=\"#{id}\""} class="quoteblock abstract#{role && " #{role}"}">#{title &&
|
538
|
+
"<div class=\"title\">#{title}</div>"}
|
539
|
+
<blockquote>
|
540
|
+
#{content}
|
541
|
+
</blockquote>
|
542
|
+
</div>\n)
|
543
|
+
end
|
544
|
+
elsif style == 'partintro' && (!node.document.attr?('doctype', 'book') || !node.parent.is_a?(Asciidoctor::Section) || node.level != 0)
|
545
|
+
puts 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\'s a child of a book part. Excluding block content.'
|
546
|
+
''
|
547
|
+
else
|
548
|
+
%(<div#{id && " id=\"#{id}\""} class="openblock#{style != 'open' ? " #{style}" : ''}#{role && " #{role}"}">#{title &&
|
549
|
+
"<div class=\"title\">#{title}</div>"}
|
550
|
+
<div class="content">
|
551
|
+
#{content}
|
434
552
|
</div>
|
435
|
-
|
553
|
+
</div>\n)
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
def template
|
558
|
+
:invoke_result
|
436
559
|
end
|
437
560
|
end
|
438
561
|
|
@@ -446,21 +569,23 @@ class BlockQuoteTemplate < BaseTemplate
|
|
446
569
|
def template
|
447
570
|
@template ||= @eruby.new <<-EOS
|
448
571
|
<%#encoding:UTF-8%><div#{id} class="quoteblock#{role_class}">
|
449
|
-
|
450
|
-
|
572
|
+
#{title_div}
|
573
|
+
<blockquote>
|
451
574
|
<%= content %>
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
575
|
+
</blockquote><%
|
576
|
+
if (attr? :attribution) || (attr? :citetitle) %>
|
577
|
+
<div class="attribution"><%
|
578
|
+
if attr? :citetitle %>
|
579
|
+
<cite><%= attr :citetitle %></cite><%
|
580
|
+
end
|
581
|
+
if attr? :attribution
|
582
|
+
if attr? :citetitle %>
|
583
|
+
<br><%
|
584
|
+
end %>
|
585
|
+
<%= "— \#{attr :attribution}" %><%
|
586
|
+
end %>
|
587
|
+
</div><%
|
588
|
+
end %>
|
464
589
|
</div>
|
465
590
|
EOS
|
466
591
|
end
|
@@ -470,19 +595,21 @@ class BlockVerseTemplate < BaseTemplate
|
|
470
595
|
def template
|
471
596
|
@template ||= @eruby.new <<-EOS
|
472
597
|
<%#encoding:UTF-8%><div#{id} class="verseblock#{role_class}">
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
598
|
+
#{title_div}
|
599
|
+
<pre class="content"><%= template.preserve_endlines(content, self) %></pre><%
|
600
|
+
if (attr? :attribution) || (attr? :citetitle) %>
|
601
|
+
<div class="attribution"><%
|
602
|
+
if attr? :citetitle %>
|
603
|
+
<cite><%= attr :citetitle %></cite><%
|
604
|
+
end
|
605
|
+
if attr? :attribution
|
606
|
+
if attr? :citetitle %>
|
607
|
+
<br><%
|
608
|
+
end %>
|
609
|
+
<%= "— \#{attr :attribution}" %><%
|
610
|
+
end %>
|
611
|
+
</div><%
|
612
|
+
end %>
|
486
613
|
</div>
|
487
614
|
EOS
|
488
615
|
end
|
@@ -492,37 +619,38 @@ class BlockUlistTemplate < BaseTemplate
|
|
492
619
|
def template
|
493
620
|
@template ||= @eruby.new <<-EOS
|
494
621
|
<%#encoding:UTF-8%><div#{id} class="ulist#{style_class}#{role_class}">
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
<%= item.content
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
622
|
+
#{title_div}
|
623
|
+
<ul><%
|
624
|
+
content.each do |item| %>
|
625
|
+
<li>
|
626
|
+
<p><%= item.text %></p><%
|
627
|
+
if item.blocks? %>
|
628
|
+
<%= item.content %><%
|
629
|
+
end %>
|
630
|
+
</li><%
|
631
|
+
end %>
|
632
|
+
</ul>
|
506
633
|
</div>
|
507
634
|
EOS
|
508
635
|
end
|
509
636
|
end
|
510
637
|
|
511
638
|
class BlockOlistTemplate < BaseTemplate
|
639
|
+
|
512
640
|
def template
|
513
641
|
@template ||= @eruby.new <<-EOS
|
514
|
-
<%#encoding:UTF-8%><div#{id} class="olist#{style_class}#{role_class}">
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
<%= item.content
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
642
|
+
<%#encoding:UTF-8%><% style = attr 'style', nil, false %><div#{id} class="olist#{style_class}#{role_class}">
|
643
|
+
#{title_div}
|
644
|
+
<ol class="<%= style %>"<%= (type = ::Asciidoctor::ORDERED_LIST_KEYWORDS[style]) ? %( type="\#{type}") : nil %>#{attribute('start', :start)}><%
|
645
|
+
content.each do |item| %>
|
646
|
+
<li>
|
647
|
+
<p><%= item.text %></p><%
|
648
|
+
if item.blocks? %>
|
649
|
+
<%= item.content %><%
|
650
|
+
end %>
|
651
|
+
</li><%
|
652
|
+
end %>
|
653
|
+
</ol>
|
526
654
|
</div>
|
527
655
|
EOS
|
528
656
|
end
|
@@ -532,25 +660,28 @@ class BlockColistTemplate < BaseTemplate
|
|
532
660
|
def template
|
533
661
|
@template ||= @eruby.new <<-EOS
|
534
662
|
<%#encoding:UTF-8%><div#{id} class="colist#{style_class}#{role_class}">
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
663
|
+
#{title_div}<%
|
664
|
+
if attr? :icons %>
|
665
|
+
<table><%
|
666
|
+
content.each_with_index do |item, i| %>
|
667
|
+
<tr>
|
668
|
+
<td><%
|
669
|
+
if attr? :icons, 'font' %><i class="conum"><%= i + 1 %></i><%
|
670
|
+
else %><img src="<%= icon_uri("callouts/\#{i + 1}") %>" alt="<%= i + 1 %>"><%
|
671
|
+
end %></td>
|
672
|
+
<td><%= item.text %></td>
|
673
|
+
</tr><%
|
674
|
+
end %>
|
675
|
+
</table><%
|
676
|
+
else %>
|
677
|
+
<ol><%
|
678
|
+
content.each do |item| %>
|
679
|
+
<li>
|
680
|
+
<p><%= item.text %></p>
|
681
|
+
</li><%
|
682
|
+
end %>
|
683
|
+
</ol><%
|
684
|
+
end %>
|
554
685
|
</div>
|
555
686
|
EOS
|
556
687
|
end
|
@@ -561,42 +692,56 @@ class BlockTableTemplate < BaseTemplate
|
|
561
692
|
@template ||= @eruby.new <<-EOS
|
562
693
|
<%#encoding:UTF-8%><table#{id} class="tableblock frame-<%= attr :frame, 'all' %> grid-<%= attr :grid, 'all'%>#{role_class}" style="<%
|
563
694
|
if !(attr? 'autowidth-option') %>width:<%= attr :tablepcwidth %>%; <% end %><%
|
564
|
-
if attr? :float %>float: <%= attr :float %>; <% end %>"
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
695
|
+
if attr? :float %>float: <%= attr :float %>; <% end %>"><%
|
696
|
+
if title? %>
|
697
|
+
<caption class="title"><% unless @caption.nil? %><%= @caption %><% end %><%= title %></caption><%
|
698
|
+
end
|
699
|
+
if (attr :rowcount) >= 0 %>
|
700
|
+
<colgroup><%
|
701
|
+
if attr? 'autowidth-option'
|
702
|
+
@columns.each do %>
|
703
|
+
<col><%
|
704
|
+
end
|
705
|
+
else
|
706
|
+
@columns.each do |col| %>
|
707
|
+
<col style="width:<%= col.attr :colpcwidth %>%;"><%
|
708
|
+
end
|
709
|
+
end %>
|
710
|
+
</colgroup><%
|
711
|
+
[:head, :foot, :body].select {|tsec| !@rows[tsec].empty? }.each do |tsec| %>
|
712
|
+
<t<%= tsec %>><%
|
713
|
+
@rows[tsec].each do |row| %>
|
714
|
+
<tr><%
|
715
|
+
row.each do |cell| %>
|
716
|
+
<<%= tsec == :head ? 'th' : 'td' %> class="tableblock halign-<%= cell.attr :halign %> valign-<%= cell.attr :valign %>"#{attribute('colspan', 'cell.colspan')}#{attribute('rowspan', 'cell.rowspan')}<%
|
717
|
+
cell_content = ''
|
718
|
+
if tsec == :head
|
719
|
+
cell_content = cell.text
|
720
|
+
else
|
721
|
+
case (cell.attr 'style', nil, false)
|
722
|
+
when :asciidoc
|
723
|
+
cell_content = %(<div>\#{cell.content}</div>)
|
724
|
+
when :verse
|
725
|
+
cell_content = %(<div class="verse">\#{template.preserve_endlines(cell.text, self)}</div>)
|
726
|
+
when :literal
|
727
|
+
cell_content = %(<div class="literal monospaced"><pre>\#{template.preserve_endlines(cell.text, self)}</pre></div>)
|
728
|
+
when :header
|
729
|
+
cell.content.each do |text|
|
730
|
+
cell_content = %(\#{cell_content}<p class="tableblock header">\#{text}</p>)
|
731
|
+
end
|
732
|
+
else
|
733
|
+
cell.content.each do |text|
|
734
|
+
cell_content = %(\#{cell_content}<p class="tableblock">\#{text}</p>)
|
735
|
+
end
|
736
|
+
end
|
737
|
+
end %><%= (@document.attr? 'cellbgcolor') ? %( style="background-color:\#{@document.attr 'cellbgcolor'};") : nil
|
738
|
+
%>><%= cell_content %></<%= tsec == :head ? 'th' : 'td' %>><%
|
739
|
+
end %>
|
740
|
+
</tr><%
|
741
|
+
end %>
|
742
|
+
</t<%= tsec %>><%
|
743
|
+
end
|
744
|
+
end %>
|
600
745
|
</table>
|
601
746
|
EOS
|
602
747
|
end
|
@@ -605,17 +750,18 @@ end
|
|
605
750
|
class BlockImageTemplate < BaseTemplate
|
606
751
|
def template
|
607
752
|
@template ||= @eruby.new <<-EOS
|
608
|
-
<%#encoding:UTF-8%><div#{id} class="imageblock#{style_class}#{role_class}"<%
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
753
|
+
<%#encoding:UTF-8%><div#{id} class="imageblock#{style_class}#{role_class}"<%
|
754
|
+
if (attr? :align) || (attr? :float) %> style="<%
|
755
|
+
if attr? :align %>text-align: <%= attr :align %><% if attr? :float %>; <% end %><% end %><% if attr? :float %>float: <%= attr :float %><% end %>"<%
|
756
|
+
end %>>
|
757
|
+
<div class="content"><%
|
758
|
+
if attr? :link %>
|
759
|
+
<a class="image" href="<%= attr :link %>"><img src="<%= image_uri(attr :target) %>" alt="<%= attr :alt %>"#{attribute('width', :width)}#{attribute('height', :height)}></a><%
|
760
|
+
else %>
|
761
|
+
<img src="<%= image_uri(attr :target) %>" alt="<%= attr :alt %>"#{attribute('width', :width)}#{attribute('height', :height)}><%
|
762
|
+
end %>
|
763
|
+
</div>
|
764
|
+
#{title_div :caption => true}
|
619
765
|
</div>
|
620
766
|
EOS
|
621
767
|
end
|
@@ -625,15 +771,15 @@ class BlockAudioTemplate < BaseTemplate
|
|
625
771
|
def template
|
626
772
|
@template ||= @eruby.new <<-EOS
|
627
773
|
<%#encoding:UTF-8%><div#{id} class="audioblock#{style_class}#{role_class}">
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
774
|
+
#{title_div :caption => true}
|
775
|
+
<div class="content">
|
776
|
+
<audio src="<%= media_uri(attr :target) %>"<%
|
777
|
+
if attr? 'autoplay-option' %> autoplay<% end %><%
|
778
|
+
unless attr? 'nocontrols-option' %> controls<% end %><%
|
779
|
+
if attr? 'loop-option' %> loop<% end %>>
|
780
|
+
Your browser does not support the audio tag.
|
781
|
+
</audio>
|
782
|
+
</div>
|
637
783
|
</div>
|
638
784
|
EOS
|
639
785
|
end
|
@@ -643,16 +789,16 @@ class BlockVideoTemplate < BaseTemplate
|
|
643
789
|
def template
|
644
790
|
@template ||= @eruby.new <<-EOS
|
645
791
|
<%#encoding:UTF-8%><div#{id} class="videoblock#{style_class}#{role_class}">
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
792
|
+
#{title_div :caption => true}
|
793
|
+
<div class="content">
|
794
|
+
<video src="<%= media_uri(attr :target) %>"#{attribute('width', :width)}#{attribute('height', :height)}<%
|
795
|
+
if attr? 'poster' %> poster="<%= media_uri(attr :poster) %>"<% end %><%
|
796
|
+
if attr? 'autoplay-option' %> autoplay<% end %><%
|
797
|
+
unless attr? 'nocontrols-option' %> controls<% end %><%
|
798
|
+
if attr? 'loop-option' %> loop<% end %>>
|
799
|
+
Your browser does not support the video tag.
|
800
|
+
</video>
|
801
|
+
</div>
|
656
802
|
</div>
|
657
803
|
EOS
|
658
804
|
end
|
@@ -670,7 +816,7 @@ end
|
|
670
816
|
|
671
817
|
class BlockPageBreakTemplate < BaseTemplate
|
672
818
|
def result(node)
|
673
|
-
|
819
|
+
%(<div style="page-break-after: always;"></div>\n)
|
674
820
|
end
|
675
821
|
|
676
822
|
def template
|
@@ -680,7 +826,7 @@ end
|
|
680
826
|
|
681
827
|
class InlineBreakTemplate < BaseTemplate
|
682
828
|
def result(node)
|
683
|
-
|
829
|
+
%(#{node.text}<br>\n)
|
684
830
|
end
|
685
831
|
|
686
832
|
def template
|
@@ -690,7 +836,9 @@ end
|
|
690
836
|
|
691
837
|
class InlineCalloutTemplate < BaseTemplate
|
692
838
|
def result(node)
|
693
|
-
if node.attr? 'icons'
|
839
|
+
if node.attr? 'icons', 'font'
|
840
|
+
%(<i class="conum">#{node.text}</i>)
|
841
|
+
elsif node.attr? 'icons'
|
694
842
|
src = node.icon_uri("callouts/#{node.text}")
|
695
843
|
%(<img src="#{src}" alt="#{node.text}">)
|
696
844
|
else
|
@@ -706,7 +854,7 @@ end
|
|
706
854
|
class InlineQuotedTemplate < BaseTemplate
|
707
855
|
NO_TAGS = ['', '']
|
708
856
|
|
709
|
-
|
857
|
+
QUOTE_TAGS = {
|
710
858
|
:emphasis => ['<em>', '</em>'],
|
711
859
|
:strong => ['<strong>', '</strong>'],
|
712
860
|
:monospaced => ['<code>', '</code>'],
|
@@ -717,16 +865,67 @@ class InlineQuotedTemplate < BaseTemplate
|
|
717
865
|
}
|
718
866
|
|
719
867
|
def quote_text(text, type, role)
|
720
|
-
start_tag, end_tag =
|
868
|
+
start_tag, end_tag = QUOTE_TAGS[type] || NO_TAGS
|
721
869
|
if role
|
722
|
-
|
870
|
+
if start_tag.start_with? '<'
|
871
|
+
%(#{start_tag.chop} class="#{role}">#{text}#{end_tag})
|
872
|
+
else
|
873
|
+
%(#{start_tag}<span class="#{role}">#{text}</span>#{end_tag})
|
874
|
+
end
|
723
875
|
else
|
724
876
|
"#{start_tag}#{text}#{end_tag}"
|
725
877
|
end
|
726
878
|
end
|
727
879
|
|
728
880
|
def result(node)
|
729
|
-
quote_text(node.text, node.type, node.attr
|
881
|
+
quote_text(node.text, node.type, (node.attr 'role'))
|
882
|
+
end
|
883
|
+
|
884
|
+
def template
|
885
|
+
:invoke_result
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
class InlineButtonTemplate < BaseTemplate
|
890
|
+
def result(node)
|
891
|
+
%(<b class="button">#{node.text}</b>)
|
892
|
+
end
|
893
|
+
|
894
|
+
def template
|
895
|
+
:invoke_result
|
896
|
+
end
|
897
|
+
end
|
898
|
+
|
899
|
+
class InlineKbdTemplate < BaseTemplate
|
900
|
+
def result(node)
|
901
|
+
keys = node.attr 'keys'
|
902
|
+
if keys.size == 1
|
903
|
+
%(<kbd>#{keys.first}</kbd>)
|
904
|
+
else
|
905
|
+
key_combo = keys.map{|key| %(<kbd>#{key}</kbd>+) }.join.chop
|
906
|
+
%(<kbd class="keyseq">#{key_combo}</kbd>)
|
907
|
+
end
|
908
|
+
end
|
909
|
+
|
910
|
+
def template
|
911
|
+
:invoke_result
|
912
|
+
end
|
913
|
+
end
|
914
|
+
|
915
|
+
class InlineMenuTemplate < BaseTemplate
|
916
|
+
def menu(menu, submenus, menuitem)
|
917
|
+
if !submenus.empty?
|
918
|
+
submenu_path = submenus.map{|submenu| %(<span class="submenu">#{submenu}</span> ▸ ) }.join.chop
|
919
|
+
%(<span class="menuseq"><span class="menu">#{menu}</span> ▸ #{submenu_path} <span class="menuitem">#{menuitem}</span></span>)
|
920
|
+
elsif !menuitem.nil?
|
921
|
+
%(<span class="menuseq"><span class="menu">#{menu}</span> ▸ <span class="menuitem">#{menuitem}</span></span>)
|
922
|
+
else
|
923
|
+
%(<span class="menu">#{menu}</span>)
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
def result(node)
|
928
|
+
menu(node.attr('menu'), node.attr('submenus'), node.attr('menuitem'))
|
730
929
|
end
|
731
930
|
|
732
931
|
def template
|
@@ -735,7 +934,7 @@ class InlineQuotedTemplate < BaseTemplate
|
|
735
934
|
end
|
736
935
|
|
737
936
|
class InlineAnchorTemplate < BaseTemplate
|
738
|
-
def anchor(target, text, type, document,
|
937
|
+
def anchor(target, text, type, document, node)
|
739
938
|
case type
|
740
939
|
when :xref
|
741
940
|
text = document.references[:ids].fetch(target, "[#{target}]") if text.nil?
|
@@ -743,14 +942,14 @@ class InlineAnchorTemplate < BaseTemplate
|
|
743
942
|
when :ref
|
744
943
|
%(<a id="#{target}"></a>)
|
745
944
|
when :link
|
746
|
-
%(<a href="#{target}"#{window
|
945
|
+
%(<a href="#{target}"#{(node.attr? 'role') ? " class=\"#{node.attr 'role'}\"" : nil}#{(node.attr? 'window') ? " target=\"#{node.attr 'window'}\"" : nil}>#{text}</a>)
|
747
946
|
when :bibref
|
748
947
|
%(<a id="#{target}"></a>[#{target}])
|
749
948
|
end
|
750
949
|
end
|
751
950
|
|
752
951
|
def result(node)
|
753
|
-
anchor(node.target, node.text, node.type, node.document,
|
952
|
+
anchor(node.target, node.text, node.type, node.document, node)
|
754
953
|
end
|
755
954
|
|
756
955
|
def template
|