docgenerator 1.0.4 → 1.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.
- data/lib/creole/creole2doc.rb +777 -0
- data/lib/creole/creole_inclusion_and_plugins.rb +236 -0
- data/lib/creole/creole_placeholder.rb +74 -0
- data/lib/creole/creole_tabular.rb +170 -0
- data/lib/docgenerator.rb +15 -6
- data/lib/docgenerator_attribute.rb +2 -2
- data/lib/docgenerator_characters.rb +20 -4
- data/lib/docgenerator_document.rb +132 -42
- data/lib/docgenerator_element.rb +531 -524
- data/lib/docgenerator_elements.rb +408 -399
- data/lib/docgenerator_environments.rb +28 -2
- data/lib/docgenerator_footnote.rb +72 -79
- data/lib/docgenerator_sections.rb +1 -1
- data/lib/docgenerator_tabular.rb +8 -3
- data/lib/packages/docgenerator_beamer.rb +253 -0
- data/lib/packages/docgenerator_scrlettr2.rb +53 -9
- data/lib/templates/docgenerator_template_css.rb +4 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +1087 -970
- data/lib/yaml2presentation/yaml2presentation.rb +1091 -0
- data/self_docgenerator.rb +8 -6
- data/unittest/Red_Flower.jpg +0 -0
- data/unittest/creole1.0test.txt +128 -0
- data/unittest/expected/beamer_01_doc.html +1 -1
- data/unittest/expected/beamer_02_doc.html +1 -1
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +34 -0
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +34 -0
- data/unittest/expected/beamer_doc_key_doc.html +1 -1
- data/unittest/expected/beamer_doc_note_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_bottom_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_left_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_right_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_top_doc.html +1 -1
- data/unittest/expected/test_footnote.html +2 -2
- data/unittest/expected/test_footnote.latex +1 -1
- data/unittest/expected/test_footnote_group.html +3 -3
- data/unittest/expected/test_footnote_group.latex +2 -2
- data/unittest/expected_creole/test_creole.html +3 -0
- data/unittest/expected_creole/test_creole_characters_all.html +10 -0
- data/unittest/expected_creole/test_creole_characters_all.latex +20 -0
- data/unittest/expected_creole/test_creole_characters_special.html +10 -0
- data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
- data/unittest/expected_creole/test_creole_countdown.html +3 -0
- data/unittest/expected_creole/test_creole_countdown.latex +4 -0
- data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
- data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
- data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
- data/unittest/expected_creole/test_creole_footnotes.html +9 -0
- data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
- data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
- data/unittest/expected_creole/test_creole_headings.html +17 -0
- data/unittest/expected_creole/test_creole_headings.latex +19 -0
- data/unittest/expected_creole/test_creole_headings.text +48 -0
- data/unittest/expected_creole/test_creole_headings.wiki +37 -0
- data/unittest/expected_creole/test_creole_hr.html +7 -0
- data/unittest/expected_creole/test_creole_hr.latex +9 -0
- data/unittest/expected_creole/test_creole_hr.text +4 -0
- data/unittest/expected_creole/test_creole_inline.html +3 -0
- data/unittest/expected_creole/test_creole_inline.latex +4 -0
- data/unittest/expected_creole/test_creole_inline.text +2 -0
- data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
- data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
- data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
- data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
- data/unittest/expected_creole/test_creole_input.normsource +23 -0
- data/unittest/expected_creole/test_creole_label.html +12 -0
- data/unittest/expected_creole/test_creole_label.latex +15 -0
- data/unittest/expected_creole/test_creole_line_break.html +6 -0
- data/unittest/expected_creole/test_creole_line_break.latex +8 -0
- data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
- data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
- data/unittest/expected_creole/test_creole_links_external.html +6 -0
- data/unittest/expected_creole/test_creole_links_external.latex +8 -0
- data/unittest/expected_creole/test_creole_links_external.text +4 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
- data/unittest/expected_creole/test_creole_links_file.html +6 -0
- data/unittest/expected_creole/test_creole_links_file.latex +8 -0
- data/unittest/expected_creole/test_creole_links_file.text +4 -0
- data/unittest/expected_creole/test_creole_list_ol.html +12 -0
- data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
- data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
- data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
- data/unittest/expected_creole/test_creole_list_ul.html +22 -0
- data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
- data/unittest/expected_creole/test_creole_list_ul.normsource +83 -0
- data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
- data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
- data/unittest/expected_creole/test_creole_newline.html +9 -0
- data/unittest/expected_creole/test_creole_newline.latex +11 -0
- data/unittest/expected_creole/test_creole_newline.text +7 -0
- data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
- data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource +27 -0
- data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
- data/unittest/expected_creole/test_creole_picture_link.html +6 -0
- data/unittest/expected_creole/test_creole_pictures.html +10 -0
- data/unittest/expected_creole/test_creole_pictures.latex +13 -0
- data/unittest/expected_creole/test_creole_pictures_css.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_css.latex +4 -0
- data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
- data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
- data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
- data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
- data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
- data/unittest/expected_creole/test_creole_tabular.html +20 -0
- data/unittest/expected_creole/test_creole_tabular.latex +22 -0
- data/unittest/expected_creole/test_creole_tabular_creole.html +18 -0
- data/unittest/expected_creole/test_creole_tabular_creole.latex +19 -0
- data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
- data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
- data/unittest/expected_creole/test_creole_toc.html +11 -0
- data/unittest/expected_creole/test_creole_toc.latex +22 -0
- data/unittest/expected_creole/test_creole_toc.text +4 -0
- data/unittest/expected_creole/test_creole_toc_text.html +5 -0
- data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
- data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
- data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
- data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
- data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
- data/unittest/expected_creole/test_creole_verbatim.html +25 -0
- data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
- data/unittest/expected_creole/test_creole_verbatim.text +17 -0
- data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
- data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
- data/unittest/expected_privat/test_creole_test_document.html +6 -0
- data/unittest/{expected → expected_wiki}/test_wiki.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_amazon.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.wiki +0 -0
- data/unittest/expected_wiki/test_wiki_footnote.html +8 -0
- data/unittest/expected_wiki/test_wiki_footnote.latex +17 -0
- data/unittest/{expected → expected_wiki}/test_wiki_footnote.text +2 -4
- data/unittest/expected_wiki/test_wiki_footnote.wiki +10 -0
- data/unittest/expected_wiki/test_wiki_footnote_2.html +8 -0
- data/unittest/expected_wiki/test_wiki_footnote_groupid.html +21 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_label.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.log +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture_thumb.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.wiki +0 -0
- data/unittest/test_docgenerator.rb +1 -2
- data/unittest/unittest_creole2doc.rb +1024 -0
- data/unittest/unittest_docgenerator.rb +17 -8
- data/unittest/unittest_wiki2doc.rb +92 -88
- data/unittest/unittest_yaml2pres.rb +336 -0
- metadata +202 -70
- data/unittest/expected/test_wiki_footnote.html +0 -8
- data/unittest/expected/test_wiki_footnote.latex +0 -15
- data/unittest/expected/test_wiki_footnote.wiki +0 -12
- data/unittest/expected/test_wiki_footnote_groupid.html +0 -21
|
@@ -4,6 +4,28 @@
|
|
|
4
4
|
#Each document contains a header and a body. Both are special Element classes.
|
|
5
5
|
#
|
|
6
6
|
class Document
|
|
7
|
+
#Valid meta tags, used for HTML
|
|
8
|
+
#
|
|
9
|
+
#This meta-tags are used by sitegenerator
|
|
10
|
+
VALID_META_TAGS = %w{
|
|
11
|
+
keywords
|
|
12
|
+
description
|
|
13
|
+
id
|
|
14
|
+
altlang
|
|
15
|
+
toc
|
|
16
|
+
pdf
|
|
17
|
+
odp
|
|
18
|
+
amazon
|
|
19
|
+
forum
|
|
20
|
+
feed
|
|
21
|
+
}
|
|
22
|
+
class << VALID_META_TAGS
|
|
23
|
+
# Return true if self is part of the given parameter.
|
|
24
|
+
def ===(o)
|
|
25
|
+
return self.include?(o)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
7
29
|
#Create a new document.
|
|
8
30
|
#There are different document templates supported.
|
|
9
31
|
#The templates refer to the corresponding TeX-classes.
|
|
@@ -29,9 +51,12 @@ class Document
|
|
|
29
51
|
settings = { :template => settings }
|
|
30
52
|
end
|
|
31
53
|
##<<<<temporary check, old interface
|
|
54
|
+
|
|
32
55
|
@log = settings[:log]
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
if ! @log
|
|
57
|
+
@log = Log4r::Logger.new( 'Doc', Log4r::WARN )
|
|
58
|
+
@log.outputters = Log4r::StdoutOutputter.new('log_xxx')
|
|
59
|
+
end
|
|
35
60
|
@meta = {} #some meta-Tags for HTML
|
|
36
61
|
@body = element( :body )
|
|
37
62
|
@head = element( :head )
|
|
@@ -44,9 +69,10 @@ class Document
|
|
|
44
69
|
|
|
45
70
|
settings.each{|key, value|
|
|
46
71
|
case key
|
|
47
|
-
when
|
|
72
|
+
when :title, :shorttitle, :author, :date, :keywords, :description, :creator, :language
|
|
48
73
|
self.send("#{key}=".to_sym, value)
|
|
49
|
-
when :
|
|
74
|
+
#~ when :odp, :pdf, :amazon #VALID_META_TAGS
|
|
75
|
+
when *VALID_META_TAGS.map{|mkey|mkey.to_sym}
|
|
50
76
|
self.meta( key, value )
|
|
51
77
|
when :template
|
|
52
78
|
[value].flatten.each{|template|
|
|
@@ -62,11 +88,25 @@ class Document
|
|
|
62
88
|
end
|
|
63
89
|
end
|
|
64
90
|
} #templates
|
|
91
|
+
when :css
|
|
92
|
+
if ! File.exist?(value)
|
|
93
|
+
@log.warn("CSS-Reference not found (#{value})") if @log.warn?
|
|
94
|
+
end
|
|
95
|
+
#~ @head << element(:htmlonly,{}, <<css
|
|
96
|
+
#~ <meta http-equiv="Content-Style-Type" content="text/css">
|
|
97
|
+
#~ css
|
|
98
|
+
#~ <link rel="stylesheet" type="text/css" href="#{value}">
|
|
99
|
+
#~ ).cr
|
|
100
|
+
@head << element( :link, {
|
|
101
|
+
:href => value,
|
|
102
|
+
:rel => 'stylesheet',
|
|
103
|
+
:type => "text/css" } ).cr. restrict_to(:html)
|
|
65
104
|
when :maketitle
|
|
66
|
-
|
|
105
|
+
#:maketitle is defined, but we have also to check, if it is true
|
|
106
|
+
@body << element(:maketitle ).cr if settings[key]
|
|
67
107
|
when :log
|
|
68
108
|
else
|
|
69
|
-
@log.
|
|
109
|
+
@log.warn("Document.new: Unknown setting #{key.inspect} (=#{value.inspect})") if @log.warn?
|
|
70
110
|
end
|
|
71
111
|
} #settings
|
|
72
112
|
|
|
@@ -77,7 +117,7 @@ class Document
|
|
|
77
117
|
#Logger for the document
|
|
78
118
|
attr_reader :log
|
|
79
119
|
#Document title
|
|
80
|
-
attr_accessor :title
|
|
120
|
+
attr_accessor :title, :shorttitle
|
|
81
121
|
#Set document description
|
|
82
122
|
attr_writer :author, :date, :keywords, :description, :creator
|
|
83
123
|
attr_writer :language
|
|
@@ -103,9 +143,15 @@ class Document
|
|
|
103
143
|
#Add a meta-tag-information for the HTML-Output.
|
|
104
144
|
def meta( key, content )
|
|
105
145
|
key = key.to_s
|
|
146
|
+
|
|
147
|
+
if ! VALID_META_TAGS.include?(key)
|
|
148
|
+
@log.warn("Unknown meta-tag #{key} (#{content})") if @log.warn?
|
|
149
|
+
@log.info("\tAllowed meta-tags: #{VALID_META_TAGS.join(', ')}") if @log.info?
|
|
150
|
+
end
|
|
106
151
|
if @meta[key]
|
|
107
|
-
|
|
152
|
+
@log.warn("Double definition meta-tag #{key} (old: #{@meta[key]}, new: #{content})") if @log.warn? and @meta[key] != content
|
|
108
153
|
end
|
|
154
|
+
|
|
109
155
|
@meta[key] = content
|
|
110
156
|
end
|
|
111
157
|
#Prepare the docinfo.
|
|
@@ -122,7 +168,7 @@ class Document
|
|
|
122
168
|
|
|
123
169
|
#Build docinfo.
|
|
124
170
|
result = []
|
|
125
|
-
result << element( :title, {:short => @
|
|
171
|
+
result << element( :title, {:short => @shorttitle }, @title).CR if @title
|
|
126
172
|
result << element( :author, {}, @author).cr if @author
|
|
127
173
|
result << element( :date, {}, @date).cr if @date
|
|
128
174
|
result << element( :keywords, {}, @keywords).cr if @keywords
|
|
@@ -145,6 +191,9 @@ class Document
|
|
|
145
191
|
#- tocfilename: Added as prefix to link.
|
|
146
192
|
# can be used to make toc for in another file (cross-referencing)
|
|
147
193
|
#- level: Depth of toc
|
|
194
|
+
#The document should be filled before you add the toc.
|
|
195
|
+
#You an use Element#insertbefore:
|
|
196
|
+
# doc.body.insertbefore(start, doc.toc)
|
|
148
197
|
def toc( options = {} )
|
|
149
198
|
opt = {
|
|
150
199
|
:id => 'toc',
|
|
@@ -228,9 +277,44 @@ end
|
|
|
228
277
|
#There is a comparison between an already existing file and the new one.
|
|
229
278
|
#To write a new version, the document must change and overwrite must be true.
|
|
230
279
|
#
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
280
|
+
#Valid options:
|
|
281
|
+
#- :replacements
|
|
282
|
+
# It is possible to give pairs of RegExp (pattern) and replacements to the result.
|
|
283
|
+
#- overwrite [true]
|
|
284
|
+
# allows to overwrite
|
|
285
|
+
#- :additional_options
|
|
286
|
+
# List of options.
|
|
287
|
+
# If you want to give parameters to specific 'Element'-obejcts you can define the keys here.
|
|
288
|
+
# If you don't make it, you get warnings about undefined options.
|
|
289
|
+
#
|
|
290
|
+
def save( filename, options = {} )
|
|
291
|
+
#check old interface before 1.1.0
|
|
292
|
+
case options
|
|
293
|
+
when true, false
|
|
294
|
+
@log.warn( "Old interface for Document.save, use :overwrite => true/false" ) if @log.error?
|
|
295
|
+
options = { :overwrite => options }
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
options = {
|
|
299
|
+
:overwrite => true,
|
|
300
|
+
:replacements => {} ,
|
|
301
|
+
:additional_options => [],
|
|
302
|
+
}.update(options)
|
|
303
|
+
|
|
304
|
+
#Check valid options
|
|
305
|
+
options.each{|key,value|
|
|
306
|
+
case key
|
|
307
|
+
when :overwrite, :replacements
|
|
308
|
+
when :additional_options
|
|
309
|
+
else
|
|
310
|
+
if options[:additional_options].include?(key)
|
|
311
|
+
@log.warn( "unknown option #{key.inspect} for Document.save" ) if @log.warn?
|
|
312
|
+
else
|
|
313
|
+
@log.debug( "Save-Specific option #{key.inspect} in Document.save" ) if @log.debug?
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
}
|
|
317
|
+
|
|
234
318
|
if ! @template
|
|
235
319
|
@log.error( "No template available to create #{filename}" ) if @log.error?
|
|
236
320
|
return false
|
|
@@ -254,26 +338,26 @@ end
|
|
|
254
338
|
extension = File.basename( filename ).split( /\./).last
|
|
255
339
|
case extension
|
|
256
340
|
when /tex/i
|
|
257
|
-
|
|
341
|
+
target = :latex
|
|
258
342
|
when /htm[l]?/i
|
|
259
|
-
|
|
343
|
+
target = :html
|
|
260
344
|
when /txt/
|
|
261
|
-
|
|
345
|
+
target = :text
|
|
262
346
|
when /wiki/
|
|
263
|
-
|
|
347
|
+
target = :wiki
|
|
264
348
|
else
|
|
265
349
|
@log.fatal( "Unknown Extension #{extension} for #{File.basename( filename )}" ) if @log.fatal?
|
|
266
350
|
raise "Unknown Extension #{extension}"
|
|
267
351
|
end
|
|
268
352
|
|
|
269
|
-
new = to_doc(
|
|
353
|
+
new = to_doc( target, {
|
|
270
354
|
:template=> @template[target],
|
|
271
355
|
:filename => filename,
|
|
272
|
-
:replacements => replacements,
|
|
356
|
+
:replacements => options[:replacements],
|
|
273
357
|
:log => @log
|
|
274
358
|
})
|
|
275
359
|
|
|
276
|
-
case
|
|
360
|
+
case target
|
|
277
361
|
when :latex
|
|
278
362
|
prefix.gsub!( /^/, '%' )
|
|
279
363
|
old.sub!(/\A.*#{PREFIX_ENDFLAG}/m, '<<prefix>>' ) if old
|
|
@@ -284,8 +368,8 @@ end
|
|
|
284
368
|
when :wiki
|
|
285
369
|
#~ new.squeeze!("\n")
|
|
286
370
|
else
|
|
287
|
-
@log.fatal( "Unknown target #{
|
|
288
|
-
raise "Unknown target #{
|
|
371
|
+
@log.fatal( "Unknown target #{target} for #{File.basename( filename )}" ) if @log.fatal?
|
|
372
|
+
raise "Unknown target #{target}"
|
|
289
373
|
end
|
|
290
374
|
#Make it a bit more compact.
|
|
291
375
|
#TeX requires at least 2 \n for paragraph changes
|
|
@@ -294,11 +378,10 @@ end
|
|
|
294
378
|
if ! new.kind_of?( String )
|
|
295
379
|
@log.error( "New is wrong type: #{new.inspect}" ) if @log.error?
|
|
296
380
|
end
|
|
297
|
-
@target = nil
|
|
298
381
|
|
|
299
382
|
if new != old
|
|
300
383
|
new.sub!( '<<prefix>>', prefix)
|
|
301
|
-
if ( File.exist?( filename ) and !overwrite )
|
|
384
|
+
if ( File.exist?( filename ) and ! options[:overwrite] )
|
|
302
385
|
puts "Datei #{filename} exist already \nContinue [yn]?"
|
|
303
386
|
answer = $stdin.gets() if $stdin.tty? #nur bei call aus DOS-Box
|
|
304
387
|
if ! ( answer =~ /[YyjJ].*/ )
|
|
@@ -316,23 +399,23 @@ end
|
|
|
316
399
|
#~ f = File.new( filename.sub( extension, 'bak'), 'w' )
|
|
317
400
|
#~ f << old
|
|
318
401
|
#~ f.close
|
|
319
|
-
Document.runtex( filename, @runtex ) if @runtex
|
|
402
|
+
Document.runtex( filename, @runtex ) if @runtex and target == :latex
|
|
320
403
|
return true
|
|
321
404
|
elsif old
|
|
322
405
|
@log.info("Unchanged\t#{filename}") if @log.info?
|
|
323
406
|
puts "Unchanged\t#{filename}" if @@givemessage.include?(:nochange)
|
|
324
407
|
return false
|
|
325
408
|
end
|
|
326
|
-
end
|
|
409
|
+
end #Document#save
|
|
327
410
|
#Build the content for the target format.
|
|
328
|
-
#Supported
|
|
411
|
+
#Supported target formats are:
|
|
329
412
|
#- :latex
|
|
330
413
|
#- :html
|
|
331
414
|
#- :text
|
|
332
415
|
#If the standard templates are used, there is a <<prefix>> left
|
|
333
416
|
#(used from Document#save to include some additional information).
|
|
334
417
|
#
|
|
335
|
-
#If the method is called directly to
|
|
418
|
+
#If the method is called directly to prepare document snipplets, you can use:
|
|
336
419
|
# puts Document#to_doc( :latex, '<<body>>')
|
|
337
420
|
#
|
|
338
421
|
#It is possible to give pairs of RegExp (pattern) and a replacement to the result.
|
|
@@ -385,28 +468,35 @@ end
|
|
|
385
468
|
attr_reader :target
|
|
386
469
|
|
|
387
470
|
#Call TeX and translate the file.
|
|
388
|
-
#Experimental
|
|
471
|
+
#Experimental, unpublished feature up to now.
|
|
389
472
|
#Fixme: Chain
|
|
390
|
-
def Document.runtex( filename, format = :
|
|
473
|
+
def Document.runtex( filename, format = :pdflualatex )
|
|
391
474
|
begin
|
|
392
|
-
|
|
393
|
-
require 'c:/usr/script/
|
|
475
|
+
require 'runtex'
|
|
476
|
+
#~ require 'c:/usr/script/runtex/lib/runtex'
|
|
394
477
|
rescue LoadError
|
|
395
|
-
puts "Sorry, didn't find the experimental tex translation tool to translate #{filename}"
|
|
478
|
+
puts "Sorry, I didn't find the experimental tex translation tool to translate #{filename}"
|
|
396
479
|
return false
|
|
397
480
|
end
|
|
398
481
|
#~ puts "Unknown texfile #{filename}" if ! filename
|
|
399
|
-
tex =
|
|
400
|
-
|
|
401
|
-
case format
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
when :
|
|
405
|
-
|
|
406
|
-
#~
|
|
407
|
-
tex.
|
|
482
|
+
tex = RunTeX::Job_chain.new( filename,
|
|
483
|
+
:format => format )
|
|
484
|
+
#~ case format
|
|
485
|
+
#~ when true: tex.pdflualatex() #default
|
|
486
|
+
#~ when false, nil
|
|
487
|
+
#~ when :pdflatex; tex.pdflatex()
|
|
488
|
+
#~ when :pdflualatex; tex.pdflualatex()
|
|
489
|
+
#~ when :xelatex; tex.xelatex()
|
|
490
|
+
#~ when :latex; tex.latex()
|
|
491
|
+
#~ else
|
|
492
|
+
#~ puts "Undefined chain #{format.inspect} for runtex, use pdflualatex"
|
|
493
|
+
#~ tex.pdflualatex() #default
|
|
494
|
+
#~ end
|
|
495
|
+
#~ tex.file = filename
|
|
408
496
|
begin
|
|
409
|
-
|
|
497
|
+
puts "Start TeX-job #{tex.basename}"
|
|
498
|
+
tex.log.level = Log4r::WARN
|
|
499
|
+
tex.start(format)
|
|
410
500
|
rescue SystemExit
|
|
411
501
|
puts "rescued a SystemExit exception"
|
|
412
502
|
return false
|