deplate 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +26 -0
- data/CHANGES.TXT +177 -0
- data/LICENSE.TXT +340 -0
- data/NEWS.TXT +29 -0
- data/README.TXT +86 -0
- data/TODO.TXT +202 -0
- data/VERSION.TXT +1 -0
- data/bin/deplate +3 -0
- data/bin/deplate.bat +2 -0
- data/etc/deplate.ini +361 -0
- data/lib/deplate.rb +31 -0
- data/lib/deplate/abstract-class.rb +30 -0
- data/lib/deplate/builtin.rb +11 -0
- data/lib/deplate/cache.rb +59 -0
- data/lib/deplate/commands.rb +693 -0
- data/lib/deplate/common.rb +335 -0
- data/lib/deplate/converter.rb +99 -0
- data/lib/deplate/core.rb +2705 -0
- data/lib/deplate/css/article.css +545 -0
- data/lib/deplate/css/deplate.css +699 -0
- data/lib/deplate/css/heading-navbar.css +29 -0
- data/lib/deplate/css/layout-deplate-print.css +540 -0
- data/lib/deplate/css/layout-deplate.css +764 -0
- data/lib/deplate/css/sans-serif.css +160 -0
- data/lib/deplate/css/serif-e.css +170 -0
- data/lib/deplate/css/serif-rel.css +121 -0
- data/lib/deplate/css/serif.css +190 -0
- data/lib/deplate/css/slides.css +11 -0
- data/lib/deplate/css/tabbar-left.css +91 -0
- data/lib/deplate/css/tabbar-right-ie.css +14 -0
- data/lib/deplate/css/tabbar-right.css +118 -0
- data/lib/deplate/css/tabbar-top.css +64 -0
- data/lib/deplate/css/tabbar.css +81 -0
- data/lib/deplate/css/text-sans-serif.css +154 -0
- data/lib/deplate/css/text-serif.css +175 -0
- data/lib/deplate/define.rb +439 -0
- data/lib/deplate/docbook.rb +738 -0
- data/lib/deplate/elements.rb +1355 -0
- data/lib/deplate/etc.rb +199 -0
- data/lib/deplate/external.rb +135 -0
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +21 -0
- data/lib/deplate/fmt/dbk-article.rb +46 -0
- data/lib/deplate/fmt/dbk-book.rb +46 -0
- data/lib/deplate/fmt/dbk-ref.rb +105 -0
- data/lib/deplate/fmt/dbk-slides.rb +47 -0
- data/lib/deplate/fmt/dbk-snippet.rb +21 -0
- data/lib/deplate/fmt/html-snippet.rb +21 -0
- data/lib/deplate/fmt/html.rb +1696 -0
- data/lib/deplate/fmt/htmlsite.rb +419 -0
- data/lib/deplate/fmt/htmlslides.rb +21 -0
- data/lib/deplate/fmt/htmlwebsite.rb +70 -0
- data/lib/deplate/fmt/latex-snippet.rb +22 -0
- data/lib/deplate/fmt/latex.rb +1242 -0
- data/lib/deplate/fmt/php.rb +19 -0
- data/lib/deplate/fmt/phpsite.rb +19 -0
- data/lib/deplate/fmt/plain.rb +598 -0
- data/lib/deplate/fmt/template.rb +34 -0
- data/lib/deplate/fmt/xhtml10t.rb +41 -0
- data/lib/deplate/formatter-snippet.rb +17 -0
- data/lib/deplate/formatter.rb +1210 -0
- data/lib/deplate/input.rb +492 -0
- data/lib/deplate/input/deplate-headings.rb +48 -0
- data/lib/deplate/input/deplate-restricted.rb +70 -0
- data/lib/deplate/input/deplate.rb +28 -0
- data/lib/deplate/input/rdoc.rb +277 -0
- data/lib/deplate/input/template.rb +29 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +15 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +15 -0
- data/lib/deplate/lib/tabmenu.js +146 -0
- data/lib/deplate/locale/de.latin1 +708 -0
- data/lib/deplate/locale/ru.koi8-r +48 -0
- data/lib/deplate/locale/zh_cn.gb2312 +35 -0
- data/lib/deplate/macros.rb +639 -0
- data/lib/deplate/messages.rb +120 -0
- data/lib/deplate/metadata.rb +77 -0
- data/lib/deplate/metadata/marshal.rb +24 -0
- data/lib/deplate/metadata/xml.rb +42 -0
- data/lib/deplate/metadata/yaml.rb +26 -0
- data/lib/deplate/mod/anyword.rb +56 -0
- data/lib/deplate/mod/babelfish.rb +27 -0
- data/lib/deplate/mod/code-gvim.rb +52 -0
- data/lib/deplate/mod/code-highlight.rb +91 -0
- data/lib/deplate/mod/colored-log.rb +17 -0
- data/lib/deplate/mod/de.rb +19 -0
- data/lib/deplate/mod/en.rb +17 -0
- data/lib/deplate/mod/endnotes.rb +60 -0
- data/lib/deplate/mod/fr.rb +46 -0
- data/lib/deplate/mod/html-asciimath.rb +40 -0
- data/lib/deplate/mod/html-deplate-button.rb +15 -0
- data/lib/deplate/mod/html-headings-navbar.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +47 -0
- data/lib/deplate/mod/html-sidebar.rb +232 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +32 -0
- data/lib/deplate/mod/iconv.rb +35 -0
- data/lib/deplate/mod/imgurl.rb +30 -0
- data/lib/deplate/mod/inlatex-compound.rb +69 -0
- data/lib/deplate/mod/koma.rb +109 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +38 -0
- data/lib/deplate/mod/latex-styles.rb +461 -0
- data/lib/deplate/mod/latex-verbatim-small.rb +29 -0
- data/lib/deplate/mod/makefile.rb +194 -0
- data/lib/deplate/mod/mark-external-urls.rb +38 -0
- data/lib/deplate/mod/markup-1-warn.rb +37 -0
- data/lib/deplate/mod/markup-1.rb +41 -0
- data/lib/deplate/mod/navbar-png.rb +33 -0
- data/lib/deplate/mod/noindent.rb +32 -0
- data/lib/deplate/mod/numpara.rb +40 -0
- data/lib/deplate/mod/particle-math.rb +34 -0
- data/lib/deplate/mod/php-extra.rb +44 -0
- data/lib/deplate/mod/pstoedit.rb +71 -0
- data/lib/deplate/mod/recode.rb +57 -0
- data/lib/deplate/mod/ru_koi8-r.rb +20 -0
- data/lib/deplate/mod/smiley.rb +50 -0
- data/lib/deplate/mod/soffice.rb +23 -0
- data/lib/deplate/mod/symbols-latin1.rb +58 -0
- data/lib/deplate/mod/symbols-od-utf-8.rb +16 -0
- data/lib/deplate/mod/symbols-plain.rb +58 -0
- data/lib/deplate/mod/symbols-sgml.rb +97 -0
- data/lib/deplate/mod/symbols-utf-8.rb +81 -0
- data/lib/deplate/mod/symbols-xml.rb +34 -0
- data/lib/deplate/mod/syntax-region-alt.rb +37 -0
- data/lib/deplate/mod/utf8.rb +49 -0
- data/lib/deplate/mod/validate-html.rb +35 -0
- data/lib/deplate/mod/xmlrpc.rb +233 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +108 -0
- data/lib/deplate/mod/zh-cn.rb +59 -0
- data/lib/deplate/once-method.rb +44 -0
- data/lib/deplate/output.rb +249 -0
- data/lib/deplate/particles.rb +815 -0
- data/lib/deplate/regions.rb +1076 -0
- data/lib/deplate/structured.rb +763 -0
- data/lib/deplate/template.rb +430 -0
- data/lib/deplate/templates/html-doc.html +28 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +37 -0
- data/lib/deplate/templates/html-left-tabbar.html +31 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +43 -0
- data/lib/deplate/templates/html-tabbar-right.html +23 -0
- data/lib/deplate/templates/html-tabbar-top.html +43 -0
- data/lib/deplate/templates/html-tabbar.html +31 -0
- data/lib/deplate/wiki-markup.rb +117 -0
- data/lib/deplate/xml.rb +109 -0
- data/lib/deplate/zh-cn.rb +59 -0
- data/lib/ps2ppm.rb +239 -0
- data/man/man1/deplate.1 +692 -0
- metadata +210 -0
@@ -0,0 +1,738 @@
|
|
1
|
+
# docbook.rb
|
2
|
+
# @Author: Thomas Link (samul AT web.de)
|
3
|
+
# @Website: http://deplate.sf.net/
|
4
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
+
# @Created: 17-M�r-2004.
|
6
|
+
# @Last Change: 01-Nov-2005.
|
7
|
+
# @Revision: 0.2651
|
8
|
+
|
9
|
+
require "deplate/xml"
|
10
|
+
|
11
|
+
# An abstract docbook formatter
|
12
|
+
|
13
|
+
class Deplate::Formatter::Docbook < Deplate::Formatter::XML
|
14
|
+
def initialize(deplate, args)
|
15
|
+
@consumed_ids = []
|
16
|
+
@sgml = false
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_open(tag, opts=nil, args=nil, other_args={})
|
21
|
+
single = other_args[:single] || false
|
22
|
+
no_id = other_args[:no_id] || false
|
23
|
+
opts ||= {}
|
24
|
+
args ||= {}
|
25
|
+
unless no_id
|
26
|
+
id = use_id(args, opts)
|
27
|
+
oid = opts["id"]
|
28
|
+
if oid and oid != id
|
29
|
+
log(["ID mismatch", id, oid, opts, args], :error)
|
30
|
+
end
|
31
|
+
opts["id"] = encode_id(id) if id
|
32
|
+
# args = args.dup
|
33
|
+
args.delete("id")
|
34
|
+
end
|
35
|
+
id = opts["id"]
|
36
|
+
if id
|
37
|
+
if @consumed_ids.include?(id)
|
38
|
+
opts = opts.dup
|
39
|
+
opts.delete("id")
|
40
|
+
else
|
41
|
+
@consumed_ids << id
|
42
|
+
end
|
43
|
+
opts["xreflabel"] ||= args[:level_as_string]
|
44
|
+
end
|
45
|
+
opts = opts.collect do |k, v|
|
46
|
+
case k
|
47
|
+
when "linkend"
|
48
|
+
v = encode_id(v)
|
49
|
+
end
|
50
|
+
if v
|
51
|
+
%{%s="%s"} % [k, v]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
if single
|
55
|
+
if @sgml
|
56
|
+
opts << "></%s" % tag
|
57
|
+
else
|
58
|
+
opts << "/"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
%{<%s>} % [tag, *opts].compact.join(" ")
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_close(tag, args=nil)
|
65
|
+
%{</%s>} % tag
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_emphasize(args, text)
|
69
|
+
formatted_inline('emphasis', text)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_code(args, text)
|
73
|
+
formatted_inline('literal', text)
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_url(args, name, dest, anchor, literal=false)
|
77
|
+
formatted_inline('ulink', name, {'url' => dest.gsub(/&/, '&')})
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_wiki(args, name, dest, anchor)
|
81
|
+
formatted_inline('ulink', name, {'url' => dest})
|
82
|
+
end
|
83
|
+
|
84
|
+
def docbook_authors(authors)
|
85
|
+
accAuthors = []
|
86
|
+
for au in authors
|
87
|
+
acc = []
|
88
|
+
author = []
|
89
|
+
if au[:firstname] and au[:surname]
|
90
|
+
firstname = @deplate.parse_and_format(nil, au[:firstname], false)
|
91
|
+
author << formatted_inline("firstname", firstname)
|
92
|
+
surname = @deplate.parse_and_format(nil, au[:surname], false)
|
93
|
+
author << formatted_inline("surname", surname)
|
94
|
+
else
|
95
|
+
surname = @deplate.parse_and_format(nil, au[:name], false)
|
96
|
+
author << formatted_inline("surname", surname)
|
97
|
+
end
|
98
|
+
acc << author.join
|
99
|
+
if au[:note]
|
100
|
+
authorblurb = @deplate.parse_and_format(nil, au[:note], false)
|
101
|
+
acc << formatted_block("authorblurb", formatted_inline("para", authorblurb))
|
102
|
+
end
|
103
|
+
accAuthors << formatted_block("author", join_blocks(acc))
|
104
|
+
end
|
105
|
+
return accAuthors
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_doc_head(args)
|
109
|
+
accum = []
|
110
|
+
|
111
|
+
authors = @deplate.options.author || []
|
112
|
+
accAuthors = docbook_authors(authors)
|
113
|
+
if authors.size > 1
|
114
|
+
accum << formatted_block("authorgroup", join_blocks(accAuthors))
|
115
|
+
else
|
116
|
+
accum += accAuthors
|
117
|
+
end
|
118
|
+
|
119
|
+
date = @deplate.get_clip("date")
|
120
|
+
date = date ? date.elt : Deplate::Element.get_date("today", nil)
|
121
|
+
accum << formatted_inline("pubdate", date)
|
122
|
+
|
123
|
+
title = @deplate.get_clip("title")
|
124
|
+
accum << formatted_inline("title", title.elt) if title
|
125
|
+
|
126
|
+
kw = keywords
|
127
|
+
if kw
|
128
|
+
kws = join_blocks(kw.collect {|kw| formatted_inline("keyword", kw)})
|
129
|
+
accum << formatted_block("keywordset", kws)
|
130
|
+
end
|
131
|
+
|
132
|
+
desc = @deplate.variables["description"]
|
133
|
+
if desc
|
134
|
+
para = formatted_inline("para", plain_text(desc))
|
135
|
+
accum << formatted_block("abstract", para)
|
136
|
+
end
|
137
|
+
|
138
|
+
return join_blocks(accum)
|
139
|
+
end
|
140
|
+
|
141
|
+
def get_doc_def(args)
|
142
|
+
version = @deplate.variables['dbkVersion'] || '4.2'
|
143
|
+
type = @deplate.variables['dbkClass'] || 'article'
|
144
|
+
dbkid = @deplate.variables['dbkId'] || "-//OASIS//DTD DocBook XML V#{version}//EN"
|
145
|
+
dtd = @deplate.variables['dbkDtd'] || "http://www.oasis-open.org/docbook/xml/#{version}/docbookx.dtd"
|
146
|
+
docbook_doc_def(args, type, dbkid, dtd)
|
147
|
+
end
|
148
|
+
|
149
|
+
def docbook_doc_def(args, type, pub, dtd, xmlVersion="1.0")
|
150
|
+
encoding = @encoding ? %{ encoding="%s"} % @encoding : ""
|
151
|
+
|
152
|
+
doc = [%{<?xml version='#{xmlVersion}'#{encoding}?>},
|
153
|
+
%{<!DOCTYPE #{type} PUBLIC "#{pub}"},
|
154
|
+
%{ "#{dtd}"}
|
155
|
+
]
|
156
|
+
ent = get_entities(args)
|
157
|
+
if ent
|
158
|
+
doc.last << " ["
|
159
|
+
doc << ent << "]"
|
160
|
+
end
|
161
|
+
doc.last << ">"
|
162
|
+
return join_blocks(doc.flatten.compact)
|
163
|
+
end
|
164
|
+
|
165
|
+
def get_entities(args)
|
166
|
+
entities = args[:deplate].variables["dbkEntities"]
|
167
|
+
return join_blocks(entities) if entities
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_entity(id, pub)
|
171
|
+
%{<!ENTITY %% %s PUBLIC "%s">\n%%%s;} % [id, pub, id]
|
172
|
+
end
|
173
|
+
|
174
|
+
# get_doc_body_open(args)
|
175
|
+
noop self, "get_doc_body_open"
|
176
|
+
|
177
|
+
# get_doc_body_close(args)
|
178
|
+
noop self, "get_doc_body_close"
|
179
|
+
|
180
|
+
# Bibliography
|
181
|
+
def get_bib(args, title, bib)
|
182
|
+
acc = [close_headings(1)]
|
183
|
+
title = formatted_inline("title", title) if title and !args["plain"]
|
184
|
+
acc << formatted_block("bibliography", join_blocks([title, bib].compact), nil, args)
|
185
|
+
join_blocks(acc)
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_bib_entry(args, key, entry)
|
189
|
+
body = join_blocks([formatted_inline("abbrev", key), entry])
|
190
|
+
return formatted_block("biblioentry", body, {"id" => encode_id(key)}, args)
|
191
|
+
end
|
192
|
+
|
193
|
+
def docbook_format_authors(type, args, text)
|
194
|
+
if text
|
195
|
+
acc = []
|
196
|
+
for au in authors_split(text)
|
197
|
+
author = Deplate::Names.name_match_sf(au) || Deplate::Names.name_match_fs(au)
|
198
|
+
if author
|
199
|
+
surname = formatted_inline("surname", author[:surname])
|
200
|
+
firstname = formatted_inline("firstname", author[:firstname])
|
201
|
+
acc << formatted_inline(type, surname + firstname)
|
202
|
+
else
|
203
|
+
# is this ok???
|
204
|
+
acc << formatted_inline(type, formatted_inline("surname", au))
|
205
|
+
end
|
206
|
+
end
|
207
|
+
if acc.size > 1
|
208
|
+
return formatted_block("authorgroup", join_blocks(acc), nil, args)
|
209
|
+
else
|
210
|
+
return join_blocks(acc)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def get_bib_author(args, text)
|
216
|
+
docbook_format_authors("author", args, text)
|
217
|
+
end
|
218
|
+
|
219
|
+
def get_bib_year(args, text)
|
220
|
+
formatted_inline("pubdate", text)
|
221
|
+
end
|
222
|
+
|
223
|
+
def get_bib_booktitle(args, text)
|
224
|
+
formatted_inline("title", text)
|
225
|
+
end
|
226
|
+
|
227
|
+
def get_bib_editor(args, text)
|
228
|
+
docbook_format_authors("editor", args, text)
|
229
|
+
end
|
230
|
+
|
231
|
+
def get_bib_journal(args, text)
|
232
|
+
formatted_inline("title", text)
|
233
|
+
end
|
234
|
+
|
235
|
+
def get_bib_pages(args, text)
|
236
|
+
formatted_inline("pagenums", text)
|
237
|
+
end
|
238
|
+
|
239
|
+
def get_bib_publisher(args, text)
|
240
|
+
formatted_block("publisher", formatted_inline("publishername", text), nil, args)
|
241
|
+
end
|
242
|
+
|
243
|
+
def get_bib_title(args, text)
|
244
|
+
formatted_inline("title", text)
|
245
|
+
end
|
246
|
+
|
247
|
+
def get_bib_volume(args, text)
|
248
|
+
formatted_inline("volumenum", text)
|
249
|
+
end
|
250
|
+
|
251
|
+
def get_bib_number(args, text)
|
252
|
+
formatted_inline("issuenum", text)
|
253
|
+
end
|
254
|
+
|
255
|
+
def docbook_bib_sorted_values(entry)
|
256
|
+
keys = ["author", "title", "editor", "booktitle", "publisher", "journal", "volume", "number", "pages", "year"]
|
257
|
+
entry = entry.sort {|a, b| keys.index(a[0]) <=> keys.index(b[0])}
|
258
|
+
entry.collect {|a| a[1..-1]}.flatten
|
259
|
+
end
|
260
|
+
|
261
|
+
def docbook_bib_relation(args, typeEntry, entry, typeContainer, container)
|
262
|
+
e = join_blocks(docbook_bib_sorted_values(entry))
|
263
|
+
e = formatted_block("biblioset", e, {"relation" => typeEntry}, args)
|
264
|
+
c = join_blocks(docbook_bib_sorted_values(container))
|
265
|
+
c = formatted_block("biblioset", c, {"relation" => typeContainer}, args)
|
266
|
+
return join_blocks([e, c])
|
267
|
+
end
|
268
|
+
|
269
|
+
def get_bib_relation(args, type, entry, container)
|
270
|
+
if type
|
271
|
+
case type.downcase
|
272
|
+
when "article"
|
273
|
+
return docbook_bib_relation(args, "article", entry, "journal", container)
|
274
|
+
when "incollection"
|
275
|
+
# is this ok???
|
276
|
+
return docbook_bib_relation(args, "article", entry, "book", container)
|
277
|
+
end
|
278
|
+
else
|
279
|
+
args[:self].log(["No bib entry type given", entry], :error)
|
280
|
+
end
|
281
|
+
join_blocks(docbook_bib_sorted_values(entry.update(container)))
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
# Text
|
286
|
+
def get_block_abstract(args, text)
|
287
|
+
return formatted_block("abstract", text, nil, args)
|
288
|
+
end
|
289
|
+
|
290
|
+
def get_block_longquote(args, text)
|
291
|
+
return formatted_block("blockquote", text, nil, args)
|
292
|
+
end
|
293
|
+
|
294
|
+
def get_block_quote(args, text)
|
295
|
+
return formatted_block("blockquote", text, nil, args)
|
296
|
+
end
|
297
|
+
|
298
|
+
def get_note(args, marker, text)
|
299
|
+
case marker
|
300
|
+
when '#'
|
301
|
+
tag = 'note'
|
302
|
+
when '+'
|
303
|
+
tag = 'warning'
|
304
|
+
when '?'
|
305
|
+
tag = 'caution'
|
306
|
+
when '!'
|
307
|
+
tag = 'important'
|
308
|
+
else
|
309
|
+
log(['Unknown marker', marker], :error)
|
310
|
+
tag = 'note'
|
311
|
+
end
|
312
|
+
return formatted_block(tag, formatted_inline('para', text), nil, args)
|
313
|
+
end
|
314
|
+
|
315
|
+
def get_pre_format(args, text)
|
316
|
+
return formatted_block('screen', %{<![CDATA[#{text}]]>}, nil, args, false, true)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Lists, Contents
|
320
|
+
# get_contents_open(args, prefix)
|
321
|
+
noop self, 'get_contents_open'
|
322
|
+
# get_contents_close(args, prefix)
|
323
|
+
noop self, 'get_contents_close'
|
324
|
+
# get_contents_list(args, prefix, list)
|
325
|
+
noop self, 'get_contents_list'
|
326
|
+
|
327
|
+
# get_list_of_tables(args, data)
|
328
|
+
noop self, 'get_list_of_tables'
|
329
|
+
# get_list_of_figures(args, data)
|
330
|
+
noop self, 'get_list_of_figures'
|
331
|
+
|
332
|
+
def get_item_paragraph(args, item, text)
|
333
|
+
formatted_inline('para', text)
|
334
|
+
end
|
335
|
+
|
336
|
+
def get_list_description_open(args)
|
337
|
+
get_open('variablelist', nil, args)
|
338
|
+
end
|
339
|
+
|
340
|
+
def get_list_description_close(args)
|
341
|
+
get_close('variablelist', args)
|
342
|
+
end
|
343
|
+
|
344
|
+
def get_item_description_open(args, item, text)
|
345
|
+
text = indent_text(formatted_inline('para', text))
|
346
|
+
list = get_open('varlistentry', nil, args, :no_id => true)
|
347
|
+
term = formatted_inline('term', item, nil, args, true)
|
348
|
+
item = get_open('listitem', nil, args, :no_id => true)
|
349
|
+
idt = format_indent(1)
|
350
|
+
join_blocks([list, idt + term, idt + item, text])
|
351
|
+
end
|
352
|
+
|
353
|
+
def get_item_description_close(args)
|
354
|
+
idt = format_indent(1)
|
355
|
+
join_blocks([idt + get_close('listitem'), get_close('varlistentry')])
|
356
|
+
end
|
357
|
+
|
358
|
+
# itemize
|
359
|
+
def get_list_itemize_open(args)
|
360
|
+
get_open('itemizedlist', nil, args)
|
361
|
+
end
|
362
|
+
|
363
|
+
def get_list_itemize_close(args)
|
364
|
+
get_close('itemizedlist')
|
365
|
+
end
|
366
|
+
|
367
|
+
def get_item_itemize_open(args, item, text)
|
368
|
+
item = get_open('listitem', nil, args, :no_id => true)
|
369
|
+
join_blocks([item, indent_text(formatted_inline('para', text))])
|
370
|
+
end
|
371
|
+
|
372
|
+
def get_item_itemize_close(args)
|
373
|
+
get_close('listitem')
|
374
|
+
end
|
375
|
+
|
376
|
+
# numbered
|
377
|
+
def get_list_numbered_open(args, subtype)
|
378
|
+
opts = {}
|
379
|
+
case subtype
|
380
|
+
when 'a'
|
381
|
+
opts['numeration'] = 'loweralpha'
|
382
|
+
when 'A'
|
383
|
+
opts['numeration'] = 'upperalpha'
|
384
|
+
# when '1'
|
385
|
+
# num = 'arabic'
|
386
|
+
# else
|
387
|
+
# num = 'arabic'
|
388
|
+
end
|
389
|
+
get_open('orderedlist', opts, args)
|
390
|
+
end
|
391
|
+
|
392
|
+
def get_list_numbered_close(args)
|
393
|
+
get_close('orderedlist')
|
394
|
+
end
|
395
|
+
|
396
|
+
### +++ explicitely numbered lists +++
|
397
|
+
def get_item_numbered_open(args, item, text)
|
398
|
+
item = get_open('listitem', nil, args, :no_id => true)
|
399
|
+
join_blocks([item, indent_text(formatted_inline('para', text))])
|
400
|
+
end
|
401
|
+
|
402
|
+
def get_item_numbered_close(args)
|
403
|
+
get_close('listitem')
|
404
|
+
end
|
405
|
+
|
406
|
+
|
407
|
+
# Textstyles
|
408
|
+
def get_subscript(args, text)
|
409
|
+
formatted_inline('subscript', text)
|
410
|
+
end
|
411
|
+
|
412
|
+
def get_superscript(args, text)
|
413
|
+
formatted_inline('superscript', text)
|
414
|
+
end
|
415
|
+
|
416
|
+
# def get_stacked(args, above, below)
|
417
|
+
# +++
|
418
|
+
# end
|
419
|
+
|
420
|
+
|
421
|
+
# Figures
|
422
|
+
def get_figure_caption(args, title, text, capAbove)
|
423
|
+
formatted_inline('title', text)
|
424
|
+
end
|
425
|
+
|
426
|
+
def get_figure(args, cap, img)
|
427
|
+
if cap
|
428
|
+
formatted_block('figure', join_blocks([cap, img]), nil, args)
|
429
|
+
else
|
430
|
+
formatted_block('informalfigure', img, nil, args)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
def get_image(args, file, fnroot, inline=false)
|
435
|
+
o = {}
|
436
|
+
w = args['w'] || args['width']
|
437
|
+
# h = args['h'] || args['heigth']
|
438
|
+
unless w
|
439
|
+
desc = Deplate::External.image_dimension(File.join(@deplate.options.dir, file))
|
440
|
+
w, h, bx, by = desc[:bw]
|
441
|
+
end
|
442
|
+
o['width'] = w if w
|
443
|
+
# o << %{height='#{h}'} if h
|
444
|
+
o['fileref'] = file
|
445
|
+
img = formatted_block('imageobject', formatted_single('imagedata', o))
|
446
|
+
acc = [img]
|
447
|
+
alt = args['alt']
|
448
|
+
if alt
|
449
|
+
acc << formatted_inline('textobject', formatted_inline('phrase', alt))
|
450
|
+
end
|
451
|
+
img = join_blocks(acc)
|
452
|
+
if inline
|
453
|
+
formatted_block('inlinemediaobject', img, nil, args)
|
454
|
+
else
|
455
|
+
formatted_block('mediaobject', img, nil, args)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
def image_suffixes
|
460
|
+
['.png', '.jpeg', '.jpg', '.gif', '.bmp']
|
461
|
+
end
|
462
|
+
|
463
|
+
|
464
|
+
# Header, Footer
|
465
|
+
# get_footer(args, text)
|
466
|
+
noop self, 'get_footer'
|
467
|
+
# get_header(args, text)
|
468
|
+
noop self, 'get_header'
|
469
|
+
|
470
|
+
# Footnote
|
471
|
+
def get_footnote(args, label, text)
|
472
|
+
formatted_block('footnote', formatted_inline('para', text), {'id'=>label}, args)
|
473
|
+
end
|
474
|
+
|
475
|
+
def get_footnote_ref(args, label, text)
|
476
|
+
formatted_single('footnoteref', {'linkend' => label})
|
477
|
+
end
|
478
|
+
|
479
|
+
|
480
|
+
# Sections, Headings
|
481
|
+
def get_heading_open(args, level, numbering, text, label)
|
482
|
+
hd = @headings[level - 1]
|
483
|
+
id = encode_id(args[:id])
|
484
|
+
if hd
|
485
|
+
plain = @deplate.variables['headings'] == 'plain' || args['plain']
|
486
|
+
id = encode_id(args['shortcaption'] || text) if id.empty? or plain
|
487
|
+
ho = {}
|
488
|
+
ho['id'] = id unless id.empty?
|
489
|
+
if plain
|
490
|
+
xreflabel = id
|
491
|
+
ho['xreflabel'] = xreflabel
|
492
|
+
else
|
493
|
+
ho['label'] = args[:level_as_string].split(/\./).last
|
494
|
+
# ho['label'] = args[:level_as_string]
|
495
|
+
xreflabel = encode_id(args[:level_as_string])
|
496
|
+
ho['xreflabel'] = xreflabel
|
497
|
+
end
|
498
|
+
hd = get_open(hd, ho, args)
|
499
|
+
unless id.empty?
|
500
|
+
to = {'id' => "#{id}_title"}
|
501
|
+
to['xreflabel'] = xreflabel
|
502
|
+
end
|
503
|
+
ti = formatted_inline('title', text, to, args)
|
504
|
+
return join_blocks([hd, ti, label])
|
505
|
+
else
|
506
|
+
label << id unless id.empty?
|
507
|
+
get_paragraph(args, text, label)
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
def get_heading_close(args, level)
|
512
|
+
hd = @headings[level - 1]
|
513
|
+
if hd
|
514
|
+
get_close(hd)
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
|
519
|
+
# Index
|
520
|
+
def get_index(args, id, text)
|
521
|
+
prim = formatted_inline("primary", text)
|
522
|
+
formatted_inline("indexterm", prim, {"id" => encode_id(id)}, args)
|
523
|
+
end
|
524
|
+
|
525
|
+
def get_list_of_index(args, data)
|
526
|
+
join_blocks([close_headings(1), formatted_single("index", nil, args)])
|
527
|
+
end
|
528
|
+
|
529
|
+
# get_index_open(args)
|
530
|
+
noop self, :get_index_open
|
531
|
+
|
532
|
+
# get_index_close(args)
|
533
|
+
noop self, :get_index_close
|
534
|
+
|
535
|
+
# get_index_group_open(args)
|
536
|
+
noop self, :get_index_group_open
|
537
|
+
|
538
|
+
# get_index_group_close(args)
|
539
|
+
noop self, :get_index_group_close
|
540
|
+
|
541
|
+
# get_index_item(args, labels, text, references)
|
542
|
+
noop self, :get_index_item
|
543
|
+
|
544
|
+
# get_index_toc_open(args)
|
545
|
+
noop self, :get_index_toc_open
|
546
|
+
|
547
|
+
# get_index_toc_close(args)
|
548
|
+
noop self, :get_index_toc_close
|
549
|
+
|
550
|
+
# get_index_toc_entry(args, char, label)
|
551
|
+
noop self, :get_index_toc_entry
|
552
|
+
|
553
|
+
|
554
|
+
# Labels, References
|
555
|
+
def get_label(args, label, mode, text="")
|
556
|
+
case mode
|
557
|
+
when :after, :closeOpen
|
558
|
+
text
|
559
|
+
else
|
560
|
+
join_inline([formatted_single("anchor", {"id" => encode_id(label)}), text])
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
def get_ref(args, file, label, heading=nil)
|
565
|
+
if label
|
566
|
+
if file.empty? and heading
|
567
|
+
if @sgml
|
568
|
+
o = @deplate.label_aliases[label]
|
569
|
+
text = o.args[:level_as_string]
|
570
|
+
formatted_inline("link", text, {"linkend" => label}, args)
|
571
|
+
else
|
572
|
+
opts = {"linkend" => encode_id(label), 'endterm' => "#{heading}_title"}
|
573
|
+
return formatted_single("xref", opts, args)
|
574
|
+
end
|
575
|
+
else
|
576
|
+
url = [file, label].join("#")
|
577
|
+
return formatted_inline("ulink", text, {"url" => "file://%s" % url}, args)
|
578
|
+
end
|
579
|
+
else
|
580
|
+
args[:self].log("No label", :error)
|
581
|
+
return ""
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
|
586
|
+
# Paragraphs, Linebreaks, Pagebreaks
|
587
|
+
def get_linebreak(args, container)
|
588
|
+
case container.class
|
589
|
+
when Deplate::Element::Paragraph
|
590
|
+
# well
|
591
|
+
%{</para><para>}
|
592
|
+
else
|
593
|
+
log(["Don't know how to insert linebreaks", container.class], :error)
|
594
|
+
""
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
def get_pagebreak(args)
|
599
|
+
formatted_single("beginpage", nil, args)
|
600
|
+
end
|
601
|
+
|
602
|
+
def get_paragraph(args, text, labels=[])
|
603
|
+
acc = []
|
604
|
+
for l in use_labels(args, labels)
|
605
|
+
acc << get_label(args, l, :string)
|
606
|
+
end
|
607
|
+
acc << text
|
608
|
+
text = join_blocks(acc)
|
609
|
+
return formatted_inline("para", text, nil, args)
|
610
|
+
end
|
611
|
+
|
612
|
+
|
613
|
+
# Table
|
614
|
+
def get_table(args, title, table)
|
615
|
+
opts = {}
|
616
|
+
frame = args["frame"] || @deplate.variables["tableFrame"] || "topbot"
|
617
|
+
if frame
|
618
|
+
opts["frame"] = frame
|
619
|
+
end
|
620
|
+
if title
|
621
|
+
formatted_block("table", join_blocks([title, table]), opts, args)
|
622
|
+
else
|
623
|
+
formatted_block("informaltable", table, opts, args)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
def get_table_order
|
628
|
+
["head", "foot", "body"]
|
629
|
+
end
|
630
|
+
|
631
|
+
def get_table_caption(args, title, text, capAbove)
|
632
|
+
formatted_inline("title", text)
|
633
|
+
end
|
634
|
+
|
635
|
+
def get_table_group_open(args, n)
|
636
|
+
acc = [get_open("tgroup", {"cols" => n}, args, :no_id => true)]
|
637
|
+
|
638
|
+
colwidths = Deplate::Core.props(args["cols"], "w")
|
639
|
+
coljusts = Deplate::Core.props(args["cols"], "j")
|
640
|
+
names = []
|
641
|
+
for i in 0 .. n - 1
|
642
|
+
col = {}
|
643
|
+
|
644
|
+
name = "c#{i}"
|
645
|
+
col["colname"] = name
|
646
|
+
names << name
|
647
|
+
|
648
|
+
w = colwidths[i]
|
649
|
+
if w and !w.empty?
|
650
|
+
col["colwidth"] = w
|
651
|
+
end
|
652
|
+
|
653
|
+
j = coljusts[i]
|
654
|
+
if j and !j.empty?
|
655
|
+
col["align"] = j
|
656
|
+
end
|
657
|
+
acc << formatted_single("colspec", col, args, true)
|
658
|
+
end
|
659
|
+
args[:colnames] = names
|
660
|
+
join_blocks(acc)
|
661
|
+
end
|
662
|
+
|
663
|
+
def get_table_group_close(args)
|
664
|
+
get_close("tgroup")
|
665
|
+
end
|
666
|
+
|
667
|
+
def get_table_head_open(args)
|
668
|
+
get_open("thead", nil, args, :no_id => true)
|
669
|
+
end
|
670
|
+
|
671
|
+
def get_table_head_close(args)
|
672
|
+
get_close("thead")
|
673
|
+
end
|
674
|
+
|
675
|
+
def get_table_foot_open(args)
|
676
|
+
get_open("tfoot", nil, args, :no_id => true)
|
677
|
+
end
|
678
|
+
|
679
|
+
def get_table_foot_close(args)
|
680
|
+
get_close("tfoot")
|
681
|
+
end
|
682
|
+
|
683
|
+
def get_table_body_open(args)
|
684
|
+
get_open("tbody", nil, args, :no_id => true)
|
685
|
+
end
|
686
|
+
|
687
|
+
def get_table_body_close(args)
|
688
|
+
get_close("tbody")
|
689
|
+
end
|
690
|
+
|
691
|
+
def get_table_head_cell(args, text, rown, coln, span_x=1, span_y=1)
|
692
|
+
entry_args = {}
|
693
|
+
if span_y > 1
|
694
|
+
entry_args["morerows"] = span_y - 1
|
695
|
+
end
|
696
|
+
formatted_block("entry", formatted_inline("para", text), entry_args)
|
697
|
+
end
|
698
|
+
|
699
|
+
def get_table_cell(args, text, rown, coln, span_x=1, span_y=1)
|
700
|
+
entry_args = {}
|
701
|
+
if span_y > 1
|
702
|
+
entry_args["morerows"] = span_y - 1
|
703
|
+
end
|
704
|
+
if span_x > 1
|
705
|
+
start = args[:colnames][coln]
|
706
|
+
entry_args["namest"] = start
|
707
|
+
entry_args["nameend"] = args[:colnames][coln + span_x - 1]
|
708
|
+
end
|
709
|
+
formatted_block("entry", formatted_inline("para", text), entry_args)
|
710
|
+
end
|
711
|
+
|
712
|
+
def get_table_note(args, note)
|
713
|
+
formatted_inline("para", note)
|
714
|
+
end
|
715
|
+
|
716
|
+
def get_table_row_open(args)
|
717
|
+
get_open("row", nil, args, :no_id => true)
|
718
|
+
end
|
719
|
+
|
720
|
+
def get_table_row_close(args)
|
721
|
+
get_close("row")
|
722
|
+
end
|
723
|
+
|
724
|
+
|
725
|
+
# Title
|
726
|
+
noop self, "format_title"
|
727
|
+
# get_title(args, data, pagebreak)
|
728
|
+
noop self, "get_title"
|
729
|
+
# get_title_author(args, text)
|
730
|
+
noop self, "get_title_author"
|
731
|
+
# get_title_authornote(args, text)
|
732
|
+
noop self, "get_title_authornote"
|
733
|
+
# get_title_date(args, text)
|
734
|
+
noop self, "get_title_date"
|
735
|
+
# get_title_title(args, text)
|
736
|
+
noop self, "get_title_title"
|
737
|
+
end
|
738
|
+
|