deplate 0.7.3 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/AUTHORS.TXT +3 -0
  2. data/CHANGES.TXT +248 -175
  3. data/LICENSE.TXT +0 -0
  4. data/NEWS.TXT +28 -24
  5. data/README.TXT +0 -0
  6. data/TODO.TXT +174 -88
  7. data/VERSION.TXT +1 -1
  8. data/bin/deplate +0 -0
  9. data/bin/deplate.bat +0 -0
  10. data/etc/deplate.ini +91 -3
  11. data/lib/action_view/helpers/deplate.rb +45 -0
  12. data/lib/deplate.rb +6 -1
  13. data/lib/deplate/abstract-class.rb +0 -0
  14. data/lib/deplate/bib.rb +576 -0
  15. data/lib/deplate/builtin.rb +0 -0
  16. data/lib/deplate/cache.rb +55 -5
  17. data/lib/deplate/commands.rb +346 -183
  18. data/lib/deplate/common.rb +209 -48
  19. data/lib/deplate/converter.rb +12 -6
  20. data/lib/deplate/core.rb +777 -378
  21. data/lib/deplate/counters.rb +254 -0
  22. data/lib/deplate/css/article.css +4 -3
  23. data/lib/deplate/css/deplate.css +121 -5
  24. data/lib/deplate/css/heading-navbar.css +0 -0
  25. data/lib/deplate/css/layout-deplate-print.css +0 -0
  26. data/lib/deplate/css/layout-deplate.css +0 -0
  27. data/lib/deplate/css/sans-serif.css +0 -0
  28. data/lib/deplate/css/serif-e.css +0 -0
  29. data/lib/deplate/css/serif-rel.css +0 -0
  30. data/lib/deplate/css/serif.css +9 -3
  31. data/lib/deplate/css/slides.css +0 -0
  32. data/lib/deplate/css/tabbar-left.css +0 -0
  33. data/lib/deplate/css/tabbar-right-ie.css +3 -9
  34. data/lib/deplate/css/tabbar-right.css +51 -18
  35. data/lib/deplate/css/tabbar-top.css +7 -1
  36. data/lib/deplate/css/tabbar.css +0 -0
  37. data/lib/deplate/css/text-sans-serif.css +0 -0
  38. data/lib/deplate/css/text-serif.css +0 -0
  39. data/lib/deplate/define.rb +183 -177
  40. data/lib/deplate/deplate-string.rb +82 -0
  41. data/lib/deplate/docbook.rb +236 -128
  42. data/lib/deplate/elements.rb +584 -417
  43. data/lib/deplate/etc.rb +163 -101
  44. data/lib/deplate/external.rb +42 -11
  45. data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
  46. data/lib/deplate/fmt/dbk-article.rb +0 -0
  47. data/lib/deplate/fmt/dbk-book.rb +0 -0
  48. data/lib/deplate/fmt/dbk-ref.rb +3 -3
  49. data/lib/deplate/fmt/dbk-slides.rb +0 -0
  50. data/lib/deplate/fmt/dbk-snippet.rb +0 -0
  51. data/lib/deplate/fmt/html-snippet.rb +0 -0
  52. data/lib/deplate/fmt/html.rb +783 -550
  53. data/lib/deplate/fmt/htmlsite.rb +192 -199
  54. data/lib/deplate/fmt/htmlslides.rb +0 -0
  55. data/lib/deplate/fmt/htmlwebsite.rb +3 -3
  56. data/lib/deplate/fmt/latex-snippet.rb +0 -0
  57. data/lib/deplate/fmt/latex.rb +242 -83
  58. data/lib/deplate/fmt/null.rb +32 -0
  59. data/lib/deplate/fmt/php.rb +4 -4
  60. data/lib/deplate/fmt/phpsite.rb +6 -5
  61. data/lib/deplate/fmt/plain.rb +160 -106
  62. data/lib/deplate/fmt/template.rb +0 -0
  63. data/lib/deplate/fmt/xhtml10t.rb +0 -0
  64. data/lib/deplate/formatter-snippet.rb +0 -0
  65. data/lib/deplate/formatter.rb +613 -301
  66. data/lib/deplate/input.rb +202 -142
  67. data/lib/deplate/input/deplate-headings.rb +4 -6
  68. data/lib/deplate/input/deplate-restricted.rb +15 -9
  69. data/lib/deplate/input/deplate.rb +2 -4
  70. data/lib/deplate/input/rdoc.rb +39 -38
  71. data/lib/deplate/input/template.rb +0 -0
  72. data/lib/deplate/lib/Makefile.config +29 -0
  73. data/lib/deplate/lib/latex/deplate.sty +54 -0
  74. data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
  75. data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
  76. data/lib/deplate/lib/php/page-comment.inc.php +216 -0
  77. data/lib/deplate/lib/tabmenu.js +0 -0
  78. data/lib/deplate/locale/de.latin1 +155 -17
  79. data/lib/deplate/locale/ru.koi8-r +0 -0
  80. data/lib/deplate/locale/zh_cn.gb2312 +0 -0
  81. data/lib/deplate/macros.rb +133 -82
  82. data/lib/deplate/messages.rb +6 -4
  83. data/lib/deplate/metadata.rb +0 -0
  84. data/lib/deplate/metadata/marshal.rb +0 -0
  85. data/lib/deplate/metadata/xml.rb +0 -0
  86. data/lib/deplate/metadata/yaml.rb +0 -0
  87. data/lib/deplate/mod/anyword.rb +3 -3
  88. data/lib/deplate/mod/babelfish.rb +4 -4
  89. data/lib/deplate/mod/code-gvim.rb +8 -4
  90. data/lib/deplate/mod/code-highlight.rb +3 -3
  91. data/lib/deplate/mod/colored-log.rb +0 -0
  92. data/lib/deplate/mod/de.rb +2 -2
  93. data/lib/deplate/mod/en.rb +0 -0
  94. data/lib/deplate/mod/endnotes.rb +0 -0
  95. data/lib/deplate/mod/fr.rb +0 -0
  96. data/lib/deplate/mod/html-asciimath.rb +0 -0
  97. data/lib/deplate/mod/html-deplate-button.rb +0 -0
  98. data/lib/deplate/mod/html-headings-navbar.rb +5 -13
  99. data/lib/deplate/mod/html-jsmath.rb +39 -0
  100. data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
  101. data/lib/deplate/mod/html-sidebar.rb +0 -0
  102. data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
  103. data/lib/deplate/mod/iconv.rb +0 -0
  104. data/lib/deplate/mod/imgurl.rb +4 -4
  105. data/lib/deplate/mod/inlatex-compound.rb +7 -10
  106. data/lib/deplate/mod/koma.rb +0 -0
  107. data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
  108. data/lib/deplate/mod/latex-styles.rb +7 -4
  109. data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
  110. data/lib/deplate/mod/makefile.rb +23 -7
  111. data/lib/deplate/mod/mark-external-urls.rb +3 -3
  112. data/lib/deplate/mod/markup-1-warn.rb +10 -10
  113. data/lib/deplate/mod/markup-1.rb +0 -0
  114. data/lib/deplate/mod/navbar-png.rb +24 -8
  115. data/lib/deplate/mod/noindent.rb +0 -0
  116. data/lib/deplate/mod/numpara.rb +0 -0
  117. data/lib/deplate/mod/particle-math.rb +4 -4
  118. data/lib/deplate/mod/php-extra.rb +46 -6
  119. data/lib/deplate/mod/pstoedit.rb +0 -0
  120. data/lib/deplate/mod/recode.rb +0 -0
  121. data/lib/deplate/mod/ru_koi8-r.rb +0 -0
  122. data/lib/deplate/mod/smart-dash.rb +26 -0
  123. data/lib/deplate/mod/smiley.rb +69 -7
  124. data/lib/deplate/mod/soffice.rb +0 -0
  125. data/lib/deplate/mod/symbols-latin1.rb +14 -23
  126. data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
  127. data/lib/deplate/mod/symbols-plain.rb +5 -35
  128. data/lib/deplate/mod/symbols-sgml.rb +8 -9
  129. data/lib/deplate/mod/symbols-utf-8.rb +8 -9
  130. data/lib/deplate/mod/symbols-xml.rb +5 -9
  131. data/lib/deplate/mod/syntax-region-alt.rb +5 -5
  132. data/lib/deplate/mod/utf8.rb +0 -0
  133. data/lib/deplate/mod/validate-html.rb +0 -0
  134. data/lib/deplate/mod/xmlrpc.rb +0 -0
  135. data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
  136. data/lib/deplate/mod/zh-cn.rb +4 -6
  137. data/lib/deplate/nukumi2.rb +71 -0
  138. data/lib/deplate/once-method.rb +0 -0
  139. data/lib/deplate/output.rb +19 -21
  140. data/lib/deplate/particles.rb +178 -116
  141. data/lib/deplate/regions.rb +99 -58
  142. data/lib/deplate/skeletons.rb +122 -0
  143. data/lib/deplate/structured.rb +164 -106
  144. data/lib/deplate/template.rb +67 -43
  145. data/lib/deplate/templates/html-doc.html +0 -0
  146. data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
  147. data/lib/deplate/templates/html-left-tabbar.html +0 -0
  148. data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
  149. data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
  150. data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
  151. data/lib/deplate/templates/html-tabbar-right.html +2 -4
  152. data/lib/deplate/templates/html-tabbar-top.html +0 -9
  153. data/lib/deplate/templates/html-tabbar.html +0 -0
  154. data/lib/deplate/variables.rb +127 -0
  155. data/lib/deplate/wiki-markup.rb +99 -33
  156. data/lib/deplate/xml.rb +18 -18
  157. data/lib/deplate/zh-cn.rb +0 -0
  158. data/lib/ps2ppm.rb +0 -0
  159. data/man/man1/deplate.1 +564 -474
  160. metadata +201 -186
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+ # deplate-string.rb
3
+ # @Author: Thomas Link (samul AT web de)
4
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
+ # @Created: 31-Dez-2005.
6
+ # @Last Change: 03-Jan-2006.
7
+ # @Revision: 0.39
8
+
9
+ require 'deplate/converter'
10
+
11
+ class DeplateString < String
12
+ @deplate_options = Deplate::Core.deplate_options
13
+ @deplate_options.included = true
14
+
15
+ class << self
16
+ attr_reader :deplate_options
17
+ end
18
+
19
+ attr_reader :deplate_options
20
+ attr_reader :deplate_variables
21
+ attr_reader :deplate_converter
22
+
23
+ def initialize(*args)
24
+ @deplate_options = self.class.deplate_options.dup
25
+ super
26
+ end
27
+
28
+ def with_deplate_options(&block)
29
+ block.call(@deplate_options)
30
+ end
31
+
32
+ def deplate(fmt)
33
+ @deplate_converter = Deplate::Converter.new(fmt,
34
+ :options => @deplate_options)
35
+ rv = @deplate_converter.convert_string(self)
36
+ @deplate_variables = @deplate_converter.deplate.variables
37
+ rv
38
+ end
39
+
40
+ def to_html
41
+ deplate('html')
42
+ end
43
+
44
+ def to_xhtml
45
+ deplate('xhtml10t')
46
+ end
47
+
48
+ def to_latex
49
+ deplate('latex')
50
+ end
51
+
52
+ def to_tex
53
+ deplate('latex')
54
+ end
55
+
56
+ def to_text
57
+ deplate('plain')
58
+ end
59
+
60
+ def to_dbk
61
+ deplate('dbk-article')
62
+ end
63
+ end
64
+
65
+
66
+ if __FILE__ == $0
67
+ puts DeplateString.new('bar __foo__ bar').to_html
68
+ puts DeplateString.new('bar __foo__ bar').to_xhtml
69
+ puts DeplateString.new('bar __foo__ bar').to_tex
70
+ puts DeplateString.new('bar __foo__ bar').to_text
71
+ puts DeplateString.new('bar __foo__ bar').to_dbk
72
+
73
+ t = <<EOF
74
+ * Introduction
75
+
76
+ ''deplate'' is a tool for converting wiki-like markup to latex, html, or
77
+ "html-slides".
78
+ EOF
79
+
80
+ puts DeplateString.new(t).to_html
81
+ end
82
+
@@ -3,10 +3,10 @@
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 17-M�r-2004.
6
- # @Last Change: 01-Nov-2005.
7
- # @Revision: 0.2651
6
+ # @Last Change: 05-Jun-2006.
7
+ # @Revision: 0.2735
8
8
 
9
- require "deplate/xml"
9
+ require 'deplate/xml'
10
10
 
11
11
  # An abstract docbook formatter
12
12
 
@@ -24,27 +24,27 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
24
24
  args ||= {}
25
25
  unless no_id
26
26
  id = use_id(args, opts)
27
- oid = opts["id"]
27
+ oid = opts['id']
28
28
  if oid and oid != id
29
- log(["ID mismatch", id, oid, opts, args], :error)
29
+ log(['ID mismatch', id, oid, opts, args], :error)
30
30
  end
31
- opts["id"] = encode_id(id) if id
31
+ opts['id'] = encode_id(id) if id
32
32
  # args = args.dup
33
- args.delete("id")
33
+ args.delete('id')
34
34
  end
35
- id = opts["id"]
35
+ id = opts['id']
36
36
  if id
37
37
  if @consumed_ids.include?(id)
38
38
  opts = opts.dup
39
- opts.delete("id")
39
+ opts.delete('id')
40
40
  else
41
41
  @consumed_ids << id
42
42
  end
43
- opts["xreflabel"] ||= args[:level_as_string]
43
+ opts['xreflabel'] ||= args[:level_as_string]
44
44
  end
45
45
  opts = opts.collect do |k, v|
46
46
  case k
47
- when "linkend"
47
+ when 'linkend'
48
48
  v = encode_id(v)
49
49
  end
50
50
  if v
@@ -53,12 +53,12 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
53
53
  end
54
54
  if single
55
55
  if @sgml
56
- opts << "></%s" % tag
56
+ opts << '></%s' % tag
57
57
  else
58
- opts << "/"
58
+ opts << '/'
59
59
  end
60
60
  end
61
- %{<%s>} % [tag, *opts].compact.join(" ")
61
+ %{<%s>} % [tag, *opts].compact.join(' ')
62
62
  end
63
63
 
64
64
  def get_close(tag, args=nil)
@@ -88,19 +88,19 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
88
88
  author = []
89
89
  if au[:firstname] and au[:surname]
90
90
  firstname = @deplate.parse_and_format(nil, au[:firstname], false)
91
- author << formatted_inline("firstname", firstname)
91
+ author << formatted_inline('firstname', firstname)
92
92
  surname = @deplate.parse_and_format(nil, au[:surname], false)
93
- author << formatted_inline("surname", surname)
93
+ author << formatted_inline('surname', surname)
94
94
  else
95
95
  surname = @deplate.parse_and_format(nil, au[:name], false)
96
- author << formatted_inline("surname", surname)
96
+ author << formatted_inline('surname', surname)
97
97
  end
98
98
  acc << author.join
99
99
  if au[:note]
100
100
  authorblurb = @deplate.parse_and_format(nil, au[:note], false)
101
- acc << formatted_block("authorblurb", formatted_inline("para", authorblurb))
101
+ acc << formatted_block('authorblurb', formatted_inline('para', authorblurb))
102
102
  end
103
- accAuthors << formatted_block("author", join_blocks(acc))
103
+ accAuthors << formatted_block('author', join_blocks(acc))
104
104
  end
105
105
  return accAuthors
106
106
  end
@@ -111,28 +111,28 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
111
111
  authors = @deplate.options.author || []
112
112
  accAuthors = docbook_authors(authors)
113
113
  if authors.size > 1
114
- accum << formatted_block("authorgroup", join_blocks(accAuthors))
114
+ accum << formatted_block('authorgroup', join_blocks(accAuthors))
115
115
  else
116
116
  accum += accAuthors
117
117
  end
118
118
 
119
- date = @deplate.get_clip("date")
120
- date = date ? date.elt : Deplate::Element.get_date("today", nil)
121
- accum << formatted_inline("pubdate", date)
119
+ date = @deplate.get_clip('date')
120
+ date = date ? date.elt : Deplate::Element.get_date('today', nil)
121
+ accum << formatted_inline('pubdate', date)
122
122
 
123
- title = @deplate.get_clip("title")
124
- accum << formatted_inline("title", title.elt) if title
123
+ title = @deplate.get_clip('title')
124
+ accum << formatted_inline('title', title.elt) if title
125
125
 
126
126
  kw = keywords
127
127
  if kw
128
- kws = join_blocks(kw.collect {|kw| formatted_inline("keyword", kw)})
129
- accum << formatted_block("keywordset", kws)
128
+ kws = join_blocks(kw.collect {|kw| formatted_inline('keyword', kw)})
129
+ accum << formatted_block('keywordset', kws)
130
130
  end
131
131
 
132
- desc = @deplate.variables["description"]
132
+ desc = @deplate.variables['description']
133
133
  if desc
134
- para = formatted_inline("para", plain_text(desc))
135
- accum << formatted_block("abstract", para)
134
+ para = formatted_inline('para', plain_text(desc))
135
+ accum << formatted_block('abstract', para)
136
136
  end
137
137
 
138
138
  return join_blocks(accum)
@@ -141,12 +141,13 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
141
141
  def get_doc_def(args)
142
142
  version = @deplate.variables['dbkVersion'] || '4.2'
143
143
  type = @deplate.variables['dbkClass'] || 'article'
144
+ oldnew = @sgml ? 'sgml' : 'xml'
144
145
  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
+ dtd = @deplate.variables['dbkDtd'] || "http://www.oasis-open.org/docbook/#{oldnew}/#{version}/docbookx.dtd"
146
147
  docbook_doc_def(args, type, dbkid, dtd)
147
148
  end
148
149
 
149
- def docbook_doc_def(args, type, pub, dtd, xmlVersion="1.0")
150
+ def docbook_doc_def(args, type, pub, dtd, xmlVersion='1.0')
150
151
  encoding = @encoding ? %{ encoding="%s"} % @encoding : ""
151
152
 
152
153
  doc = [%{<?xml version='#{xmlVersion}'#{encoding}?>},
@@ -155,15 +156,15 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
155
156
  ]
156
157
  ent = get_entities(args)
157
158
  if ent
158
- doc.last << " ["
159
- doc << ent << "]"
159
+ doc.last << ' ['
160
+ doc << ent << ']'
160
161
  end
161
- doc.last << ">"
162
+ doc.last << '>'
162
163
  return join_blocks(doc.flatten.compact)
163
164
  end
164
165
 
165
166
  def get_entities(args)
166
- entities = args[:deplate].variables["dbkEntities"]
167
+ entities = args[:deplate].variables['dbkEntities']
167
168
  return join_blocks(entities) if entities
168
169
  end
169
170
 
@@ -172,40 +173,40 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
172
173
  end
173
174
 
174
175
  # get_doc_body_open(args)
175
- noop self, "get_doc_body_open"
176
+ noop self, 'get_doc_body_open'
176
177
 
177
178
  # get_doc_body_close(args)
178
- noop self, "get_doc_body_close"
179
+ noop self, 'get_doc_body_close'
179
180
 
180
181
  # Bibliography
181
182
  def get_bib(args, title, bib)
182
183
  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)
184
+ title = formatted_inline('title', title) if title and !args['plain']
185
+ acc << formatted_block('bibliography', join_blocks([title, bib].compact), nil, args)
185
186
  join_blocks(acc)
186
187
  end
187
188
 
188
189
  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)
190
+ body = join_blocks([formatted_inline('abbrev', key), entry])
191
+ return formatted_block('biblioentry', body, {'id' => encode_id(key)}, args)
191
192
  end
192
193
 
193
194
  def docbook_format_authors(type, args, text)
194
195
  if text
195
196
  acc = []
196
- for au in authors_split(text)
197
+ for au in Deplate::Core.authors_split(text)
197
198
  author = Deplate::Names.name_match_sf(au) || Deplate::Names.name_match_fs(au)
198
199
  if author
199
- surname = formatted_inline("surname", author[:surname])
200
- firstname = formatted_inline("firstname", author[:firstname])
200
+ surname = formatted_inline('surname', author[:surname])
201
+ firstname = formatted_inline('firstname', author[:firstname])
201
202
  acc << formatted_inline(type, surname + firstname)
202
203
  else
203
204
  # is this ok???
204
- acc << formatted_inline(type, formatted_inline("surname", au))
205
+ acc << formatted_inline(type, formatted_inline('surname', au))
205
206
  end
206
207
  end
207
208
  if acc.size > 1
208
- return formatted_block("authorgroup", join_blocks(acc), nil, args)
209
+ return formatted_block('authorgroup', join_blocks(acc), nil, args)
209
210
  else
210
211
  return join_blocks(acc)
211
212
  end
@@ -213,70 +214,70 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
213
214
  end
214
215
 
215
216
  def get_bib_author(args, text)
216
- docbook_format_authors("author", args, text)
217
+ docbook_format_authors('author', args, text)
217
218
  end
218
219
 
219
220
  def get_bib_year(args, text)
220
- formatted_inline("pubdate", text)
221
+ formatted_inline('pubdate', text)
221
222
  end
222
223
 
223
224
  def get_bib_booktitle(args, text)
224
- formatted_inline("title", text)
225
+ formatted_inline('title', text)
225
226
  end
226
227
 
227
228
  def get_bib_editor(args, text)
228
- docbook_format_authors("editor", args, text)
229
+ docbook_format_authors('editor', args, text)
229
230
  end
230
231
 
231
232
  def get_bib_journal(args, text)
232
- formatted_inline("title", text)
233
+ formatted_inline('title', text)
233
234
  end
234
235
 
235
236
  def get_bib_pages(args, text)
236
- formatted_inline("pagenums", text)
237
+ formatted_inline('pagenums', text)
237
238
  end
238
239
 
239
240
  def get_bib_publisher(args, text)
240
- formatted_block("publisher", formatted_inline("publishername", text), nil, args)
241
+ formatted_block('publisher', formatted_inline('publishername', text), nil, args)
241
242
  end
242
243
 
243
244
  def get_bib_title(args, text)
244
- formatted_inline("title", text)
245
+ formatted_inline('title', text)
245
246
  end
246
247
 
247
248
  def get_bib_volume(args, text)
248
- formatted_inline("volumenum", text)
249
+ formatted_inline('volumenum', text)
249
250
  end
250
251
 
251
252
  def get_bib_number(args, text)
252
- formatted_inline("issuenum", text)
253
+ formatted_inline('issuenum', text)
253
254
  end
254
255
 
255
256
  def docbook_bib_sorted_values(entry)
256
- keys = ["author", "title", "editor", "booktitle", "publisher", "journal", "volume", "number", "pages", "year"]
257
+ keys = ['author', 'title', 'editor', 'booktitle', 'publisher', 'journal', 'volume', 'number', 'pages', 'year']
257
258
  entry = entry.sort {|a, b| keys.index(a[0]) <=> keys.index(b[0])}
258
259
  entry.collect {|a| a[1..-1]}.flatten
259
260
  end
260
261
 
261
262
  def docbook_bib_relation(args, typeEntry, entry, typeContainer, container)
262
263
  e = join_blocks(docbook_bib_sorted_values(entry))
263
- e = formatted_block("biblioset", e, {"relation" => typeEntry}, args)
264
+ e = formatted_block('biblioset', e, {'relation' => typeEntry}, args)
264
265
  c = join_blocks(docbook_bib_sorted_values(container))
265
- c = formatted_block("biblioset", c, {"relation" => typeContainer}, args)
266
+ c = formatted_block('biblioset', c, {'relation' => typeContainer}, args)
266
267
  return join_blocks([e, c])
267
268
  end
268
269
 
269
270
  def get_bib_relation(args, type, entry, container)
270
271
  if type
271
272
  case type.downcase
272
- when "article"
273
- return docbook_bib_relation(args, "article", entry, "journal", container)
274
- when "incollection"
273
+ when 'article'
274
+ return docbook_bib_relation(args, 'article', entry, 'journal', container)
275
+ when 'incollection'
275
276
  # is this ok???
276
- return docbook_bib_relation(args, "article", entry, "book", container)
277
+ return docbook_bib_relation(args, 'article', entry, 'book', container)
277
278
  end
278
279
  else
279
- args[:self].log(["No bib entry type given", entry], :error)
280
+ args[:self].log(['No bib entry type given', entry], :error)
280
281
  end
281
282
  join_blocks(docbook_bib_sorted_values(entry.update(container)))
282
283
  end
@@ -284,15 +285,15 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
284
285
 
285
286
  # Text
286
287
  def get_block_abstract(args, text)
287
- return formatted_block("abstract", text, nil, args)
288
+ return formatted_block('abstract', text, nil, args)
288
289
  end
289
290
 
290
291
  def get_block_longquote(args, text)
291
- return formatted_block("blockquote", text, nil, args)
292
+ return formatted_block('blockquote', text, nil, args)
292
293
  end
293
294
 
294
295
  def get_block_quote(args, text)
295
- return formatted_block("blockquote", text, nil, args)
296
+ return formatted_block('blockquote', text, nil, args)
296
297
  end
297
298
 
298
299
  def get_note(args, marker, text)
@@ -329,6 +330,69 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
329
330
  # get_list_of_figures(args, data)
330
331
  noop self, 'get_list_of_figures'
331
332
 
333
+ def listing_prematter(invoker, args, id)
334
+ case args[:listing]
335
+ when 'toc'
336
+ get_open('lot', {:id => id}, args)
337
+ else
338
+ args[:id] ||= id
339
+ get_list_itemize_open(args)
340
+ end
341
+ end
342
+
343
+ def listing_postmatter(invoker, args)
344
+ case args[:listing]
345
+ when 'toc'
346
+ get_close('lot')
347
+ else
348
+ get_list_itemize_close(args)
349
+ end
350
+ end
351
+
352
+ def listing_title(invoker, args, name)
353
+ if name
354
+ # case args[:listing]
355
+ # when 'toc'
356
+ formatted_inline('title', @deplate.msg(name))
357
+ # else
358
+ # end
359
+ end
360
+ end
361
+
362
+ def listing_item(invoker, args, prefix, title, heading, level, other_args)
363
+ v = clean_tags(title)
364
+ # v = clean_tags(title, 'indexterm')
365
+ case other_args[:listing]
366
+ when 'toc'
367
+ v = [heading.level_as_string, v].join(' ') unless heading.plain_caption?
368
+ d = @deplate.elt_label(prefix, heading.level_as_string)
369
+ f = formatted_inline('lotentry', v, {'linkend' => d})
370
+ s = Deplate::ListItem.new(nil, nil, nil, nil, level, 0, true)
371
+ s.preformatted = [f, nil]
372
+ else
373
+ v = [heading.level_as_string, v].join(' ') unless heading.plain_caption?
374
+ d = @deplate.elt_label(prefix, heading.level_as_string)
375
+ s = Deplate::ListItem.new(nil, nil, nil, nil, level, 0, true)
376
+ f = join_blocks([
377
+ get_item_itemize_open(args, heading.level_as_string, v),
378
+ get_item_itemize_close(args)
379
+ ])
380
+ s.preformatted = [f, nil]
381
+ end
382
+ s
383
+ end
384
+
385
+ def clean_tags(text, *tags)
386
+ if text
387
+ tags = tags.empty? ? '\w+' : tags.join('|')
388
+ t = text.gsub(/<(#{tags}).*?>.*?<\/\1>|<(#{tags}).*?\/>/, '')
389
+ t.gsub!(/^\s*$/, '')
390
+ t.gsub!(/^\n\s*/, '')
391
+ t.gsub!(/\n\s*$/, '')
392
+ t
393
+ end
394
+ end
395
+
332
396
  def get_item_paragraph(args, item, text)
333
397
  formatted_inline('para', text)
334
398
  end
@@ -355,6 +419,31 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
355
419
  join_blocks([idt + get_close('listitem'), get_close('varlistentry')])
356
420
  end
357
421
 
422
+ # tasks
423
+ def get_list_task_open(args)
424
+ get_list_description_open(args)
425
+ end
426
+
427
+ def get_list_task_close(args)
428
+ get_list_description_close(args)
429
+ end
430
+
431
+ def get_item_task_open(args, item, text, opts)
432
+ pri = opts[:priority]
433
+ cat = opts[:category]
434
+ done = opts[:done] ? 'done' : nil
435
+ due = opts[:due]
436
+ task = [cat, pri]
437
+ task << " #{due}" if due
438
+ # task = ['{', task, '}'].join
439
+ task = task.join
440
+ get_item_description_open(args, task, text)
441
+ end
442
+
443
+ def get_item_task_close(args)
444
+ get_item_description_close(args)
445
+ end
446
+
358
447
  # itemize
359
448
  def get_list_itemize_open(args)
360
449
  get_open('itemizedlist', nil, args)
@@ -432,11 +521,16 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
432
521
  end
433
522
 
434
523
  def get_image(args, file, fnroot, inline=false)
524
+ if file =~ Deplate::HyperLink::Url.rx
525
+ Deplate::Core.log([%{Can't include remote images in current document}, file], :error)
526
+ file = File.basename(file)
527
+ end
435
528
  o = {}
436
529
  w = args['w'] || args['width']
437
530
  # h = args['h'] || args['heigth']
438
531
  unless w
439
- desc = Deplate::External.image_dimension(File.join(@deplate.options.dir, file))
532
+ ifile = Deplate::Core.file_join(@deplate.options.dir, file)
533
+ desc = Deplate::External.image_dimension(ifile)
440
534
  w, h, bx, by = desc[:bw]
441
535
  end
442
536
  o['width'] = w if w
@@ -469,7 +563,8 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
469
563
 
470
564
  # Footnote
471
565
  def get_footnote(args, label, text)
472
- formatted_block('footnote', formatted_inline('para', text), {'id'=>label}, args)
566
+ # formatted_block('footnote', formatted_inline('para', text), {'id'=>label}, args)
567
+ formatted_block('footnote', text, {'id'=>label}, args)
473
568
  end
474
569
 
475
570
  def get_footnote_ref(args, label, text)
@@ -482,26 +577,39 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
482
577
  hd = @headings[level - 1]
483
578
  id = encode_id(args[:id])
484
579
  if hd
485
- plain = @deplate.variables['headings'] == 'plain' || args['plain']
486
- id = encode_id(args['shortcaption'] || text) if id.empty? or plain
580
+ plain = @deplate.variables['headings'] == 'plain' || args['plain']
581
+ no_id = id.empty?
582
+ if no_id or plain
583
+ id = encode_id(args['shortcaption'] || text)
584
+ if no_id
585
+ args[:id] = id if no_id
586
+ args[:self].log(['Internal error: No ID', @args[:self].class, text, label], :error)
587
+ end
588
+ end
487
589
  ho = {}
488
- ho['id'] = id unless id.empty?
590
+ # ho['id'] = id unless id.empty?
591
+ ho['id'] = id
489
592
  if plain
490
593
  xreflabel = id
491
594
  ho['xreflabel'] = xreflabel
492
595
  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
596
+ xlab = args[:level_as_string]
597
+ if xlab
598
+ ho['label'] = xlab.split(/\./).last
599
+ # ho['label'] = args[:level_as_string]
600
+ xreflabel = encode_id(xlab)
601
+ ho['xreflabel'] = xreflabel
602
+ else
603
+ args[:self].log(['Internal error', 'No label'], :error)
604
+ end
497
605
  end
498
606
  hd = get_open(hd, ho, args)
499
- unless id.empty?
607
+ # unless id.empty?
500
608
  to = {'id' => "#{id}_title"}
501
609
  to['xreflabel'] = xreflabel
502
- end
610
+ # end
503
611
  ti = formatted_inline('title', text, to, args)
504
- return join_blocks([hd, ti, label])
612
+ return join_blocks([hd, indent_text(ti), indent_text(label)])
505
613
  else
506
614
  label << id unless id.empty?
507
615
  get_paragraph(args, text, label)
@@ -552,33 +660,33 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
552
660
 
553
661
 
554
662
  # Labels, References
555
- def get_label(args, label, mode, text="")
663
+ def get_label(args, label, mode, text='')
556
664
  case mode
557
665
  when :after, :closeOpen
558
666
  text
559
667
  else
560
- join_inline([formatted_single("anchor", {"id" => encode_id(label)}), text])
668
+ join_inline([formatted_single('anchor', {'id' => encode_id(label)}), text])
561
669
  end
562
670
  end
563
671
 
564
672
  def get_ref(args, file, label, heading=nil)
565
673
  if label
566
- if file.empty? and heading
674
+ if file.empty? and heading
567
675
  if @sgml
568
676
  o = @deplate.label_aliases[label]
569
677
  text = o.args[:level_as_string]
570
- formatted_inline("link", text, {"linkend" => label}, args)
678
+ formatted_inline('link', text, {'linkend' => label}, args)
571
679
  else
572
- opts = {"linkend" => encode_id(label), 'endterm' => "#{heading}_title"}
573
- return formatted_single("xref", opts, args)
680
+ opts = {'linkend' => encode_id(label), 'endterm' => "#{heading}_title"}
681
+ return formatted_single('xref', opts, args)
574
682
  end
575
683
  else
576
- url = [file, label].join("#")
577
- return formatted_inline("ulink", text, {"url" => "file://%s" % url}, args)
684
+ url = [file, label].join('#')
685
+ return formatted_inline('ulink', text, {'url' => 'file://%s' % url}, args)
578
686
  end
579
687
  else
580
- args[:self].log("No label", :error)
581
- return ""
688
+ args[:self].log('No label', :error)
689
+ return ''
582
690
  end
583
691
  end
584
692
 
@@ -591,12 +699,12 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
591
699
  %{</para><para>}
592
700
  else
593
701
  log(["Don't know how to insert linebreaks", container.class], :error)
594
- ""
702
+ ''
595
703
  end
596
704
  end
597
705
 
598
706
  def get_pagebreak(args)
599
- formatted_single("beginpage", nil, args)
707
+ formatted_single('beginpage', nil, args)
600
708
  end
601
709
 
602
710
  def get_paragraph(args, text, labels=[])
@@ -606,133 +714,133 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
606
714
  end
607
715
  acc << text
608
716
  text = join_blocks(acc)
609
- return formatted_inline("para", text, nil, args)
717
+ return formatted_inline('para', text, nil, args)
610
718
  end
611
719
 
612
720
 
613
721
  # Table
614
722
  def get_table(args, title, table)
615
723
  opts = {}
616
- frame = args["frame"] || @deplate.variables["tableFrame"] || "topbot"
724
+ frame = args['frame'] || @deplate.variables['tableFrame'] || 'topbot'
617
725
  if frame
618
- opts["frame"] = frame
726
+ opts['frame'] = frame
619
727
  end
620
728
  if title
621
- formatted_block("table", join_blocks([title, table]), opts, args)
729
+ formatted_block('table', join_blocks([title, table]), opts, args)
622
730
  else
623
- formatted_block("informaltable", table, opts, args)
731
+ formatted_block('informaltable', table, opts, args)
624
732
  end
625
733
  end
626
734
 
627
735
  def get_table_order
628
- ["head", "foot", "body"]
736
+ ['head', 'foot', 'body']
629
737
  end
630
738
 
631
739
  def get_table_caption(args, title, text, capAbove)
632
- formatted_inline("title", text)
740
+ formatted_inline('title', text)
633
741
  end
634
742
 
635
743
  def get_table_group_open(args, n)
636
- acc = [get_open("tgroup", {"cols" => n}, args, :no_id => true)]
744
+ acc = [get_open('tgroup', {'cols' => n}, args, :no_id => true)]
637
745
 
638
- colwidths = Deplate::Core.props(args["cols"], "w")
639
- coljusts = Deplate::Core.props(args["cols"], "j")
746
+ colwidths = Deplate::Core.props(args['cols'], 'w')
747
+ coljusts = Deplate::Core.props(args['cols'], 'j')
640
748
  names = []
641
749
  for i in 0 .. n - 1
642
750
  col = {}
643
751
 
644
752
  name = "c#{i}"
645
- col["colname"] = name
753
+ col['colname'] = name
646
754
  names << name
647
755
 
648
756
  w = colwidths[i]
649
757
  if w and !w.empty?
650
- col["colwidth"] = w
758
+ col['colwidth'] = w
651
759
  end
652
760
 
653
761
  j = coljusts[i]
654
762
  if j and !j.empty?
655
- col["align"] = j
763
+ col['align'] = j
656
764
  end
657
- acc << formatted_single("colspec", col, args, true)
765
+ acc << formatted_single('colspec', col, args, true)
658
766
  end
659
767
  args[:colnames] = names
660
768
  join_blocks(acc)
661
769
  end
662
770
 
663
771
  def get_table_group_close(args)
664
- get_close("tgroup")
772
+ get_close('tgroup')
665
773
  end
666
774
 
667
775
  def get_table_head_open(args)
668
- get_open("thead", nil, args, :no_id => true)
776
+ get_open('thead', nil, args, :no_id => true)
669
777
  end
670
778
 
671
779
  def get_table_head_close(args)
672
- get_close("thead")
780
+ get_close('thead')
673
781
  end
674
782
 
675
783
  def get_table_foot_open(args)
676
- get_open("tfoot", nil, args, :no_id => true)
784
+ get_open('tfoot', nil, args, :no_id => true)
677
785
  end
678
786
 
679
787
  def get_table_foot_close(args)
680
- get_close("tfoot")
788
+ get_close('tfoot')
681
789
  end
682
790
 
683
791
  def get_table_body_open(args)
684
- get_open("tbody", nil, args, :no_id => true)
792
+ get_open('tbody', nil, args, :no_id => true)
685
793
  end
686
794
 
687
795
  def get_table_body_close(args)
688
- get_close("tbody")
796
+ get_close('tbody')
689
797
  end
690
798
 
691
799
  def get_table_head_cell(args, text, rown, coln, span_x=1, span_y=1)
692
800
  entry_args = {}
693
801
  if span_y > 1
694
- entry_args["morerows"] = span_y - 1
802
+ entry_args['morerows'] = span_y - 1
695
803
  end
696
- formatted_block("entry", formatted_inline("para", text), entry_args)
804
+ formatted_block('entry', formatted_inline('para', text), entry_args)
697
805
  end
698
806
 
699
807
  def get_table_cell(args, text, rown, coln, span_x=1, span_y=1)
700
808
  entry_args = {}
701
809
  if span_y > 1
702
- entry_args["morerows"] = span_y - 1
810
+ entry_args['morerows'] = span_y - 1
703
811
  end
704
812
  if span_x > 1
705
813
  start = args[:colnames][coln]
706
- entry_args["namest"] = start
707
- entry_args["nameend"] = args[:colnames][coln + span_x - 1]
814
+ entry_args['namest'] = start
815
+ entry_args['nameend'] = args[:colnames][coln + span_x - 1]
708
816
  end
709
- formatted_block("entry", formatted_inline("para", text), entry_args)
817
+ formatted_block('entry', formatted_inline('para', text), entry_args)
710
818
  end
711
819
 
712
820
  def get_table_note(args, note)
713
- formatted_inline("para", note)
821
+ formatted_inline('para', note)
714
822
  end
715
823
 
716
824
  def get_table_row_open(args)
717
- get_open("row", nil, args, :no_id => true)
825
+ get_open('row', nil, args, :no_id => true)
718
826
  end
719
827
 
720
828
  def get_table_row_close(args)
721
- get_close("row")
829
+ get_close('row')
722
830
  end
723
831
 
724
832
 
725
833
  # Title
726
- noop self, "format_title"
834
+ noop self, 'format_title'
727
835
  # get_title(args, data, pagebreak)
728
- noop self, "get_title"
836
+ noop self, 'get_title'
729
837
  # get_title_author(args, text)
730
- noop self, "get_title_author"
838
+ noop self, 'get_title_author'
731
839
  # get_title_authornote(args, text)
732
- noop self, "get_title_authornote"
840
+ noop self, 'get_title_authornote'
733
841
  # get_title_date(args, text)
734
- noop self, "get_title_date"
842
+ noop self, 'get_title_date'
735
843
  # get_title_title(args, text)
736
- noop self, "get_title_title"
844
+ noop self, 'get_title_title'
737
845
  end
738
846