deplate 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/CHANGES.TXT +118 -0
  2. data/NEWS.TXT +6 -21
  3. data/VERSION.TXT +1 -1
  4. data/etc/deplate.ini +15 -2
  5. data/lib/action_view/helpers/deplate.rb +0 -0
  6. data/lib/deplate/abstract-class.rb +3 -2
  7. data/lib/deplate/bib.rb +3 -2
  8. data/lib/deplate/builtin.rb +3 -2
  9. data/lib/deplate/cache.rb +3 -2
  10. data/lib/deplate/commands.rb +3 -11
  11. data/lib/deplate/common.rb +7 -2
  12. data/lib/deplate/compat.rb +21 -0
  13. data/lib/deplate/compat/parsedate.rb +24 -0
  14. data/lib/deplate/converter.rb +3 -2
  15. data/lib/deplate/core.rb +135 -103
  16. data/lib/deplate/counters.rb +3 -2
  17. data/lib/deplate/css/article.css +2 -2
  18. data/lib/deplate/css/doc.css +3 -2
  19. data/lib/deplate/css/heading-navbar.css +2 -2
  20. data/lib/deplate/css/highlight.css +0 -0
  21. data/lib/deplate/css/layout-deplate-print.css +2 -2
  22. data/lib/deplate/css/layout-deplate.css +2 -2
  23. data/lib/deplate/css/presentation.css +2 -2
  24. data/lib/deplate/css/sans-serif.css +2 -2
  25. data/lib/deplate/css/screenplay.css +0 -0
  26. data/lib/deplate/css/serif-e.css +2 -2
  27. data/lib/deplate/css/serif-rel.css +3 -2
  28. data/lib/deplate/css/serif.css +2 -2
  29. data/lib/deplate/css/slides.css +3 -2
  30. data/lib/deplate/css/tabbar-top.css +2 -2
  31. data/lib/deplate/css/text-sans-serif.css +3 -2
  32. data/lib/deplate/css/text-serif.css +2 -2
  33. data/lib/deplate/css/website.css +0 -0
  34. data/lib/deplate/define.rb +3 -2
  35. data/lib/deplate/deplate-string.rb +3 -2
  36. data/lib/deplate/docbook.rb +4 -14
  37. data/lib/deplate/elements.rb +37 -4
  38. data/lib/deplate/encoding.rb +57 -0
  39. data/lib/deplate/etc.rb +7 -5
  40. data/lib/deplate/external.rb +5 -13
  41. data/lib/deplate/fmt/dbk-article-4.1.2.rb +3 -2
  42. data/lib/deplate/fmt/dbk-article.rb +3 -2
  43. data/lib/deplate/fmt/dbk-book.rb +3 -2
  44. data/lib/deplate/fmt/dbk-ref.rb +3 -2
  45. data/lib/deplate/fmt/dbk-slides.rb +3 -2
  46. data/lib/deplate/fmt/dbk-snippet.rb +3 -2
  47. data/lib/deplate/fmt/html-snippet.rb +3 -2
  48. data/lib/deplate/fmt/html.rb +40 -27
  49. data/lib/deplate/fmt/htmlsite.rb +3 -2
  50. data/lib/deplate/fmt/htmlslides.rb +3 -2
  51. data/lib/deplate/fmt/htmlwebsite.rb +3 -2
  52. data/lib/deplate/fmt/latex-dramatist.rb +2 -1
  53. data/lib/deplate/fmt/latex-snippet.rb +3 -2
  54. data/lib/deplate/fmt/latex.rb +88 -67
  55. data/lib/deplate/fmt/null.rb +3 -2
  56. data/lib/deplate/fmt/php.rb +3 -2
  57. data/lib/deplate/fmt/phpsite.rb +3 -2
  58. data/lib/deplate/fmt/plain.rb +4 -3
  59. data/lib/deplate/fmt/sweave.rb +104 -0
  60. data/lib/deplate/fmt/template.rb +3 -2
  61. data/lib/deplate/fmt/xhtml10t.rb +82 -2
  62. data/lib/deplate/fmt/xhtml11m.rb +3 -2
  63. data/lib/deplate/formatter-snippet.rb +3 -2
  64. data/lib/deplate/formatter.rb +203 -29
  65. data/lib/deplate/guesslanguage.rb +3 -2
  66. data/lib/deplate/input.rb +9 -8
  67. data/lib/deplate/input/deplate-headings.rb +3 -2
  68. data/lib/deplate/input/deplate-restricted.rb +3 -2
  69. data/lib/deplate/input/deplate.rb +3 -2
  70. data/lib/deplate/input/play.rb +3 -2
  71. data/lib/deplate/input/rdoc.rb +3 -2
  72. data/lib/deplate/input/template.rb +3 -2
  73. data/lib/deplate/lib/Makefile.config +8 -0
  74. data/lib/deplate/locale/de.latin1 +6 -0
  75. data/lib/deplate/macros.rb +4 -2
  76. data/lib/deplate/messages.rb +9 -5
  77. data/lib/deplate/metadata.rb +3 -2
  78. data/lib/deplate/metadata/marshal.rb +3 -2
  79. data/lib/deplate/metadata/xml.rb +3 -2
  80. data/lib/deplate/metadata/yaml.rb +3 -2
  81. data/lib/deplate/mod/anyword.rb +3 -2
  82. data/lib/deplate/mod/babelfish.rb +3 -2
  83. data/lib/deplate/mod/code-coderay.rb +3 -2
  84. data/lib/deplate/mod/code-gvim.rb +3 -2
  85. data/lib/deplate/mod/code-gvim71.rb +3 -2
  86. data/lib/deplate/mod/code-highlight.rb +3 -2
  87. data/lib/deplate/mod/colored-log.rb +3 -2
  88. data/lib/deplate/mod/encode.rb +33 -0
  89. data/lib/deplate/mod/endnotes.rb +3 -2
  90. data/lib/deplate/mod/entities-decode.rb +2 -1
  91. data/lib/deplate/mod/entities-encode.rb +2 -1
  92. data/lib/deplate/mod/guesslanguage.rb +3 -2
  93. data/lib/deplate/mod/html-asciimath.rb +3 -2
  94. data/lib/deplate/mod/html-deplate-button.rb +3 -2
  95. data/lib/deplate/mod/html-headings-navbar.rb +3 -2
  96. data/lib/deplate/mod/html-highstep.rb +3 -2
  97. data/lib/deplate/mod/html-jsmath.rb +3 -2
  98. data/lib/deplate/mod/html-mathml.rb +2 -1
  99. data/lib/deplate/mod/html-obfuscate-email.rb +3 -2
  100. data/lib/deplate/mod/html-sidebar.rb +3 -2
  101. data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -2
  102. data/lib/deplate/mod/iconv.rb +3 -2
  103. data/lib/deplate/mod/imgurl.rb +4 -3
  104. data/lib/deplate/mod/inlatex-compound.rb +3 -2
  105. data/lib/deplate/mod/koma.rb +3 -2
  106. data/lib/deplate/mod/lang-de.rb +3 -2
  107. data/lib/deplate/mod/lang-en.rb +3 -2
  108. data/lib/deplate/mod/lang-ru-koi8-r.rb +3 -2
  109. data/lib/deplate/mod/lang-ru.rb +3 -2
  110. data/lib/deplate/mod/lang-zh_CN-autospace.rb +3 -2
  111. data/lib/deplate/mod/lang-zh_CN.rb +3 -2
  112. data/lib/deplate/mod/latex-emph-table-head.rb +3 -2
  113. data/lib/deplate/mod/latex-styles.rb +3 -2
  114. data/lib/deplate/mod/latex-verbatim-small.rb +3 -2
  115. data/lib/deplate/mod/linkmap.rb +2 -1
  116. data/lib/deplate/mod/makefile.rb +39 -46
  117. data/lib/deplate/mod/mark-external-urls.rb +3 -2
  118. data/lib/deplate/mod/markup-1-warn.rb +3 -2
  119. data/lib/deplate/mod/markup-1.rb +3 -2
  120. data/lib/deplate/mod/navbar-png.rb +3 -2
  121. data/lib/deplate/mod/noindent.rb +3 -2
  122. data/lib/deplate/mod/numpara.rb +3 -2
  123. data/lib/deplate/mod/particle-math.rb +3 -2
  124. data/lib/deplate/mod/php-extra.rb +3 -2
  125. data/lib/deplate/mod/pstoedit.rb +3 -2
  126. data/lib/deplate/mod/recode.rb +3 -2
  127. data/lib/deplate/mod/smart-dash.rb +3 -2
  128. data/lib/deplate/mod/smiley.rb +3 -2
  129. data/lib/deplate/mod/soffice.rb +3 -2
  130. data/lib/deplate/mod/symbols-latin1.rb +8 -2
  131. data/lib/deplate/mod/symbols-od-utf-8.rb +3 -2
  132. data/lib/deplate/mod/symbols-plain.rb +3 -2
  133. data/lib/deplate/mod/symbols-sgml.rb +6 -5
  134. data/lib/deplate/mod/symbols-utf-8.rb +6 -5
  135. data/lib/deplate/mod/symbols-xml.rb +3 -2
  136. data/lib/deplate/mod/syntax-region-alt.rb +3 -2
  137. data/lib/deplate/mod/utf8.rb +3 -2
  138. data/lib/deplate/mod/validate-html.rb +3 -2
  139. data/lib/deplate/mod/xmlrpc.rb +3 -2
  140. data/lib/deplate/nukumi2.rb +3 -2
  141. data/lib/deplate/once-method.rb +3 -2
  142. data/lib/deplate/output.rb +3 -2
  143. data/lib/deplate/particles.rb +12 -6
  144. data/lib/{ps2ppm.rb → deplate/ps2ppm.rb} +11 -11
  145. data/lib/deplate/regions.rb +75 -52
  146. data/lib/deplate/skeletons.rb +3 -2
  147. data/lib/deplate/structured.rb +8 -24
  148. data/lib/deplate/template.rb +3 -2
  149. data/lib/deplate/themes/presentation.html/css/presentation.css +2 -2
  150. data/lib/deplate/themes/presentation.html/prelude.txt +1 -1
  151. data/lib/deplate/themes/presentation.html/resources/spacer.png +0 -0
  152. data/lib/deplate/themes/s5.xhtml/README.TXT +2 -0
  153. data/lib/deplate/themes/s5.xhtml/templates/s5.xhtml +42 -0
  154. data/lib/deplate/themes/s5.xhtml/theme.ini +11 -0
  155. data/lib/deplate/variables.rb +12 -2
  156. data/lib/deplate/wiki-markup.rb +3 -2
  157. data/lib/deplate/xml.rb +19 -21
  158. data/lib/deplate/zh_CN.rb +3 -2
  159. data/man/man1/deplate.1 +83 -128
  160. metadata +16 -4
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # dbk-article.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2007-02-17.
7
- # @Revision: 0.2057
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.2059
8
9
 
9
10
  require "deplate/docbook"
10
11
  require "deplate/fmt/dbk-article"
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # dbk-article.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2007-02-24.
7
- # @Revision: 0.2061
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.2063
8
9
 
9
10
  require "deplate/docbook"
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # dbk-book.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2007-02-17.
7
- # @Revision: 0.2053
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.2055
8
9
 
9
10
  require "deplate/docbook"
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # dbk-ref.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2007-06-30.
7
- # @Revision: 0.2127
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.2129
8
9
 
9
10
  require "deplate/docbook"
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # dbk-slides.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 29-Apr-2005.
6
- # @Last Change: 2007-02-17.
7
- # @Revision: 0.14
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.16
8
9
 
9
10
  require 'deplate/docbook'
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # docbook-snippet.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 11-Aug-2005.
6
- # @Last Change: 2007-02-17.
7
- # @Revision: 0.18
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.20
8
9
 
9
10
  require 'deplate/fmt/dbk-article.rb'
10
11
  require 'deplate/formatter-snippet.rb'
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # html-snippet.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 11-Aug-2005.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.12
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.14
8
9
 
9
10
  require 'deplate/fmt/html.rb'
10
11
  require 'deplate/formatter-snippet.rb'
@@ -1,14 +1,15 @@
1
+ # encoding: ASCII
1
2
  # fmt-html.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2008-07-18.
7
- # @Revision: 0.4333
7
+ # @Last Change: 2009-02-05.
8
+ # @Revision: 0.4381
8
9
 
9
10
  # require 'cgi'
10
11
  require 'uri'
11
- require 'parsedate'
12
+ require 'deplate/compat/parsedate'
12
13
  require 'time'
13
14
  require 'pathname'
14
15
 
@@ -133,6 +134,11 @@ class Deplate::Formatter::HTML < Deplate::Formatter
133
134
 
134
135
  output_at(:post, :body_end, '</body>')
135
136
  output_at(:post, :doc_end, '</html>')
137
+
138
+ @deplate.postponed_print << Proc.new do
139
+ ch = close_headings(0)
140
+ output_at(:body, :inner_body_end, ch)
141
+ end
136
142
  end
137
143
 
138
144
  def html_head
@@ -457,8 +463,6 @@ EOT
457
463
  opts['class'] << 'plus'
458
464
  when '*'
459
465
  opts['class'] << 'asterisk'
460
- when '�'
461
- opts['class'] << 'bullet'
462
466
  end
463
467
  end
464
468
  li = open_tag(invoker, 'li', opts)
@@ -646,7 +650,7 @@ EOT
646
650
  end
647
651
  end
648
652
 
649
- def include_image(invoker, file, args, inline=false)
653
+ def include_image_general(invoker, file, args, inline=false)
650
654
  acc = []
651
655
 
652
656
  file = args['file'] if args['file']
@@ -871,6 +875,9 @@ EOJS
871
875
  if consume_label(id)
872
876
  html_args += %{ id="#{id}"}
873
877
  end
878
+ acc = [close_headings(level), '']
879
+ acc << @variables['htmlHeadingPre']
880
+ acc << @variables["htmlHeadingPre#{level}"]
874
881
  if level > 0 and level <= 6
875
882
  hd = "h#{level}"
876
883
  if invoker.plain_caption?
@@ -879,10 +886,24 @@ EOJS
879
886
  ls = invoker.level_as_string
880
887
  ls += '&nbsp;' if ls
881
888
  end
882
- %{\n<#{hd}#{html_args}>#{l}#{ls}#{elt}</#{hd}>\n}
889
+ acc << %{<#{hd}#{html_args}>#{l}#{ls}#{elt}</#{hd}>\n}
883
890
  else
884
891
  l += format_label(invoker, :string, [id]) if id
885
- "\n#{l}#{elt}"
892
+ acc << "#{l}#{elt}"
893
+ end
894
+ acc.compact!
895
+ @deplate.options.headings << invoker
896
+ return join_blocks(acc)
897
+ end
898
+
899
+ def close_headings(level)
900
+ super(level) do |hlevel|
901
+ post = [@variables["htmlHeadingPost#{hlevel}"], @variables['htmlHeadingPost']].compact
902
+ if post.empty?
903
+ nil
904
+ else
905
+ join_blocks(post)
906
+ end
886
907
  end
887
908
  end
888
909
 
@@ -945,17 +966,19 @@ EOJS
945
966
  ################################################ Commands {{{1
946
967
  def format_title(invoker)
947
968
  acc = []
969
+ acc << @variables['htmlTitlePre']
948
970
  acc << %{<div class="title">}
949
- for i, c in [["title", %{<p class="title">%s</p>}],
950
- ["author", %{<p class="author">%s</p>}],
951
- ["authornote", %{<p class="authornote">%s</p>}],
952
- ["date", %{<p class="date">%s</p>}]]
971
+ for i, c in [["title", %{<#{@variables['htmlTagTitle'] || 'p class="title"'}>%s</p>}],
972
+ ["author", %{<#{@variables['htmlTagAuthor'] || 'p class="author"'}>%s</p>}],
973
+ ["authornote", %{<#{@variables['htmlTagAuthorNote'] || 'p class="authornote"'}>%s</p>}],
974
+ ["date", %{<#{@variables['htmlTagDate'] || 'p class="date"'}>%s</p>}]]
953
975
  ii = @deplate.get_clip(i)
954
976
  acc << c % ii.elt if ii
955
977
  end
956
978
  acc << %{</div>}
979
+ acc << @variables['htmlTitlePost']
957
980
  acc << format_pagebreak(invoker, 'title') if invoker.args['page']
958
- join_blocks(acc)
981
+ join_blocks(acc.compact)
959
982
  end
960
983
 
961
984
  alias :format_IMG :format_figure
@@ -1186,16 +1209,6 @@ EOJS
1186
1209
 
1187
1210
  protected ######################################## private methods {{{1
1188
1211
  ################################################ General {{{1
1189
- def clean_tags(text)
1190
- if text
1191
- t = text.gsub(/\<[^>]*?\>/, '')
1192
- t.gsub!(/^\s*$/, '')
1193
- t.gsub!(/^\n\s*/, '')
1194
- t.gsub!(/\n\s*$/, '')
1195
- t
1196
- end
1197
- end
1198
-
1199
1212
  def format_header_or_footer(invoker, type, slot, html_type, html_class)
1200
1213
  args = invoker.args
1201
1214
  acc = []
@@ -1708,17 +1721,17 @@ EOJS
1708
1721
  acc = []
1709
1722
  start = navbar_guess_file_name(0, nil, :inline)
1710
1723
  if start and start != ''
1711
- title = @deplate.msg('Frontpage')
1712
- acc << head_link_tag(%{rel="start" href="#{start}" title="#{clean_tags(title)}"})
1724
+ fp_title = @deplate.msg('Frontpage')
1725
+ acc << head_link_tag(%{rel="start" href="#{start}" title="#{clean_tags(fp_title)}"})
1713
1726
  end
1714
1727
  tags = ['', 'chapter', 'section', 'subsection']
1715
- @deplate.each_heading(depth || @deplate.options.split_level) do |hd, title|
1728
+ @deplate.each_heading(depth || @deplate.options.split_level) do |hd, hd_title|
1716
1729
  ref = tags[hd.level]
1717
1730
  anchor = hd.args[:id] || hd.label.first
1718
1731
  file = hd.output_file_name(:basename => true)
1719
1732
  file = escape_filename(file)
1720
1733
  file = [file, '#', anchor].join if anchor
1721
- acc << head_link_tag(%{rel="#{ref}" href="#{file}" title="#{clean_tags(title)}"})
1734
+ acc << head_link_tag(%{rel="#{ref}" href="#{file}" title="#{clean_tags(hd_title)}"})
1722
1735
  end
1723
1736
  acc.join("\n")
1724
1737
  end
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # htmlsite.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2007-09-28.
7
- # @Revision: 0.1026
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.1028
8
9
 
9
10
  require "deplate/fmt/html"
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # fmt-html.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.809
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.811
8
9
 
9
10
  require "deplate/fmt/htmlsite"
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # fmt-html.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 02-Apr-2006.
7
- # @Revision: 0.442
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.444
8
9
 
9
10
  require "deplate/fmt/htmlslides"
10
11
 
@@ -1,5 +1,6 @@
1
+ # encoding: ASCII
1
2
  # latex-dramatist.rb
2
- # @Last Change: 2007-09-30.
3
+ # @Last Change: 2009-02-02.
3
4
  # Author:: Thomas Link (micathom AT gmail com)
4
5
  # License:: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # Created:: 2007-08-09.
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # latex-snippet.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 11-Aug-2005.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.14
7
+ # @Last Change: 2009-02-02.
8
+ # @Revision: 0.16
8
9
 
9
10
  require 'deplate/fmt/latex.rb'
10
11
  require 'deplate/formatter-snippet.rb'
@@ -1,10 +1,11 @@
1
+ # encoding: ASCII
1
2
  # latex.rb
2
3
  # @Author: Thomas Link (micathom AT gmail com)
3
4
  # @Website: http://deplate.sf.net/
4
5
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
6
  # @Created: 17-M�r-2004.
6
- # @Last Change: 2008-07-10.
7
- # @Revision: 0.2164
7
+ # @Last Change: 2009-02-05.
8
+ # @Revision: 0.2190
8
9
 
9
10
  require "deplate/formatter"
10
11
 
@@ -93,6 +94,10 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
93
94
 
94
95
  lco = lco.uniq.join(',')
95
96
  output_at(:pre, :doc_def, "\\documentclass[#{lco}]{#{@document_class}}")
97
+ if @deplate.options.pdftex
98
+ pdfcompresslevel = (@deplate.variables['pdfCompressLevel'] || 9).to_i
99
+ output_at(:pre, :doc_def, "\\pdfcompresslevel#{pdfcompresslevel}")
100
+ end
96
101
 
97
102
  set_document_encoding
98
103
 
@@ -378,7 +383,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
378
383
 
379
384
  ################################################ General {{{1
380
385
  def format_environment(invoker, env, text, opts=nil)
381
- join_blocks(["\\begin{#{env}}", text.rstrip, "\\end{#{env}}\n"])
386
+ join_blocks(["\\begin{#{env}}", text.rstrip, "\\end{#{env}}#{block_postfix(invoker)}"])
382
387
  end
383
388
 
384
389
  def format_label(invoker, mode=nil, label=nil)
@@ -444,71 +449,75 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
444
449
  acc << "\\caption{#{caption.elt}}"
445
450
  end
446
451
  acc << format_label(invoker, :once)
447
- acc << "\\end{figure}\n"
452
+ acc << "\\end{figure}#{block_postfix(invoker)}"
448
453
  join_blocks(acc)
449
454
  end
450
455
 
451
- def include_image(invoker, file, args, inline=false)
452
- file = args['file'] if args['file']
453
- if file =~ Deplate::HyperLink::Url.rx
454
- Deplate::Core.log([%{Cannot include remote images in current document}, file], :error)
455
- file = File.basename(file)
456
- end
457
- ff = use_image_filename(file, args)
458
- o = []
459
- bw, bh, bx, by, desc = nil
460
- @deplate.in_working_dir do
461
- bw = args['bw']
462
- bh = args['bh']
463
- desc = Deplate::External.image_dimension(ff)
464
- unless (bw and bh) or @deplate.options.pdftex
465
- bw, bh, bx, by = desc[:bw]
456
+ def include_image_general(invoker, file, args, inline=false)
457
+ if args[:verbatim]
458
+ rv = args[:verbatim]
459
+ else
460
+ file = args['file'] if args['file']
461
+ if file =~ Deplate::HyperLink::Url.rx
462
+ Deplate::Core.log([%{Cannot include remote images in current document}, file], :error)
463
+ file = File.basename(file)
466
464
  end
467
- end
468
- unless @deplate.options.pdftex
469
- o << "bb=0 0 #{bw || "100"} #{bh || "100"}"
470
- end
471
- width = args['w'] || args['width']
472
- if width
473
- if width =~ /^\d+%$/
474
- width = width.to_f / 100
475
- o << "width=#{width}\\textwidth{}"
476
- elsif width =~ /^[.\d]+(cm|mm|in|em|pt)$/
477
- o << "width=#{width}"
478
- else
479
- o << "width=#{width}pt"
465
+ ff = use_image_filename(file, args)
466
+ o = []
467
+ bw, bh, bx, by, desc = nil
468
+ @deplate.in_working_dir do
469
+ bw = args['bw']
470
+ bh = args['bh']
471
+ desc = Deplate::External.image_dimension(ff)
472
+ unless (bw and bh) or @deplate.options.pdftex
473
+ bw, bh, bx, by = desc[:bw]
474
+ end
475
+ end
476
+ unless @deplate.options.pdftex
477
+ o << "bb=0 0 #{bw || "100"} #{bh || "100"}"
480
478
  end
481
- elsif !inline
482
- bb = desc[:bw]
483
- bw = bb ? bb[0] : nil
484
- res = desc[:res]
485
- if desc and bb and res
486
- estimated_width = bw.to_f / res
487
- if estimated_width > 6
488
- o << "width=\\textwidth{}"
479
+ width = args['w'] || args['width']
480
+ if width
481
+ if width =~ /^\d+%$/
482
+ width = width.to_f / 100
483
+ o << "width=#{width}\\textwidth{}"
484
+ elsif width =~ /^[.\d]+(cm|mm|in|em|pt)$/
485
+ o << "width=#{width}"
486
+ else
487
+ o << "width=#{width}pt"
488
+ end
489
+ elsif !inline
490
+ bb = desc[:bw]
491
+ bw = bb ? bb[0] : nil
492
+ res = desc[:res]
493
+ if desc and bb and res
494
+ estimated_width = bw.to_f / res
495
+ if estimated_width > 6
496
+ o << "width=\\textwidth{}"
497
+ end
489
498
  end
490
499
  end
491
- end
492
- height = args['h']
493
- if height
494
- if height =~ /^\d+%$/
495
- height = height.to_f / 100
496
- o << "height=#{height}\\textheight{}"
497
- elsif height =~ /^\d+(cm|mm|in|em|pt)$/
498
- o << "height=#{height}"
499
- else
500
- o << "height=#{height}pt"
500
+ height = args['h']
501
+ if height
502
+ if height =~ /^\d+%$/
503
+ height = height.to_f / 100
504
+ o << "height=#{height}\\textheight{}"
505
+ elsif height =~ /^\d+(cm|mm|in|em|pt)$/
506
+ o << "height=#{height}"
507
+ else
508
+ o << "height=#{height}pt"
509
+ end
510
+ end
511
+ o = o.join(',')
512
+ if !o.empty?
513
+ o = "[#{o}]"
514
+ end
515
+ add_package('graphicx')
516
+ rv = "\\includegraphics#{o}{#{ff}}"
517
+ rot = args['rotate'] || @deplate.variables['imgRotate']
518
+ if rot
519
+ rv = %{\\rotatebox{#{rot}}{#{rv}}}
501
520
  end
502
- end
503
- o = o.join(',')
504
- if !o.empty?
505
- o = "[#{o}]"
506
- end
507
- add_package('graphicx')
508
- rv = "\\includegraphics#{o}{#{ff}}"
509
- rot = args['rotate'] || @deplate.variables['imgRotate']
510
- if rot
511
- rv = %{\\rotatebox{#{rot}}{#{rv}}}
512
521
  end
513
522
  return rv
514
523
  end
@@ -670,7 +679,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
670
679
  acc << lab
671
680
  end
672
681
  acc << printable_list(invoker)
673
- acc << ""
682
+ acc << "" unless invoker.inlay?
674
683
  join_blocks(acc)
675
684
  end
676
685
 
@@ -683,7 +692,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
683
692
 
684
693
  def format_paragraph(invoker)
685
694
  rv = wrap_text(invoker.elt)
686
- if invoker.args[:minor]
695
+ if invoker.args[:minor] or invoker.inlay?
687
696
  return rv
688
697
  else
689
698
  return join_blocks([rv, ""])
@@ -756,10 +765,12 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
756
765
  acc << with_agent(:table_top, String, invoker, capAbove, nil)
757
766
  acc << elt
758
767
  acc << with_agent(:table_bottom, String, invoker, capAbove, nil)
759
- else
768
+ elsif args["type"] == "fig"
760
769
  acc << with_agent(:figure_top, String, invoker)
761
770
  acc << elt
762
771
  acc << with_agent(:figure_bottom, String, invoker)
772
+ else
773
+ acc << elt
763
774
  end
764
775
  join_blocks(acc)
765
776
  end
@@ -791,7 +802,8 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
791
802
  acc << "\\maketitle\n" if elts.include?("title")
792
803
  # and elts.include?("author")
793
804
  kw = keywords
794
- acc << %{#{@deplate.msg("Keywords:")} #{kw.join(", ")}} << "" if kw
805
+ acc << %{#{@deplate.msg("Keywords:")} #{kw.join(", ")}} if kw
806
+ acc << "" unless invoker.inlay?
795
807
  # end
796
808
  join_blocks(acc)
797
809
  end
@@ -836,7 +848,8 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
836
848
  # dest = "file://" + File.expand_path(dest)
837
849
  # end
838
850
  dest = Deplate::HyperLink.url_anchor(dest, anchor)
839
- dest.gsub!(/([&%#])/, "\\\\\\1")
851
+ # dest.gsub!(/([&%#])/, "\\\\\\1")
852
+ dest.gsub!(/([%#])/, "\\\\\\1")
840
853
  "\\href{%s}{%s}" % [dest, name]
841
854
  end
842
855
 
@@ -980,7 +993,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
980
993
  elsif n
981
994
  o << "[]"
982
995
  end
983
- o = o.join unless o.empty?
996
+ o = o.empty? ? '' : o.join
984
997
  if np
985
998
  cmd = if y then 'citeyear' else 'citealp' end
986
999
  elsif ip
@@ -1441,7 +1454,10 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1441
1454
 
1442
1455
  def float_options(invoker)
1443
1456
  args = invoker.args
1444
- if args["here"] or @deplate.variables["floatHere"]
1457
+ if args["here"] == "H" or @deplate.variables["floatHere"] == "H"
1458
+ floatPos = "[H]"
1459
+ add_package("float")
1460
+ elsif args["here"] or @deplate.variables["floatHere"]
1445
1461
  floatPos = "[hptb]"
1446
1462
  else
1447
1463
  floatPos = nil
@@ -1460,6 +1476,11 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1460
1476
  end
1461
1477
  return floatPos, alignCmd
1462
1478
  end
1479
+
1480
+ def block_postfix(invoker)
1481
+ return invoker.inlay? ? "" : "\n"
1482
+ end
1483
+
1463
1484
  end
1464
1485
 
1465
1486