deplate 0.8 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/AUTHORS.TXT +19 -16
  2. data/CHANGES.TXT +214 -248
  3. data/NEWS.TXT +47 -30
  4. data/README.TXT +0 -1
  5. data/TODO.TXT +93 -20
  6. data/VERSION.TXT +1 -1
  7. data/bin/deplate.exy +192 -0
  8. data/etc/deplate.ini +70 -9
  9. data/lib/action_view/helpers/deplate.rb +33 -33
  10. data/lib/deplate.rb +2 -2
  11. data/lib/deplate/bib.rb +72 -41
  12. data/lib/deplate/builtin.rb +1 -1
  13. data/lib/deplate/cache.rb +1 -1
  14. data/lib/deplate/commands.rb +161 -102
  15. data/lib/deplate/common.rb +93 -7
  16. data/lib/deplate/converter.rb +10 -4
  17. data/lib/deplate/core.rb +215 -108
  18. data/lib/deplate/counters.rb +23 -8
  19. data/lib/deplate/css/article.css +9 -5
  20. data/lib/deplate/css/deplate.css +37 -3
  21. data/lib/deplate/css/heading-navbar.css +1 -1
  22. data/lib/deplate/css/highstep.css +18 -0
  23. data/lib/deplate/css/htmldoc.css +43 -0
  24. data/lib/deplate/css/layout-deplate-print.css +1 -1
  25. data/lib/deplate/css/layout-deplate.css +1 -1
  26. data/lib/deplate/css/play.css +101 -0
  27. data/lib/deplate/css/sans-serif.css +1 -1
  28. data/lib/deplate/css/serif-e.css +1 -1
  29. data/lib/deplate/css/serif-rel.css +1 -1
  30. data/lib/deplate/css/serif.css +1 -1
  31. data/lib/deplate/css/slides.css +1 -1
  32. data/lib/deplate/css/styles.css +4 -0
  33. data/lib/deplate/css/tabbar-right.css +54 -8
  34. data/lib/deplate/css/tabbar-top.css +28 -9
  35. data/lib/deplate/css/text-sans-serif.css +1 -1
  36. data/lib/deplate/css/text-serif.css +1 -1
  37. data/lib/deplate/define.rb +71 -38
  38. data/lib/deplate/deplate-string.rb +3 -3
  39. data/lib/deplate/docbook.rb +9 -9
  40. data/lib/deplate/elements.rb +173 -84
  41. data/lib/deplate/etc.rb +6 -8
  42. data/lib/deplate/external.rb +9 -5
  43. data/lib/deplate/fmt/dbk-article-4.1.2.rb +4 -3
  44. data/lib/deplate/fmt/dbk-article.rb +9 -8
  45. data/lib/deplate/fmt/dbk-book.rb +4 -3
  46. data/lib/deplate/fmt/dbk-ref.rb +5 -4
  47. data/lib/deplate/fmt/dbk-slides.rb +4 -3
  48. data/lib/deplate/fmt/dbk-snippet.rb +4 -3
  49. data/lib/deplate/fmt/html-snippet.rb +1 -1
  50. data/lib/deplate/fmt/html.rb +186 -46
  51. data/lib/deplate/fmt/htmlsite.rb +19 -9
  52. data/lib/deplate/fmt/htmlslides.rb +1 -1
  53. data/lib/deplate/fmt/htmlwebsite.rb +1 -1
  54. data/lib/deplate/fmt/latex-dramatist.rb +175 -0
  55. data/lib/deplate/fmt/latex-snippet.rb +1 -1
  56. data/lib/deplate/fmt/latex.rb +132 -80
  57. data/lib/deplate/fmt/null.rb +1 -1
  58. data/lib/deplate/fmt/php.rb +1 -1
  59. data/lib/deplate/fmt/phpsite.rb +1 -1
  60. data/lib/deplate/fmt/plain.rb +16 -9
  61. data/lib/deplate/fmt/template.rb +1 -1
  62. data/lib/deplate/fmt/xhtml10t.rb +1 -1
  63. data/lib/deplate/formatter-snippet.rb +1 -1
  64. data/lib/deplate/formatter.rb +272 -81
  65. data/lib/deplate/guesslanguage.rb +57 -0
  66. data/lib/deplate/input.rb +205 -50
  67. data/lib/deplate/input/deplate-headings.rb +9 -11
  68. data/lib/deplate/input/deplate-restricted.rb +3 -23
  69. data/lib/deplate/input/deplate.rb +1 -1
  70. data/lib/deplate/input/play.rb +208 -0
  71. data/lib/deplate/input/rdoc.rb +37 -15
  72. data/lib/deplate/input/template.rb +6 -11
  73. data/lib/deplate/lib/Makefile.config +53 -4
  74. data/lib/deplate/lib/html/parbreak +3 -0
  75. data/lib/deplate/lib/javascript/StepwiseNextPage.js +8 -0
  76. data/lib/deplate/lib/javascript/StepwiseNextPage_confirm.js +8 -0
  77. data/lib/deplate/lib/latex/deplate.sty +36 -0
  78. data/lib/deplate/lib/latex/parbreak +6 -0
  79. data/lib/deplate/lib/php/page-comment.inc.php +5 -5
  80. data/lib/deplate/lib/plain/parbreak +6 -0
  81. data/lib/deplate/locale/de.latin1 +87 -15
  82. data/lib/deplate/locale/de.latin1_data +60 -0
  83. data/lib/deplate/locale/en.latin1_data +46 -0
  84. data/lib/deplate/locale/fr.latin1_data +74 -0
  85. data/lib/deplate/locale/ru.koi8-r_data +63 -0
  86. data/lib/deplate/locale/{zh_cn.gb2312 → zh_CN.GB2312} +0 -0
  87. data/lib/deplate/macros.rb +106 -32
  88. data/lib/deplate/messages.rb +22 -8
  89. data/lib/deplate/metadata.rb +1 -1
  90. data/lib/deplate/metadata/marshal.rb +1 -1
  91. data/lib/deplate/metadata/xml.rb +1 -1
  92. data/lib/deplate/metadata/yaml.rb +1 -1
  93. data/lib/deplate/mod/anyword.rb +4 -4
  94. data/lib/deplate/mod/babelfish.rb +1 -1
  95. data/lib/deplate/mod/code-gvim.rb +14 -8
  96. data/lib/deplate/mod/code-gvim71.rb +52 -0
  97. data/lib/deplate/mod/code-highlight.rb +35 -19
  98. data/lib/deplate/mod/colored-log.rb +1 -1
  99. data/lib/deplate/mod/endnotes.rb +1 -1
  100. data/lib/deplate/mod/guesslanguage.rb +75 -0
  101. data/lib/deplate/mod/html-asciimath.rb +1 -1
  102. data/lib/deplate/mod/html-deplate-button.rb +1 -1
  103. data/lib/deplate/mod/html-headings-navbar.rb +1 -1
  104. data/lib/deplate/mod/html-highstep.rb +43 -0
  105. data/lib/deplate/mod/html-jsmath.rb +1 -1
  106. data/lib/deplate/mod/html-obfuscate-email.rb +1 -1
  107. data/lib/deplate/mod/html-sidebar.rb +1 -1
  108. data/lib/deplate/mod/iconv.rb +1 -1
  109. data/lib/deplate/mod/imgurl.rb +1 -1
  110. data/lib/deplate/mod/inlatex-compound.rb +1 -1
  111. data/lib/deplate/mod/koma.rb +4 -4
  112. data/lib/deplate/mod/{de.rb → lang-de.rb} +1 -1
  113. data/lib/deplate/mod/{en.rb → lang-en.rb} +1 -1
  114. data/lib/deplate/mod/{ru_koi8-r.rb → lang-ru-koi8-r.rb} +1 -1
  115. data/lib/deplate/mod/lang-ru.rb +9 -0
  116. data/lib/deplate/mod/{zh-cn-autospace.rb → lang-zh_CN-autospace.rb} +3 -3
  117. data/lib/deplate/mod/{zh-cn.rb → lang-zh_CN.rb} +8 -8
  118. data/lib/deplate/mod/latex-emph-table-head.rb +1 -1
  119. data/lib/deplate/mod/latex-styles.rb +6 -6
  120. data/lib/deplate/mod/latex-verbatim-small.rb +1 -1
  121. data/lib/deplate/mod/linkmap.rb +128 -0
  122. data/lib/deplate/mod/makefile.rb +23 -22
  123. data/lib/deplate/mod/mark-external-urls.rb +13 -7
  124. data/lib/deplate/mod/markup-1-warn.rb +1 -1
  125. data/lib/deplate/mod/markup-1.rb +1 -1
  126. data/lib/deplate/mod/navbar-png.rb +5 -4
  127. data/lib/deplate/mod/noindent.rb +1 -1
  128. data/lib/deplate/mod/numpara.rb +1 -1
  129. data/lib/deplate/mod/particle-math.rb +1 -1
  130. data/lib/deplate/mod/php-extra.rb +1 -1
  131. data/lib/deplate/mod/pstoedit.rb +1 -1
  132. data/lib/deplate/mod/recode.rb +1 -1
  133. data/lib/deplate/mod/smart-dash.rb +1 -1
  134. data/lib/deplate/mod/smiley.rb +1 -1
  135. data/lib/deplate/mod/soffice.rb +1 -1
  136. data/lib/deplate/mod/symbols-latin1.rb +1 -1
  137. data/lib/deplate/mod/symbols-od-utf-8.rb +1 -1
  138. data/lib/deplate/mod/symbols-plain.rb +1 -1
  139. data/lib/deplate/mod/symbols-sgml.rb +1 -1
  140. data/lib/deplate/mod/symbols-utf-8.rb +1 -1
  141. data/lib/deplate/mod/symbols-xml.rb +1 -1
  142. data/lib/deplate/mod/syntax-region-alt.rb +1 -1
  143. data/lib/deplate/mod/utf8.rb +1 -1
  144. data/lib/deplate/mod/validate-html.rb +1 -1
  145. data/lib/deplate/mod/xmlrpc.rb +37 -36
  146. data/lib/deplate/nukumi2.rb +4 -4
  147. data/lib/deplate/once-method.rb +1 -1
  148. data/lib/deplate/output.rb +12 -4
  149. data/lib/deplate/particles.rb +52 -22
  150. data/lib/deplate/regions.rb +160 -90
  151. data/lib/deplate/skeletons.rb +4 -3
  152. data/lib/deplate/structured.rb +19 -13
  153. data/lib/deplate/template.rb +17 -9
  154. data/lib/deplate/templates/html-doc.html +8 -11
  155. data/lib/deplate/templates/html-tabbar-right.html +1 -1
  156. data/lib/deplate/templates/html-tabbar-top.html +3 -3
  157. data/lib/deplate/variables.rb +25 -9
  158. data/lib/deplate/wiki-markup.rb +14 -3
  159. data/lib/deplate/xml.rb +3 -4
  160. data/lib/deplate/{zh-cn.rb → zh_CN.rb} +16 -16
  161. data/man/man1/deplate.1 +80 -65
  162. metadata +72 -48
  163. data/lib/deplate/mod/fr.rb +0 -46
@@ -1,10 +1,10 @@
1
1
  # etc.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 16-Okt-2005.
6
- # @Last Change: 29-Apr-2006.
7
- # @Revision: 0.308
6
+ # @Last Change: 2007-09-29.
7
+ # @Revision: 0.312
8
8
 
9
9
  require 'deplate/common'
10
10
 
@@ -85,10 +85,10 @@ module Deplate::Footnote
85
85
  if text
86
86
  @fnId = @args['id']
87
87
  if @fnId and text and !text.empty?
88
- @regNote = @fnId
88
+ # @regNote = @fnId
89
89
  @accum = text
90
90
  # @level = @container.level
91
- fn = Deplate::Regions::Footnote.new(@deplate, @source, @regNote, {}, self)
91
+ fn = Deplate::Regions::Footnote.new(@deplate, @source, @fnId, {}, self)
92
92
  fn.finish
93
93
  else
94
94
  @fnId ||= text
@@ -122,9 +122,7 @@ class Deplate::IndexEntry
122
122
 
123
123
  def initialize(container)
124
124
  @container = container
125
- unless container
126
- # p "DBG IndexEntry: container = nil"
127
- end
125
+ # p "DBG IndexEntry: container = nil" unless container
128
126
  if block_given?
129
127
  yield(self)
130
128
  end
@@ -1,10 +1,10 @@
1
1
  # external.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 04-Sep-2004.
6
- # @Last Change: 08-Apr-2006.
7
- # @Revision: 0.206
6
+ # @Last Change: 2007-09-02.
7
+ # @Revision: 0.215
8
8
 
9
9
  require "ps2ppm"
10
10
 
@@ -39,7 +39,7 @@ module Deplate::External
39
39
  def log_popen(container, cmd)
40
40
  rv = []
41
41
  if container.deplate.allow_external
42
- container.log(["PWD", Dir.pwd])
42
+ container.log(["CWD", Dir.pwd])
43
43
  container.log(["Exec", cmd])
44
44
  begin
45
45
  IO.popen(cmd, "w+") do |io|
@@ -80,11 +80,15 @@ module Deplate::External
80
80
  bibfile = File.basename(bibfile)
81
81
  log_popen(instance, "#{get_app('kpsewhich')} #{bibfile}")
82
82
  end
83
-
83
+
84
84
  def dvi2ps(instance, dvifile, psfile, other_options=nil)
85
85
  log_popen(instance, "#{get_app('dvips')} -E -Z -D 300 #{other_options} -o #{psfile} #{dvifile}")
86
86
  end
87
87
 
88
+ def dvi2png(instance, dvifile, outfile, other_options=nil)
89
+ log_popen(instance, "#{get_app('dvipng')} -T tight -bg Transparent -D 120 #{other_options} -o #{outfile} #{dvifile}")
90
+ end
91
+
88
92
  def ps2img(instance, device, psfile, outfile, args)
89
93
  # r = args["rx"] || instance.deplate.variables["ps2imgRes"] || 96
90
94
  r = args["rx"] || instance.deplate.variables["ps2imgRes"] || 120
@@ -1,10 +1,10 @@
1
1
  # dbk-article.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
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: 23-Okt-2005.
7
- # @Revision: 0.2056
6
+ # @Last Change: 2007-02-17.
7
+ # @Revision: 0.2057
8
8
 
9
9
  require "deplate/docbook"
10
10
  require "deplate/fmt/dbk-article"
@@ -12,6 +12,7 @@ require "deplate/fmt/dbk-article"
12
12
  class Deplate::Formatter::DbkArticle412 < Deplate::Formatter::DbkArticle
13
13
  self.myname = "dbk-article-4.1.2"
14
14
  self.rx = /dbk|dbk-article|docbook/i
15
+ self.related = ['dbk']
15
16
 
16
17
  def setup
17
18
  @deplate.variables['dbkClass'] ||= 'article'
@@ -1,16 +1,17 @@
1
1
  # dbk-article.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
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: 23-Okt-2005.
7
- # @Revision: 0.2058
6
+ # @Last Change: 2007-02-24.
7
+ # @Revision: 0.2061
8
8
 
9
9
  require "deplate/docbook"
10
10
 
11
11
  class Deplate::Formatter::DbkArticle < Deplate::Formatter::Docbook
12
- self.myname = "dbk-article"
12
+ self.myname = 'dbk-article'
13
13
  self.rx = /dbk|dbk-article|docbook/i
14
+ self.related = ['dbk']
14
15
 
15
16
  def initialize(deplate, args)
16
17
  @headings = ['sect1', 'sect2', 'sect3', 'sect4', 'sect5', 'sect6']
@@ -28,19 +29,19 @@ class Deplate::Formatter::DbkArticle < Deplate::Formatter::Docbook
28
29
  if lang
29
30
  o << %{ lang="#{lang}"}
30
31
  end
31
- return "<article%s>" % o.join
32
+ return '<article%s>' % o.join
32
33
  end
33
34
 
34
35
  def get_doc_close(args)
35
- return "</article>"
36
+ return '</article>'
36
37
  end
37
38
 
38
39
  def get_doc_head_open(args)
39
- return "<articleinfo>"
40
+ return '<articleinfo>'
40
41
  end
41
42
 
42
43
  def get_doc_head_close(args)
43
- return "</articleinfo>"
44
+ return '</articleinfo>'
44
45
  end
45
46
  end
46
47
 
@@ -1,16 +1,17 @@
1
1
  # dbk-book.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
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: 23-Okt-2005.
7
- # @Revision: 0.2052
6
+ # @Last Change: 2007-02-17.
7
+ # @Revision: 0.2053
8
8
 
9
9
  require "deplate/docbook"
10
10
 
11
11
  class Deplate::Formatter::DbkBook < Deplate::Formatter::Docbook
12
12
  self.myname = "dbk-book"
13
13
  self.rx = /dbk|dbk-book|docbook/i
14
+ self.related = ['dbk']
14
15
 
15
16
  def initialize(deplate, args)
16
17
  @headings = ["chapter", "sect1", "sect2", "sect3", "sect4", "sect5", "sect6"]
@@ -1,16 +1,17 @@
1
1
  # dbk-ref.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
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: 02-Apr-2006.
7
- # @Revision: 0.2125
6
+ # @Last Change: 2007-06-30.
7
+ # @Revision: 0.2127
8
8
 
9
9
  require "deplate/docbook"
10
10
 
11
11
  class Deplate::Formatter::DbkRef < Deplate::Formatter::Docbook
12
12
  self.myname = "dbk-ref"
13
13
  self.rx = /dbk|dbk-ref|docbook/i
14
+ self.related = ['dbk']
14
15
 
15
16
  def initialize(deplate, args)
16
17
  @headings = ["refsect1", "refsect2", "refsect3"]
@@ -72,7 +73,7 @@ class Deplate::Formatter::DbkRef < Deplate::Formatter::Docbook
72
73
 
73
74
  yr = @deplate.variables["copyrightYear"] || dt
74
75
  if yr
75
- year = yr.split(/[\s,;]/).collect {|yr| formatted_inline("year", yr)}
76
+ year = Deplate::Core.split_list(yr, ',', '; ').collect {|yr| formatted_inline("year", yr)}
76
77
  holder = @deplate.get_clip("author")
77
78
  holder = formatted_inline("holder", holder.elt) if holder
78
79
  copyright = formatted_block("copyright", [year, holder].flatten.compact.join("\n"))
@@ -1,10 +1,10 @@
1
1
  # dbk-slides.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 29-Apr-2005.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.13
6
+ # @Last Change: 2007-02-17.
7
+ # @Revision: 0.14
8
8
 
9
9
  require 'deplate/docbook'
10
10
 
@@ -12,6 +12,7 @@ require 'deplate/docbook'
12
12
  class Deplate::Formatter::DbkSlides < Deplate::Formatter::Docbook
13
13
  self.myname = 'dbk-slides'
14
14
  self.rx = /dbk|dbk-slides|docbook/i
15
+ self.related = ['dbk']
15
16
 
16
17
  def initialize(deplate, args)
17
18
  @headings = ['foilgroup', 'foil']
@@ -1,16 +1,17 @@
1
1
  # docbook-snippet.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 11-Aug-2005.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.17
6
+ # @Last Change: 2007-02-17.
7
+ # @Revision: 0.18
8
8
 
9
9
  require 'deplate/fmt/dbk-article.rb'
10
10
  require 'deplate/formatter-snippet.rb'
11
11
 
12
12
  class Deplate::Formatter::DbkSnippet < Deplate::Formatter::DbkArticle
13
13
  self.myname = "dbk-snippet"
14
+ self.related = ['dbk']
14
15
 
15
16
  include Deplate::Snippet
16
17
 
@@ -1,5 +1,5 @@
1
1
  # html-snippet.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 11-Aug-2005.
@@ -1,10 +1,10 @@
1
1
  # fmt-html.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
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: 05-Jun-2006.
7
- # @Revision: 0.4111
6
+ # @Last Change: 2007-10-12.
7
+ # @Revision: 0.4287
8
8
 
9
9
  # require 'cgi'
10
10
  require 'uri'
@@ -41,7 +41,6 @@ class Deplate::Formatter::HTML < Deplate::Formatter
41
41
 
42
42
  attr_accessor :html_class
43
43
 
44
-
45
44
  ################################################ Setup {{{1
46
45
  def initialize(deplate, args)
47
46
  super
@@ -61,9 +60,11 @@ class Deplate::Formatter::HTML < Deplate::Formatter
61
60
  @encodings = {
62
61
  'latin1' => 'iso-8859-1',
63
62
  }
63
+ @deplate.output.attributes[:stepwiseIdx] ||= 0
64
64
  end
65
65
 
66
66
  def hook_post_write_file_html
67
+ return if @deplate.variables['cssInclude']
67
68
  @deplate.options.css.each do |name, anyway|
68
69
  begin
69
70
  src = @deplate.collected_css[name]
@@ -80,7 +81,7 @@ class Deplate::Formatter::HTML < Deplate::Formatter
80
81
  end
81
82
  end
82
83
  rescue
83
- log(["Can't copy css file", name], :error)
84
+ log(["Cannot copy css file", name], :error)
84
85
  end
85
86
  end
86
87
  end
@@ -163,7 +164,7 @@ class Deplate::Formatter::HTML < Deplate::Formatter
163
164
  date = ParseDate.parsedate(date, true)
164
165
  date = Time.local(*date)
165
166
  rescue
166
- log(["Can't parse date", @deplate.get_clip("date").elt], :error)
167
+ log(["Cannot parse date", @deplate.get_clip("date").elt], :error)
167
168
  date = nil
168
169
  end
169
170
  end
@@ -199,9 +200,34 @@ class Deplate::Formatter::HTML < Deplate::Formatter
199
200
  output_at(:pre, :head_meta, head_meta_tag(%{name="generator" content="deplate.rb #{Deplate::Core.version}"})) unless @variables['noGenerator']
200
201
  md = @variables['metaDataExtra']
201
202
  output_at(:pre, :head_meta, md) if md
202
-
203
+
203
204
  output_at(:pre, :head_title, %{<title>%s</title>} % title) if title
204
205
 
206
+ news = @variables['newsFeed']
207
+ if news
208
+ news = [news] if news.kind_of?(String)
209
+ for feed in news
210
+ opts, text = @deplate.input.parse_args(feed, nil, false)
211
+ if (href = opts['rss'])
212
+ opts['type'] = 'rss'
213
+ elsif (href = opts['atom'])
214
+ opts['type'] = 'atom'
215
+ else
216
+ href = opts['href'] || text
217
+ end
218
+ case opts['type']
219
+ when 'atom'
220
+ type = 'application/atom+xml'
221
+ else
222
+ type = 'application/rss+xml'
223
+ end
224
+ type = %{type="#{type}"}
225
+ href = %{href="#{href}"}
226
+ title = %{title="#{plain_text(opts['title'] || opts['type'])}"}
227
+ output_at(:pre, :head_meta, head_link_tag(['rel="alternate"', type, title, href].join(' ')))
228
+ end
229
+ end
230
+
205
231
  headExtra = @variables['headExtra']
206
232
  headExtra = headExtra.join("\n") if headExtra.kind_of?(Array)
207
233
  output_at(:pre, :head_extra, headExtra) if headExtra and !headExtra.empty?
@@ -337,8 +363,7 @@ EOT
337
363
 
338
364
  def wrap_formatted_element_zz_stepwise(invoker, value, args)
339
365
  if @variables['stepwiseDisplay']
340
- @deplate.output.attributes[:stepwiseIdx] ||= 0
341
- idx = @deplate.output.attributes[:stepwiseIdx] += 1
366
+ idx = stepwise_next
342
367
  beg = (@variables['stepwiseBegin'] || '1').to_i
343
368
  vis = idx > beg ? 'hidden' : 'visible'
344
369
  value.sub!(/\A(\s*)(.*?)(\s*)\Z/m) do |m|
@@ -363,7 +388,45 @@ EOT
363
388
  classes.flatten.compact.uniq.join(' ')
364
389
  end
365
390
 
366
-
391
+ unless defined?(KEYS)
392
+ KEYS = {
393
+ 'bs' => '8', 'backspace' => '8',
394
+ 'tab' => '9',
395
+ 'enter' => '13', 'cr' => '13', 'return' => '13',
396
+ 'shift' => '16',
397
+ 'ctrl' => '17',
398
+ 'alt' => '18', 'meta' => '18',
399
+ 'pause' => '19',
400
+ 'esc' => '27', 'escape' => '27',
401
+ 'space' => '32',
402
+ 'pageup' => '33',
403
+ 'pagedown' => '34',
404
+ 'left' => '37',
405
+ 'right' => '39',
406
+ 'n' => '78',
407
+ '-' => '109', 'dash' => '109',
408
+ 'f1' => '112',
409
+ 'f2' => '113',
410
+ 'f3' => '114',
411
+ 'f4' => '115',
412
+ 'f5' => '116',
413
+ 'f6' => '117',
414
+ 'f7' => '118',
415
+ 'f8' => '119',
416
+ 'f9' => '120',
417
+ 'f10' => '121',
418
+ 'f11' => '122',
419
+ 'f12' => '123',
420
+ ',' => '188', 'comma' => '188',
421
+ '.' => '190', 'period' => '190',
422
+ '#' => '191', 'sharp' => '191',
423
+ }
424
+ end
425
+
426
+ def keys_name_to_id(keys)
427
+ Deplate::Core.split_list(keys, ',', '; ').collect {|key| KEYS[key.downcase] || key}.join(',')
428
+ end
429
+
367
430
  ################################################ Lists {{{1
368
431
  def format_list_item(invoker, type, level, item, args={})
369
432
  indent = format_indent(level, true)
@@ -615,7 +678,7 @@ EOT
615
678
 
616
679
  style = args['style']
617
680
  if style
618
- style = style.split(/[ ,]/)
681
+ style = Deplate::Core.split_list(style, ',', '; ', invoker.source)
619
682
  else
620
683
  style = []
621
684
  end
@@ -624,7 +687,7 @@ EOT
624
687
 
625
688
  img_id = args['id']
626
689
  unless img_id
627
- fbase = Deplate::Core.clean_file_name(File.basename(fbase || 'imgid'))
690
+ fbase = Deplate::Core.clean_name(File.basename(fbase || 'imgid'))
628
691
  img_id = @deplate.auto_numbered(fbase, :inc => 1, :fmt => %{#{fbase}_%s})
629
692
  end
630
693
  acc << %{id="#{img_id}" name="#{img_id}"}
@@ -951,6 +1014,10 @@ EOJS
951
1014
  if target
952
1015
  args['target'] = target
953
1016
  end
1017
+ rel = invoker.args['rel']
1018
+ if rel
1019
+ args['rel'] = rel
1020
+ end
954
1021
  return args
955
1022
  end
956
1023
  private :href_args
@@ -1146,7 +1213,7 @@ EOJS
1146
1213
  def head_css
1147
1214
  csso = @variables['css']
1148
1215
  if csso
1149
- csss = csso.split(/\s+/)
1216
+ csss = Deplate::Core.split_list(csso, ',', ' ;', nil, nil)
1150
1217
  else
1151
1218
  csss = []
1152
1219
  end
@@ -1155,6 +1222,9 @@ EOJS
1155
1222
  csss << cls + '.css'
1156
1223
  end
1157
1224
  acc = []
1225
+ if @deplate.variables['cssInclude']
1226
+ acc << %{<style type="text/css">} << %{<!--}
1227
+ end
1158
1228
  csss.each_with_index do | f, i |
1159
1229
  css, media = f.split(/\|/)
1160
1230
  if css =~ /^\+/
@@ -1167,16 +1237,28 @@ EOJS
1167
1237
  unless @deplate.options.css.find {|c, anyway| cssName == c}
1168
1238
  @deplate.options.css << [cssName]
1169
1239
  end
1170
- cssFile = @deplate.auxiliary_filename(css)
1171
- cssFmt = @deplate.variables['htmlCssUrl'] || @deplate.variables['htmlAuxUrl']
1172
- cssFile = cssFmt % cssFile if cssFmt
1173
- opts = [%{rel="stylesheet" type="text/css" href="#{URI.escape(cssFile)}"}]
1174
- opts << %{title="#{cssName}"} if with_title
1175
- opts << %{media="#{media}"} if media
1176
- acc << head_link_tag(opts.join(' '))
1240
+ if @deplate.variables['cssInclude']
1241
+ cssFile = @deplate.collected_css[css]
1242
+ if cssFile and File.readable?(cssFile)
1243
+ acc << File.read(cssFile)
1244
+ else
1245
+ log(['File not found', 'Cannot include CSS', css], :error)
1246
+ end
1247
+ else
1248
+ cssFile = @deplate.auxiliary_filename(css)
1249
+ cssFmt = @deplate.variables['htmlCssUrl'] || @deplate.variables['htmlAuxUrl']
1250
+ cssFile = cssFmt % cssFile if cssFmt
1251
+ opts = [%{rel="stylesheet" type="text/css" href="#{URI.escape(cssFile)}"}]
1252
+ opts << %{title="#{cssName}"} if with_title
1253
+ opts << %{media="#{media}"} if media
1254
+ acc << head_link_tag(opts.join(' '))
1255
+ end
1177
1256
  end
1178
1257
  cssExtra = @variables['cssExtra']
1179
1258
  acc << cssExtra if cssExtra
1259
+ if @deplate.variables['cssInclude']
1260
+ acc << %{-->} << %{</style>}
1261
+ end
1180
1262
  return acc.join("\n")
1181
1263
  end
1182
1264
 
@@ -1307,24 +1389,29 @@ EOJS
1307
1389
  for i in arr
1308
1390
  ff = @deplate.dest
1309
1391
  xf = i.file(invoker)
1310
- xl = i.level_as_string
1392
+ xc = i.container
1393
+ xl = xc && xc.heading_level
1311
1394
  if xf or xl
1312
- f = xf || invoker.output_file_name(:level_as_string => xl,
1313
- :relative => invoker)
1314
- if f == ff
1315
- f = ''
1316
- l = xl
1317
- if l and !l.empty?
1318
- t = l
1319
- elsif @deplate.options.multi_file_output
1320
- t = @variables['refButton'] || '[&rArr;]'
1395
+ begin
1396
+ f = xf || invoker.output_file_name(:level_as_string => xl,
1397
+ :relative => invoker)
1398
+ if f == ff
1399
+ f = ''
1400
+ l = xl
1401
+ if l and !l.empty?
1402
+ t = l
1403
+ elsif @deplate.options.multi_file_output
1404
+ t = @variables['refButton'] || '[&rArr;]'
1405
+ else
1406
+ t = 'I'
1407
+ end
1321
1408
  else
1322
- t = 'I'
1409
+ t = @deplate.file_with_suffix(f, '', true)
1323
1410
  end
1324
- else
1325
- t = @deplate.file_with_suffix(f, '', true)
1411
+ acc << format_url(invoker, t, f, i.label, true)
1412
+ rescue Exception => e
1413
+ invoker.log(['Internal error: No output file', n, i.label, ff, xf, xl, invoker.class, e], :error)
1326
1414
  end
1327
- acc << format_url(invoker, t, f, i.label, true)
1328
1415
  else
1329
1416
  invoker.log(['Index: Neither file nor level defined: dropping', n, i.label], :error)
1330
1417
  end
@@ -1351,7 +1438,7 @@ EOJS
1351
1438
  end
1352
1439
 
1353
1440
  def format_index_hd_label(char)
1354
- return "hdIdx#{char}"
1441
+ return "hdIdx#{Deplate::Core.clean_name(char, :chars => '^a-zA-Z0-9')}"
1355
1442
  end
1356
1443
 
1357
1444
 
@@ -1400,7 +1487,13 @@ EOJS
1400
1487
  when :ruler, :noruler
1401
1488
  return nil
1402
1489
  else
1403
- c = cell.cell
1490
+ if cell.class == Array
1491
+ puts caller[0..10].join("\n")
1492
+ log(["We shouldn't be here. If you can track down when this happens, please send an example to the author.", cell[0].get_text], :error)
1493
+ return []
1494
+ else
1495
+ c = cell.cell
1496
+ end
1404
1497
  if thistag
1405
1498
  tag = thistag
1406
1499
  else
@@ -1650,10 +1743,10 @@ EOJS
1650
1743
  return f
1651
1744
  end
1652
1745
 
1653
- def handle_key(key, function)
1654
- key = ',%s,' % key.split(/\s*,\s*/).join(',')
1746
+ def handle_key(keys, function)
1747
+ keys = ',%s,' % keys_name_to_id(keys)
1655
1748
  @deplate.output.attributes[:handle_keys] ||= {}
1656
- @deplate.output.attributes[:handle_keys][key] = function
1749
+ @deplate.output.attributes[:handle_keys][keys] = function
1657
1750
  end
1658
1751
 
1659
1752
  def_service('navigation_links') do |args, text|
@@ -1768,30 +1861,64 @@ EOJS
1768
1861
 
1769
1862
  def_service('stepwise_display') do |args, text|
1770
1863
  stepKey = @variables['stepwiseKey'] || '34'
1771
- if @variables['stepwiseDisplay'] and stepKey
1864
+ # if @variables['stepwiseDisplay'] and stepKey
1865
+ if stepKey
1772
1866
  handle_key(stepKey, 'StepwiseDisplayNext();')
1773
- stepInit = @variables['stepwiseBegin'] || '1'
1867
+ stepInit = @variables['stepwiseBegin'] || '0'
1868
+ unless defined?(@nextPage)
1869
+ catch(:exit) do
1870
+ # files = ['StepWiseNextPage.js']
1871
+ style = args['style'] || @variables['stepwiseStyle']
1872
+ files = [style ? "StepWiseNextPage_#{style}.js" : 'StepWiseNextPage.js']
1873
+ for file in files
1874
+ @nextPage = get_javascript(file, args)
1875
+ throw :exit if @nextPage
1876
+ end
1877
+ @nextPage = ''
1878
+ # <<EOJS
1879
+ # function StepwiseNextPage(Msg) {
1880
+ # return confirm(Msg);
1881
+ # }
1882
+ # EOJS
1883
+ end
1884
+ end
1774
1885
  acc = []
1775
1886
  acc << <<EOJS
1887
+ #{@nextPage}
1776
1888
  <script type="text/javascript">
1777
1889
  <!--
1778
1890
  var StepwiseCounter = #{stepInit};
1891
+
1779
1892
  function StepwiseDisplayNext() {
1780
1893
  StepwiseCounter = StepwiseCounter + 1;
1781
1894
  var Elt = document.getElementById('Step' + StepwiseCounter);
1895
+ var HighStep = document.getElementById('HighStep' + StepwiseCounter);
1896
+ var NextHighStep = document.getElementById('HighStep' + (StepwiseCounter + 1));
1782
1897
  if (Elt)
1783
1898
  Elt.style.visibility = 'visible';
1899
+ else if (HighStep)
1900
+ if (NextHighStep)
1901
+ HighStep.className = 'stephighlight';
1902
+ else
1903
+ HighStep.className = 'steplast';
1784
1904
  EOJS
1785
- if @variables['stepwiseContinous']
1786
- acc << <<EOJS
1905
+ case @variables['stepwiseContinous']
1906
+ when 'confirm', 'query', 'ask', 'yn'
1907
+ acc << <<EOJS
1908
+ else
1909
+ if (StepwiseNextPage("#{@deplate.msg('Next page?')}"))
1910
+ NavigationNextPage();
1911
+ EOJS
1912
+ when true, 1, '1'
1913
+ acc << <<EOJS
1787
1914
  else
1788
1915
  NavigationNextPage();
1789
1916
  EOJS
1790
1917
  end
1791
1918
  acc << <<EOJS
1792
1919
  }
1793
- //-->
1794
- </script>
1920
+ //-->
1921
+ </script>
1795
1922
  EOJS
1796
1923
  acc.join
1797
1924
  else
@@ -1836,7 +1963,20 @@ EOJS
1836
1963
  end
1837
1964
  @html_navigation_note
1838
1965
  end
1839
-
1966
+
1967
+ def get_javascript(file, args)
1968
+ file = @deplate.find_in_lib(file, :formatters => ['javascript'])
1969
+ if file
1970
+ tmpl = Deplate::Template.new(:template => File.read(file))
1971
+ Deplate::Define.let_variables(@deplate, args) do
1972
+ return tmpl.fill_in(@deplate).join("\n")
1973
+ end
1974
+ else
1975
+ log(['File not found', file])
1976
+ end
1977
+ return nil
1978
+ end
1979
+
1840
1980
 
1841
1981
  private
1842
1982
  def navbar_begin(type, slot, idx)