docgenerator 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/examples/creole_example.rb +0 -1
  3. data/examples/creole_example_new_plugin.rb +51 -0
  4. data/examples/creole_example_tabular.rb +3 -1
  5. data/examples/wiki2docgenerator_example.rb +2 -2
  6. data/lib/creole/creole2doc.rb +697 -680
  7. data/lib/creole/creole_characters.rb +90 -26
  8. data/lib/creole/creole_inclusion_and_plugins.rb +25 -43
  9. data/lib/creole/creole_inclusions.rb +87 -75
  10. data/lib/creole/creole_placeholder.rb +87 -89
  11. data/lib/creole/creole_plugins.rb +149 -117
  12. data/lib/creole/creole_tabular.rb +247 -141
  13. data/lib/creole/plugins/todonotes.rb +48 -48
  14. data/lib/docgenerator/characters.rb +106 -8
  15. data/lib/docgenerator/compatibility_v1.rb +7 -1
  16. data/lib/docgenerator/document.rb +34 -19
  17. data/lib/docgenerator/element.rb +1 -0
  18. data/lib/docgenerator/element_meta.rb +1 -1
  19. data/lib/docgenerator/elements.rb +594 -535
  20. data/lib/docgenerator/environments.rb +131 -99
  21. data/lib/docgenerator/index.rb +110 -0
  22. data/lib/docgenerator/lists.rb +2 -1
  23. data/lib/docgenerator/packages/caption.rb +32 -34
  24. data/lib/docgenerator/packages/hyperref.rb +1 -0
  25. data/lib/docgenerator/packages/multicol.rb +3 -2
  26. data/lib/docgenerator/packages/pdfpages.rb +71 -20
  27. data/lib/docgenerator/packages/scrpage2.rb +99 -142
  28. data/lib/docgenerator/packages/url.rb +75 -81
  29. data/lib/docgenerator/sections.rb +98 -98
  30. data/lib/docgenerator/standard.rb +8 -1
  31. data/lib/docgenerator/tabular.rb +44 -25
  32. data/lib/docgenerator/templates/docgenerator_template.yaml +28 -0
  33. data/lib/docgenerator/version.rb +146 -0
  34. data/lib/docgenerator.rb +20 -15
  35. data/meta_test_and_doc/build_doc.rb +39 -10
  36. data/meta_test_and_doc/build_test.rb +34 -12
  37. data/meta_test_and_doc/manpages/characters.rb +452 -20
  38. data/meta_test_and_doc/manpages/elementlist.rb +304 -0
  39. data/meta_test_and_doc/manpages/elements.rb +305 -42
  40. data/meta_test_and_doc/manpages/others.rb +403 -0
  41. data/meta_test_and_doc/manpages/pdfpages.rb +117 -18
  42. data/meta_test_and_doc/manpages/readme.rdoc +3 -1
  43. data/meta_test_and_doc/manpages/scrpage2.rb +0 -80
  44. data/meta_test_and_doc/manpages/tables.rb +6 -6
  45. data/readme.rdoc +11 -120
  46. data/unittest/expected/test_comment.html +1 -0
  47. data/unittest/expected/test_comment.latex +5 -0
  48. data/unittest/expected/test_comment_complex.html +3 -0
  49. data/unittest/expected/test_comment_complex.latex +15 -0
  50. data/unittest/expected_creole/test_creole_characters_all.html +6 -5
  51. data/unittest/expected_creole/test_creole_characters_all.latex +10 -8
  52. data/unittest/expected_creole/test_creole_creole1.0test.latex +5 -5
  53. data/unittest/expected_creole/test_creole_input.normsource +11 -9
  54. data/unittest/expected_creole/test_creole_list_ul.normsource +57 -51
  55. data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +6 -0
  56. data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +12 -0
  57. data/unittest/expected_creole/test_creole_paragraphs.normsource +12 -10
  58. data/unittest/expected_creole/test_creole_pictures.latex +2 -2
  59. data/unittest/expected_creole/test_creole_pictures_css.latex +2 -2
  60. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +2 -2
  61. data/unittest/expected_creole/test_creole_pictures_width.latex +1 -1
  62. data/unittest/expected_creole/test_creole_tabular.latex +3 -3
  63. data/unittest/expected_creole/test_creole_tabular_creole.latex +2 -2
  64. data/unittest/expected_creole/test_creole_tabular_css.latex +3 -3
  65. data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +22 -0
  66. data/unittest/expected_templates/test_standalone.tex +34 -0
  67. data/unittest/expected_wikimedia/test_wiki_picture.latex +12 -12
  68. data/unittest/unittest_creole.rb +22 -3
  69. data/unittest/unittest_creole_tabular.rb +34 -1
  70. data/unittest/unittest_docgenerator.rb +46 -3
  71. data/unittest/unittest_docgenerator_characters.rb +527 -82
  72. data/unittest/unittest_templates.rb +1 -1
  73. metadata +149 -108
@@ -6,6 +6,10 @@ This document is UTF-8-encoded.
6
6
  A side effect: Hanna/Rdoc will not add this code to the documentation.
7
7
  =end
8
8
 
9
+ #
10
+ # Fixme: Add unicode-codepoints
11
+ #
12
+
9
13
 
10
14
  #
11
15
  module Docgenerator
@@ -37,7 +41,65 @@ Attributes are not defined for this element.
37
41
  add_text_output ''
38
42
  add_creole_output '{{shy}}'
39
43
  end #Shy
44
+ =begin rdoc
45
+ Define Element ZeroWidthSpace
46
+
47
+ Create an instance with
48
+ element( :zerowidthspace )
49
+ or
50
+ ZeroWidthSpace.new( )
51
+ Attributes are not defined for this element.
52
+
53
+ See http://stackoverflow.com/questions/5038920/html-soft-hypen-shy-without-dash
54
+ =end
55
+ class ZeroWidthSpace < Element
56
+ has_no_content false
57
+ add_html_output '&#8203;'
58
+ add_latex_output '""'
59
+ add_text_output ''
60
+ #~ add_creole_output '{{-}}'
61
+ end #ZeroWidthSpace
62
+
63
+ =begin rdoc
64
+ Define Element :thinsp
65
+
66
+ Small space in text
67
+
68
+ Create an instance with
69
+ element( :thinsp )
70
+ or
71
+ thinsp.new( )
72
+ Attributes are not defined for this element.
73
+
74
+ See http://stackoverflow.com/questions/5038920/html-soft-hypen-shy-without-dash
75
+ for usage as Soft hypen (&shy;) without dash.
76
+ =end
77
+ class Thinsp < Element
78
+ has_no_content false
79
+ add_html_output '&thinsp;'
80
+ add_latex_output '\,'
81
+ add_text_output ''
82
+ add_creole_output '{{thinsp}}'
83
+ end #thinsp
84
+ =begin rdoc
85
+ Define Element :wbr
86
+
87
+ optionalen line break, no separator.
40
88
 
89
+ Create an instance with
90
+ element( :wbr )
91
+ or
92
+ Wbr.new( )
93
+ Attributes are not defined for this element.
94
+ =end
95
+ class Wbr < Element
96
+ has_no_content false
97
+ add_html_output '&wbr;'
98
+ add_latex_output '""'
99
+ add_text_output '' #&#8203;
100
+ add_creole_output '{{wbr}}'
101
+ end #Wbr
102
+
41
103
  =begin rdoc
42
104
  Define Element :space, :ensp
43
105
 
@@ -382,7 +444,7 @@ Attributes are not defined for this element.
382
444
  add_id :<=
383
445
  has_no_content false
384
446
  add_html_output '&lArr;'
385
- add_latex_output '\ensuremath{\Lefttarrow}'
447
+ add_latex_output '\ensuremath{\Leftarrow}'
386
448
  add_text_output '<='
387
449
  add_creole_output '<='
388
450
  end #Larr
@@ -476,6 +538,23 @@ Attributes are not defined for this element.
476
538
  end #Lt
477
539
 
478
540
  =begin rdoc
541
+ Define Element :ll, :<<
542
+
543
+ Create an instance with
544
+ element( :l< )
545
+ element( :<< )
546
+ or
547
+ Ll.new( )
548
+ Attributes are not defined for this element.
549
+ =end
550
+ class Ll < Element
551
+ add_id :<<
552
+ has_no_content false
553
+ add_html_output '&laquo;'
554
+ add_latex_output '\ll '
555
+ add_text_output '<<'
556
+ end #Lt
557
+ =begin rdoc
479
558
  Define Element :gt, :>
480
559
 
481
560
  Create an instance with
@@ -493,6 +572,24 @@ Attributes are not defined for this element.
493
572
  add_text_output '>'
494
573
  end #Gt
495
574
 
575
+ =begin rdoc
576
+ Define Element :gg, :>>
577
+
578
+ Create an instance with
579
+ element( :gg )
580
+ element( :>> )
581
+ or
582
+ Gg.new( )
583
+ Attributes are not defined for this element.
584
+ =end
585
+ class Gg < Element
586
+ add_id :>>
587
+ has_no_content false
588
+ add_html_output '&raquo;'
589
+ add_latex_output '\gg '
590
+ add_text_output '>>'
591
+ end #Gt
592
+
496
593
  =begin rdoc
497
594
  Define Element :infin, :infty
498
595
 
@@ -755,6 +852,7 @@ Attributes are not defined for this element.
755
852
  has_no_content false
756
853
  add_html_output '&bdquo;'
757
854
  add_latex_output '\glqq '
855
+ add_text_output '„'
758
856
  add_wiki_output '„'
759
857
  add_creole_output '„'
760
858
  end #Bdquo
@@ -770,11 +868,10 @@ Attributes are not defined for this element.
770
868
  =end
771
869
  class Leftdoublequotemark < Element
772
870
  add_id :ldquo
773
- add_id :grqq
774
871
  has_no_content false
775
872
  add_html_output '&ldquo;'
776
- add_latex_output '\grqq'
777
- add_text_output '``'
873
+ add_latex_output '\lq\lq{}'
874
+ add_text_output ''
778
875
  add_wiki_output '“'
779
876
  add_creole_output '“'
780
877
  end #Ldquo
@@ -790,12 +887,13 @@ Attributes are not defined for this element.
790
887
  =end
791
888
  class Rightdoublequotemark < Element
792
889
  add_id :rdquo
793
- add_id :rqq
890
+ add_id :grqq
794
891
  has_no_content false
795
892
  add_html_output '&rdquo;'
796
- add_latex_output '\rqq '
797
- add_text_output ''''
798
- #~ add_creole_output ''
893
+ add_latex_output '\grqq '
894
+ add_text_output ''
895
+ add_wiki_output ''
896
+ add_creole_output '”'
799
897
  end #Rdquo
800
898
 
801
899
  =begin rdoc
@@ -102,12 +102,18 @@ This code is obsolete.
102
102
  Please use Element.create_convert_to_code to get a template to replace your Element#create.
103
103
  =end
104
104
  def self.create( name, attr = {}, content = false, output = {} )
105
- DOCGENERATOR_LOGGER.warn("Element.create called -> to be replaced") if DOCGENERATOR_LOGGER.warn?
105
+ if @@ids[name]
106
+ DOCGENERATOR_LOGGER.error("Element.create for existing #{name.inspect} called -> ignored") if DOCGENERATOR_LOGGER.error?
107
+ return
108
+ else
109
+ DOCGENERATOR_LOGGER.warn("Element.create for #{name.inspect} called -> to be replaced") if DOCGENERATOR_LOGGER.warn?
110
+ end
106
111
  create_convert_to_code( [name].flatten, attr, content, output ) if DOCGENERATOR_LOGGER.warn?
107
112
  #First some checks
108
113
  if ! attr.kind_of?( Hash )
109
114
  raise "Type error Element.create: Expected Hash, get #{attr.class}"
110
115
  end
116
+
111
117
  #Generic class creation
112
118
  elementclass = Class.new( Element )
113
119
  #Add the id of the new class to central collection.
@@ -99,7 +99,7 @@ The templates refer to the corresponding TeX-classes.
99
99
 
100
100
  settings.each{|key, value|
101
101
  case key
102
- when :title, :shorttitle, :author, :date, :keywords, :description, :creator, :language
102
+ when :title, :shorttitle, :subtitle, :author, :date, :location, :keywords, :description, :creator, :language
103
103
  self.send("#{key}=".to_sym, value)
104
104
  #~ when :odp, :pdf, :amazon #VALID_META_TAGS
105
105
  when *VALID_META_TAGS.map{|mkey|mkey.to_sym}
@@ -136,13 +136,14 @@ The templates refer to the corresponding TeX-classes.
136
136
  @body << element(:maketitle ).cr if settings[key]
137
137
  when :latex_options
138
138
  add_option(value)
139
- when :log
139
+ when :log, :logname
140
140
  else
141
141
  @log.warn("Document.new: Unknown setting #{key.inspect} (=#{value.inspect})") if @log.warn?
142
142
  end
143
143
  } #settings
144
144
 
145
145
  if @template[:html].encoding.name == 'UTF-8'
146
+ @log.debug("Document.new: set UTF-8 for html") if @log.debug?
146
147
  @head << element(:htmlonly,{},'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">').Cr
147
148
  end
148
149
 
@@ -154,6 +155,8 @@ The templates refer to the corresponding TeX-classes.
154
155
  attr_reader :log
155
156
  #Document title
156
157
  attr_accessor :title, :shorttitle
158
+ #For usage in ocument title
159
+ attr_accessor :subtitle
157
160
  #Set document description
158
161
  attr_writer :author, :date, :keywords, :description, :creator
159
162
  attr_writer :language
@@ -207,6 +210,7 @@ Add a meta-tag-information for the HTML-Output.
207
210
  #Build docinfo.
208
211
  result = []
209
212
  result << element( :title, {:short => shorttitle }, @title).CR if @title
213
+ result << element( :subtitle, {}, @subtitle).CR if @subtitle
210
214
  result << element( :author, {}, @author).cr if @author
211
215
  result << element( :date, {}, @date).cr if @date
212
216
  result << element( :keywords, {}, @keywords).cr if @keywords
@@ -369,17 +373,6 @@ Valid options:
369
373
  return false
370
374
  end
371
375
 
372
-
373
- prefix = [ nil,
374
- "Build by\t#{__FILE__}",
375
- "Dir:\t\t#{Dir.pwd}",
376
- "Creator:\tDocgenerator #{Docgenerator::VERSION} - http://rubygems.org/gems/docgenerator",
377
- "Target:\t\t#{filename}",
378
- "#{Time.now.strftime('%Y/%m/%d %H:%M:%S')}",
379
- nil,
380
- "#{PREFIX_ENDFLAG}"
381
- ].join("\n\t")
382
-
383
376
  #Determine the target document type, depending on extension.
384
377
  extension = File.basename( filename ).split( /\./).last
385
378
  case extension
@@ -419,6 +412,20 @@ Valid options:
419
412
  :replacements => options[:replacements],
420
413
  :log => @log
421
414
  })
415
+
416
+ #Define a file prefix.
417
+ prefix = [ nil,
418
+ ( target == :latex ? "!TEX encoding= %s" : 'encoding: %s' ) % new.encoding,
419
+ #~ "!TEX TS-program = lualatex",
420
+ "Build by\t#{__FILE__}",
421
+ "Dir:\t\t#{Dir.pwd}",
422
+ "Creator:\tDocgenerator #{Docgenerator::VERSION} - http://rubygems.org/gems/docgenerator",
423
+ "Target:\t\t#{filename}",
424
+ "#{Time.now.strftime('%Y/%m/%d %H:%M:%S')}",
425
+ nil,
426
+ "#{PREFIX_ENDFLAG}"
427
+ ].join("\n\t")
428
+
422
429
  #Get previous content if available
423
430
  old = nil
424
431
  if File.exist?( filename )
@@ -559,7 +566,10 @@ If the method is called directly to prepare document snipplets, you can use:
559
566
  new.sub!( '<<head>>', @head.to_doc(target, options ).encode(encoding))
560
567
 
561
568
  options[:log].debug( "Build body") if options[:log].debug?
562
- new.sub!( '<<body>>', @body.to_doc(target, options).encode(encoding))
569
+ #The block version is needed.
570
+ #Else there is a problem with \&
571
+ #Example: puts 'xx<<body>>xx'.sub('<<body>>', 'a\&b')
572
+ new.sub!( '<<body>>'){ @body.to_doc(target, options).encode(encoding) }
563
573
 
564
574
  new.sub!( '<<classoptions>>', @options.uniq.join(',').encode(encoding))
565
575
 
@@ -571,6 +581,10 @@ If the method is called directly to prepare document snipplets, you can use:
571
581
  return new
572
582
  end #Document#to_doc
573
583
 
584
+ def inspect()
585
+ return "#<Document '#{self.title}'>"
586
+ end
587
+
574
588
  #
575
589
  #Eigenclass Document
576
590
  class << self
@@ -643,6 +657,10 @@ Better solution:
643
657
  * use elements from Docgenerator::Characters
644
658
  * Use unicode in TeX-Document.
645
659
  * Put string into \path, \verb or similar.
660
+
661
+ Usage:
662
+ Docgenerator::Document.texify('text_with_underscore')
663
+
646
664
  =end
647
665
  def texify( input )
648
666
  out = input.strip
@@ -657,9 +675,6 @@ Better solution:
657
675
  #~ out.gsub!( /€/, '\euro ') #regexp is in utf-8 -- may make problems.
658
676
  return out
659
677
  end
660
- def inspect()
661
- return "#<Document '#{@title}'>"
662
- end
663
- end #Eigenclass Document
678
+ end #Eigenclass Document
664
679
  end #Document
665
- end #module Docgenerator
680
+ end #module Docgenerator
@@ -419,6 +419,7 @@ false-values are ignored.
419
419
  If you need a "value=true", then add 'true' as a string.
420
420
 
421
421
  Example (Packages::IncludePDF):
422
+
422
423
  class IncludePDF < Element
423
424
  add_attribute :pages, Attribute.create( [ :texkeyval], [ String ] )
424
425
  add_attribute :nup, Attribute.create( [ :texkeyval], [ /\d+x\d+/ ] ) #multiple logical pages onto each sheet of paper.
@@ -225,7 +225,7 @@ Define the output routine, based on a string.
225
225
  cmd = <<-code
226
226
  def to_#{target}(options = {})
227
227
  o = set_option_defaults(options)
228
- o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: \#{options.keys.inspect}") if o[:log].debug?
228
+ o[:log].debug("enter to_#{target} for #{self.inspect}, options: \#{options.keys.inspect}") if o[:log].debug?
229
229
  code
230
230
  template = string.gsub(/\\/, '\\\\\\')
231
231
  template.gsub!(/"/, '\"')