deplate 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/AUTHORS.TXT +2 -1
  2. data/CHANGES.TXT +56 -211
  3. data/NEWS.TXT +15 -38
  4. data/VERSION.TXT +1 -1
  5. data/bin/deplate +0 -0
  6. data/bin/deplate.bat +0 -0
  7. data/etc/deplate.ini +11 -0
  8. data/lib/deplate/commands.rb +8 -3
  9. data/lib/deplate/common.rb +2 -2
  10. data/lib/deplate/core.rb +157 -45
  11. data/lib/deplate/css/article.css +19 -3
  12. data/lib/deplate/css/doc.css +770 -0
  13. data/lib/deplate/elements.rb +7 -7
  14. data/lib/deplate/ents/general-latin1.entities +100 -0
  15. data/lib/deplate/ents/general-utf-8.entities +252 -0
  16. data/lib/deplate/external.rb +3 -2
  17. data/lib/deplate/fmt/html.rb +12 -10
  18. data/lib/deplate/fmt/latex.rb +25 -14
  19. data/lib/deplate/fmt/plain.rb +4 -5
  20. data/lib/deplate/fmt/xhtml11m.rb +25 -0
  21. data/lib/deplate/formatter.rb +106 -32
  22. data/lib/deplate/input.rb +8 -7
  23. data/lib/deplate/lib/Makefile.config +11 -1
  24. data/lib/deplate/locale/de.latin1 +9 -0
  25. data/lib/deplate/macros.rb +23 -18
  26. data/lib/deplate/mod/code-coderay.rb +45 -0
  27. data/lib/deplate/mod/code-gvim.rb +3 -2
  28. data/lib/deplate/mod/code-gvim71.rb +3 -6
  29. data/lib/deplate/mod/code-highlight.rb +3 -2
  30. data/lib/deplate/mod/entities-decode.rb +72 -0
  31. data/lib/deplate/mod/entities-encode.rb +50 -0
  32. data/lib/deplate/mod/guesslanguage.rb +3 -3
  33. data/lib/deplate/mod/html-jsmath.rb +5 -5
  34. data/lib/deplate/mod/html-mathml.rb +40 -0
  35. data/lib/deplate/mod/latex-styles.rb +21 -11
  36. data/lib/deplate/mod/makefile.rb +21 -11
  37. data/lib/deplate/mod/markup-1.rb +3 -3
  38. data/lib/deplate/mod/particle-math.rb +15 -6
  39. data/lib/deplate/particles.rb +2 -2
  40. data/lib/deplate/regions.rb +50 -15
  41. data/lib/deplate/template.rb +7 -2
  42. data/lib/deplate/themes/presentation.html/css/highstep.css +29 -0
  43. data/lib/deplate/themes/presentation.html/css/presentation.css +206 -0
  44. data/lib/deplate/themes/presentation.html/css/website.css +281 -0
  45. data/lib/deplate/themes/presentation.html/prelude.txt +19 -0
  46. data/lib/deplate/themes/presentation.html/resources/spacer.png +0 -0
  47. data/lib/deplate/themes/presentation.html/templates/presentation.html +26 -0
  48. data/lib/deplate/themes/presentation.html/theme.ini +20 -0
  49. data/man/man1/deplate.1 +147 -73
  50. metadata +67 -40
  51. data/bin/deplate.exy +0 -192
@@ -3,8 +3,8 @@
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: 2007-09-30.
7
- # @Revision: 0.2110
6
+ # @Last Change: 2008-07-06.
7
+ # @Revision: 0.2138
8
8
 
9
9
  require "deplate/formatter"
10
10
 
@@ -529,10 +529,11 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
529
529
  else
530
530
  @packages[pkg] = options.dup
531
531
  case pkg
532
- when 'hyperref', 'graphicx'
533
- if @deplate.options.pdftex
534
- options << 'pdftex'
535
- end
532
+ when 'hyperref'
533
+ options << 'pdftex' if @deplate.options.pdftex
534
+ options << 'unicode' if canonic_encoding() == 'utf-8'
535
+ when 'graphicx'
536
+ options << 'pdftex' if @deplate.options.pdftex
536
537
  end
537
538
 
538
539
  unless options.empty?
@@ -689,12 +690,15 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
689
690
  end
690
691
 
691
692
  def format_abstract(invoker)
692
- format_environment(invoker, "abstract", wrap_text(invoker.elt))
693
+ format_environment(invoker, "abstract", invoker.elt)
693
694
  end
694
695
 
695
696
  def format_quote(invoker)
696
697
  env = invoker.args["long"] ? "quotation" : "quote"
697
- elt = wrap_text(invoker.elt)
698
+ # +++TBD CHECK: Extra newlines in output.
699
+ # https://sourceforge.net/forum/message.php?msg_id=5041702
700
+ # elt = wrap_text(invoker.elt)
701
+ elt = invoker.elt
698
702
  format_environment(invoker, env, elt)
699
703
  end
700
704
 
@@ -1017,8 +1021,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1017
1021
  protected ###################################### protected {{{1
1018
1022
  ################################################ General {{{1
1019
1023
  def set_document_encoding
1020
- enc = @deplate.variables["encoding"] || "latin1"
1021
- enc = canonic_enc_name(enc)
1024
+ enc = document_encoding()
1022
1025
  output_at(:pre, :fmt_packages, "\\usepackage[#{enc}]{inputenc}")
1023
1026
  end
1024
1027
 
@@ -1308,13 +1311,13 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1308
1311
  acc << "\\begin{minipage}{\\textwidth}"
1309
1312
  acc << alignCmd
1310
1313
  end
1311
- acc << "\\begin{tabular}{#{table_cols(invoker)}}"
1314
+ acc << with_agent(:table_tabular_top, String, invoker)
1312
1315
  join_blocks(acc)
1313
1316
  end
1314
1317
 
1315
1318
  def table_table_bottom(invoker, capAbove)
1316
1319
  acc = []
1317
- acc << "\\end{tabular}"
1320
+ acc << with_agent(:table_tabular_bottom, String, invoker)
1318
1321
  note = with_agent(:table_note, String, invoker)
1319
1322
  acc << "\\end{minipage}" if invoker.contains_footnotes or note
1320
1323
  acc << note if note
@@ -1323,6 +1326,14 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1323
1326
  acc << "\\end{table}"
1324
1327
  join_blocks(acc)
1325
1328
  end
1329
+
1330
+ def table_tabular_top(invoker)
1331
+ "\\begin{tabular}{#{table_cols(invoker)}}"
1332
+ end
1333
+
1334
+ def table_tabular_bottom(invoker)
1335
+ "\\end{tabular}"
1336
+ end
1326
1337
 
1327
1338
  def table_longtable_top(invoker, capAbove)
1328
1339
  add_package("longtable")
@@ -1351,7 +1362,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1351
1362
  if invoker.contains_footnotes or invoker.args["note"]
1352
1363
  acc << "\\begin{minipage}{\\textwidth}"
1353
1364
  end
1354
- acc << "\\begin{tabular}{#{table_cols(invoker)}}"
1365
+ acc << with_agent(:table_tabular_top, String, invoker)
1355
1366
  end
1356
1367
  join_blocks(acc)
1357
1368
  end
@@ -1364,7 +1375,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
1364
1375
  acc << table_table_bottom(invoker, capAbove)
1365
1376
  else
1366
1377
  acc << format_label(invoker, :once)
1367
- acc << "\\end{tabular}"
1378
+ acc << with_agent(:table_tabular_bottom, String, invoker)
1368
1379
  note = with_agent(:table_note, String, invoker)
1369
1380
  acc << "\\end{minipage}" if invoker.contains_footnotes or note
1370
1381
  acc << note if note
@@ -3,8 +3,8 @@
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: 2007-09-28.
7
- # @Revision: 0.3591
6
+ # @Last Change: 2008-05-14.
7
+ # @Revision: 0.3594
8
8
 
9
9
  require "deplate/formatter"
10
10
 
@@ -267,10 +267,9 @@ class Deplate::Formatter::Plain < Deplate::Formatter
267
267
  else
268
268
  i = i.to_s
269
269
  end
270
+ i += '.' unless i.empty?
270
271
  end
271
- unless i.empty?
272
- i += ". "
273
- end
272
+ i += ' ' unless i.empty?
274
273
  return wrap_text([indent, i, item.body].join, :hanging => 2), :none
275
274
  when "Itemize"
276
275
  if explicit or item.explicit and item.item
@@ -0,0 +1,25 @@
1
+ # @Author: Thomas Link (micathom AT gmail com)
2
+ # @Website: http://deplate.sf.net/
3
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
4
+ # @Created: 2008-04-14.
5
+ # @Last Change: 2008-04-14.
6
+ # @Revision: 0.42
7
+
8
+ require "deplate/fmt/xhtml10t"
9
+
10
+ # An uninformed hack to enable mathml.
11
+ class Deplate::Formatter::XHTML11m < Deplate::Formatter::XHTML10transitional
12
+ self.myname = "xhtml11m"
13
+ self.rx = /x?html?/i
14
+ self.suffix = ".xhtml"
15
+
16
+ def head_doctype
17
+ enc = canonic_encoding(nil, 'latin1' => 'ISO-8859-1')
18
+ return <<HEADER
19
+ <?xml version="1.0" encoding="#{enc}"?>
20
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
21
+ HEADER
22
+ end
23
+
24
+ end
25
+
@@ -3,8 +3,8 @@
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 31-Okt-2004.
6
- # @Last Change: 2007-10-21.
7
- # @Revision: 0.1574
6
+ # @Last Change: 2008-07-06.
7
+ # @Revision: 0.1658
8
8
 
9
9
  require 'deplate/abstract-class'
10
10
  require 'deplate/common'
@@ -135,15 +135,18 @@ class Deplate::Formatter < Deplate::CommonObject
135
135
  attr_accessor :bibentries
136
136
  # A hash holding all known document services (names => method).
137
137
  attr_accessor :doc_services
138
+ attr_reader :entities_table
138
139
 
139
140
  def initialize(deplate, args={})
140
- @deplate = deplate
141
- @variables = deplate.variables
142
- @advices = args[:advices] || {}
143
- @doc_services = args[:doc_services] || initialize_services
144
- @inlatex_idx = 0
145
- @encodings = {}
146
- @symbol_proxy = nil
141
+ @deplate = deplate
142
+ @variables = deplate.variables
143
+ @advices = args[:advices] || {}
144
+ @doc_services = args[:doc_services] || initialize_services
145
+ @inlatex_idx = 0
146
+ @encodings = {}
147
+ @symbol_proxy = nil
148
+ @entities_table = nil
149
+ @format_advice_backlist = []
147
150
  reset!
148
151
  end
149
152
 
@@ -239,7 +242,16 @@ class Deplate::Formatter < Deplate::CommonObject
239
242
  def log(*args)
240
243
  Deplate::Core.log(*args)
241
244
  end
242
-
245
+
246
+ # def canonic_encoding(default=nil, table=@encodings)
247
+ def canonic_encoding(default=nil, table={})
248
+ canonic_enc_name(@variables['encoding'] || default || 'latin1', table)
249
+ end
250
+
251
+ def document_encoding(table=@encodings)
252
+ canonic_enc_name(@variables['encoding'] || 'latin1', table)
253
+ end
254
+
243
255
  def canonic_enc_name(enc, table=@encodings)
244
256
  case enc.downcase
245
257
  when 'latin-1', 'latin1', 'l1', 'isolat1', 'iso-8859-1'
@@ -272,16 +284,20 @@ class Deplate::Formatter < Deplate::CommonObject
272
284
  end
273
285
 
274
286
  def format_particle(agent, invoker, *args)
275
- # rv = with_agent(agent, Array, invoker, *args)
276
- # rv.empty? ? format_unknown_particle(invoker) : rv.join
277
- rv = with_agent(agent, Array, invoker, *args)
278
- if rv and !rv.empty? and !self.class.naked_agents.include?(agent)
279
- wa = {}
280
- wa[:styles] = invoker.styles if invoker.respond_to?(:styles)
281
- rv = methods.find_all {|m| m =~ /^wrap_formatted_particle_/ }.
282
- inject(rv) {|rv, m| send(m, invoker, rv, wa)}
287
+ if @format_advice_backlist.include?(agent)
288
+ send(agent, invoker, *args)
289
+ else
290
+ # rv = with_agent(agent, Array, invoker, *args)
291
+ # rv.empty? ? format_unknown_particle(invoker) : rv.join
292
+ rv = with_agent(agent, Array, invoker, *args)
293
+ if rv and !rv.empty? and !self.class.naked_agents.include?(agent)
294
+ wa = {}
295
+ wa[:styles] = invoker.styles if invoker.respond_to?(:styles)
296
+ rv = methods.find_all {|m| m =~ /^wrap_formatted_particle_/ }.
297
+ inject(rv) {|rv, m| send(m, invoker, rv, wa)}
298
+ end
299
+ rv
283
300
  end
284
- rv
285
301
  end
286
302
 
287
303
  def format_particle_as_string(agent, invoker, *args)
@@ -289,16 +305,20 @@ class Deplate::Formatter < Deplate::CommonObject
289
305
  end
290
306
 
291
307
  def format_element(agent, invoker, *args)
292
- # rv = with_agent(agent, Array, invoker, *args)
293
- # rv.empty? ? format_unknown(invoker) : join_blocks(rv)
294
- rv = with_agent(agent, Array, invoker, *args)
295
- if rv and !rv.empty? and !self.class.naked_agents.include?(agent)
296
- wa = {}
297
- wa[:styles] = invoker.styles if invoker.respond_to?(:styles)
298
- rv = methods.find_all {|m| m =~ /^wrap_formatted_element_/ }.
299
- inject(rv) {|rv, m| send(m, invoker, rv, wa)}
308
+ if @format_advice_backlist.include?(agent)
309
+ send(agent, invoker, *args)
310
+ else
311
+ # rv = with_agent(agent, Array, invoker, *args)
312
+ # rv.empty? ? format_unknown(invoker) : join_blocks(rv)
313
+ rv = with_agent(agent, Array, invoker, *args)
314
+ if rv and !rv.empty? and !self.class.naked_agents.include?(agent)
315
+ wa = {}
316
+ wa[:styles] = invoker.styles if invoker.respond_to?(:styles)
317
+ rv = methods.find_all {|m| m =~ /^wrap_formatted_element_/ }.
318
+ inject(rv) {|rv, m| send(m, invoker, rv, wa)}
319
+ end
320
+ rv
300
321
  end
301
- rv
302
322
  end
303
323
 
304
324
  def format_element_as_string(agent, invoker, *args)
@@ -439,6 +459,44 @@ class Deplate::Formatter < Deplate::CommonObject
439
459
  end
440
460
  end
441
461
 
462
+ def setup_entities
463
+ unless @entities_table
464
+ @entities_table = []
465
+ enc = canonic_encoding()
466
+ ents = Deplate::Core.split_list(@deplate.variables['entities'] || 'general')
467
+ for d in Deplate::Core.library_directories(@deplate.vanilla, true, ['ents'])
468
+ for pre in self.class.formatter_family_members << nil
469
+ for ent in ents
470
+ f = File.join(d, '%s-%s.entities' % [ent, [pre, enc].compact.join('_')])
471
+ if File.readable?(f)
472
+ @entities_table = File.readlines(f).map do |line|
473
+ line.chomp.split(/\t/)
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end
479
+ end
480
+ end
481
+
482
+ def char_by_number(number)
483
+ @entities_table.each do |char, named, numbered|
484
+ if numbered == number
485
+ return char
486
+ end
487
+ end
488
+ return number
489
+ end
490
+
491
+ def char_by_name(name)
492
+ @entities_table.each do |char, named, numbered|
493
+ if named == name
494
+ return char
495
+ end
496
+ end
497
+ return name
498
+ end
499
+
442
500
  def check_symbol_proxy
443
501
  unless @symbol_proxy
444
502
  pre_process
@@ -736,9 +794,15 @@ class Deplate::Formatter < Deplate::CommonObject
736
794
  # Takes an optional block that takes a string as argument and returns
737
795
  # true if we shouldn't wrap the text at this position
738
796
  def wrap_text(text, args={})
797
+ outerMargin = args[:maxmargin] || (wm = @deplate.variables['wrapMargin'] && wm.to_i) || 72
798
+ innerMargin = args[:margin] || (wm = @deplate.variables['wrapMarginInner'] && wm.to_i) || 52
799
+ return text if outerMargin == 0 and innerMargin == 0
800
+ if outerMargin == 0
801
+ outerMargin = innerMargin + 20
802
+ else
803
+ innerMargin = outerMargin - 20
804
+ end
739
805
  moreIndent = args[:indent] || ''
740
- innerMargin = args[:margin] || 66
741
- outerMargin = args[:maxmargin] || 72
742
806
  hanging = args[:hanging] || nil
743
807
  hang_idt = hanging ? ' ' * hanging : nil
744
808
  acc = []
@@ -843,7 +907,17 @@ class Deplate::Formatter < Deplate::CommonObject
843
907
 
844
908
  # Format the math macro
845
909
  alias :format_math :format_ltx
846
-
910
+
911
+ def bare_latex_formula(text)
912
+ m = /^(\\\[|\$)(.*?)(\\\]|\$)$/.match(text)
913
+ if m
914
+ return [m[1] == '\\[', m[2]]
915
+ else
916
+ log(['Internal error', text], :error)
917
+ return nil
918
+ end
919
+ end
920
+
847
921
  # Process inline latex. The file names of the output are saved as an
848
922
  # array in <tt>invoker.elt</tt>.
849
923
  def inlatex(invoker)
@@ -990,7 +1064,7 @@ class Deplate::Formatter < Deplate::CommonObject
990
1064
 
991
1065
  def inlatex_clean(line)
992
1066
  line = line.chomp
993
- unless @deplate.options.allow.include?('t')
1067
+ unless @deplate.is_allowed?('t')
994
1068
  line.gsub!(INLATEX_RX, '+++disabled+++')
995
1069
  end
996
1070
  line
@@ -3,8 +3,8 @@
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 10-M�r-2005.
6
- # @Last Change: 2007-09-30.
7
- # @Revision: 0.809
6
+ # @Last Change: 2008-01-30.
7
+ # @Revision: 0.825
8
8
  #
9
9
  # = Description
10
10
  # = Usage
@@ -542,13 +542,13 @@ class Deplate::Input < Deplate::CommonObject
542
542
  parse_using(container, text, get_particles(:rx, alt), particles, alt)
543
543
  end
544
544
 
545
- def parse_with_source(source, text, alt=true, excluded=[])
545
+ def parse_with_source(source, text, alt=true, excluded=nil)
546
546
  container = Deplate::PseudoContainer.new(@deplate, :source => source)
547
- parse(container, text, alt, excluded)
547
+ parse(container, text, alt, :excluded => excluded)
548
548
  end
549
549
 
550
- def parse(container, text, alt=true, excluded=nil, args={})
551
- excluded ||= []
550
+ def parse(container, text, alt=true, args={})
551
+ excluded = args[:excluded] || []
552
552
  rx, particles = get_particles(:both, alt)
553
553
  for p in excluded
554
554
  case p
@@ -568,7 +568,8 @@ class Deplate::Input < Deplate::CommonObject
568
568
  # @@rxsrc_argval = %{(\\\\=|\\\\:|[^=:]*)+?}
569
569
  # @@rxsrc_argval = %{("(\\\\"|[^"])*?"|(\\\\ |\\\\=|\\\\:|\\\\!|[%s]+)+?)}
570
570
  # @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\\\.|[%s"]+)+?}
571
- @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\([^)]+\\)|\\\\.|[^%s"]+)+?}
571
+ # @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\([^)]+\\)|\\\\.|[^%s"]+)+?}
572
+ @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\([^)]+\\)|\\\\.|[^%s"]+)*?}
572
573
 
573
574
  # @@rxsrc_key = %{[$@\\w]+(\\[\\S*?\\])?}
574
575
  # @@rxsrc_args1 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "=!:"
@@ -4,12 +4,17 @@ OTHER={arg: files}
4
4
 
5
5
  DEPLATE=deplate
6
6
 
7
+ OFLAGS=
7
8
  DFLAGS={arg: options}
8
9
 
9
10
  HTML_DIR=html
10
11
  HTML_PLUS=
11
12
  HTML_DFLAGS=$\{HTML_PLUS\} -d $\{HTML_DIR\} -f html
12
13
 
14
+ XHTML_DIR=$\{HTML_DIR\}
15
+ XHTML_PLUS=$\{HTML_PLUS\}
16
+ XHTML_DFLAGS=$\{XHTML_PLUS\} -d $\{XHTML_DIR\} -f xhtml11m
17
+
13
18
  WEBSITE_DIR=website
14
19
  WEBSITE_DFLAGS=$\{HTML_PLUS\} -d $\{WEBSITE_DIR\} -f htmlsite
15
20
 
@@ -37,7 +42,7 @@ copy_css=if ls *.css 2> /dev/null; then cp -vu *.css $(1); fi
37
42
 
38
43
  .PHONY: view show cleantex website makefile pdfclean dviclean \
39
44
  dbk html pdf tex text man \
40
- prepare_website prepare_html prepare_text prepare_php prepare_dbk \
45
+ prepare_website prepare_html prepare_xhtml prepare_text prepare_php prepare_dbk \
41
46
  prepare_tex prepare_ref prepare_dvi prepare_pdf
42
47
 
43
48
  default: html
@@ -52,6 +57,11 @@ prepare_html:
52
57
  $(call copy_images,"$\{HTML_DIR\}")
53
58
  $(call copy_css,"$\{HTML_DIR\}")
54
59
 
60
+ prepare_xhtml:
61
+ mkdir -p $\{XHTML_DIR\}
62
+ $(call copy_images,"$\{XHTML_DIR\}")
63
+ $(call copy_css,"$\{XHTML_DIR\}")
64
+
55
65
  prepare_text:
56
66
  mkdir -p $\{TEXT_DIR\}
57
67
 
@@ -319,6 +319,9 @@ Leerer Textk
319
319
  ENDIF without IF
320
320
  ENDIF ohne IF
321
321
 
322
+ Error in module
323
+ Fehler in Modul
324
+
322
325
  Error in ruby code
323
326
  Fehler in Ruby Fragment
324
327
 
@@ -394,6 +397,9 @@ ID bereits vorhanden
394
397
  Imprint
395
398
  Impressum
396
399
 
400
+ Inadequate formatter
401
+ Unpassendes Ausgabeformat
402
+
397
403
  Including from STDIN
398
404
  Lese von STDIN
399
405
 
@@ -840,6 +846,9 @@ Unbekannte Dateiendung
840
846
  Unknown template
841
847
  Unbekannte Schablone
842
848
 
849
+ Unknown theme
850
+ Unbekanntes Thema
851
+
843
852
  Unknown variable
844
853
  Unbekannte Variable
845
854