docgenerator-creole 3.0.0

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 (221) hide show
  1. checksums.yaml +7 -0
  2. data/examples/creole_example.rb +76 -0
  3. data/examples/creole_example_footnote.rb +66 -0
  4. data/examples/creole_example_new_plugin.rb +51 -0
  5. data/examples/creole_example_placeholder.rb +77 -0
  6. data/examples/creole_example_rail.rb +155 -0
  7. data/examples/creole_example_rubycode.rb +144 -0
  8. data/examples/creole_example_struktex.rb +170 -0
  9. data/examples/creole_example_tabular.rb +96 -0
  10. data/examples/creole_example_tikz.rb +47 -0
  11. data/lib/docgenerator-creole.rb +5 -0
  12. data/lib/docgenerator/creole.rb +15 -0
  13. data/lib/docgenerator/creole/base.rb +170 -0
  14. data/lib/docgenerator/creole/characters.rb +131 -0
  15. data/lib/docgenerator/creole/creole.rb +708 -0
  16. data/lib/docgenerator/creole/document.rb +91 -0
  17. data/lib/docgenerator/creole/inclusion_and_plugins.rb +91 -0
  18. data/lib/docgenerator/creole/inclusions.rb +148 -0
  19. data/lib/docgenerator/creole/placeholder.rb +242 -0
  20. data/lib/docgenerator/creole/plugins.rb +230 -0
  21. data/lib/docgenerator/creole/plugins/index.rb +61 -0
  22. data/lib/docgenerator/creole/plugins/rail.rb +179 -0
  23. data/lib/docgenerator/creole/plugins/rubycode4creole.rb +136 -0
  24. data/lib/docgenerator/creole/plugins/struktex.rb +60 -0
  25. data/lib/docgenerator/creole/plugins/tikz.rb +93 -0
  26. data/lib/docgenerator/creole/plugins/todonotes.rb +77 -0
  27. data/lib/docgenerator/creole/tabular.rb +405 -0
  28. data/readme.rdoc +44 -0
  29. data/unittest/Red_Flower.jpg +0 -0
  30. data/unittest/expected_creole/test_creole.html +3 -0
  31. data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
  32. data/unittest/expected_creole/test_creole_characters_all.html +18 -0
  33. data/unittest/expected_creole/test_creole_characters_all.latex +36 -0
  34. data/unittest/expected_creole/test_creole_characters_special.html +10 -0
  35. data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
  36. data/unittest/expected_creole/test_creole_comment.context +11 -0
  37. data/unittest/expected_creole/test_creole_comment.creole +12 -0
  38. data/unittest/expected_creole/test_creole_comment.html +9 -0
  39. data/unittest/expected_creole/test_creole_comment.latex +11 -0
  40. data/unittest/expected_creole/test_creole_countdown.html +3 -0
  41. data/unittest/expected_creole/test_creole_countdown.latex +4 -0
  42. data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
  43. data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
  44. data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
  45. data/unittest/expected_creole/test_creole_footnotes.html +9 -0
  46. data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
  47. data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
  48. data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
  49. data/unittest/expected_creole/test_creole_headings.html +17 -0
  50. data/unittest/expected_creole/test_creole_headings.latex +19 -0
  51. data/unittest/expected_creole/test_creole_headings.text +48 -0
  52. data/unittest/expected_creole/test_creole_headings.wiki +37 -0
  53. data/unittest/expected_creole/test_creole_hr.html +7 -0
  54. data/unittest/expected_creole/test_creole_hr.latex +9 -0
  55. data/unittest/expected_creole/test_creole_hr.text +4 -0
  56. data/unittest/expected_creole/test_creole_ignore.html +3 -0
  57. data/unittest/expected_creole/test_creole_ignore.latex +4 -0
  58. data/unittest/expected_creole/test_creole_ignore.text +2 -0
  59. data/unittest/expected_creole/test_creole_inline.html +3 -0
  60. data/unittest/expected_creole/test_creole_inline.latex +4 -0
  61. data/unittest/expected_creole/test_creole_inline.text +2 -0
  62. data/unittest/expected_creole/test_creole_inline_apostroph.html +7 -0
  63. data/unittest/expected_creole/test_creole_inline_apostroph.latex +9 -0
  64. data/unittest/expected_creole/test_creole_inline_apostroph.text +5 -0
  65. data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
  66. data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
  67. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
  68. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
  69. data/unittest/expected_creole/test_creole_input.normsource +22 -0
  70. data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
  71. data/unittest/expected_creole/test_creole_input_file_simple.html +15 -0
  72. data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +15 -0
  73. data/unittest/expected_creole/test_creole_label.html +12 -0
  74. data/unittest/expected_creole/test_creole_label.latex +15 -0
  75. data/unittest/expected_creole/test_creole_line_break.html +6 -0
  76. data/unittest/expected_creole/test_creole_line_break.latex +8 -0
  77. data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
  78. data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
  79. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
  80. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
  81. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
  82. data/unittest/expected_creole/test_creole_links_external.html +6 -0
  83. data/unittest/expected_creole/test_creole_links_external.latex +8 -0
  84. data/unittest/expected_creole/test_creole_links_external.text +4 -0
  85. data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
  86. data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
  87. data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
  88. data/unittest/expected_creole/test_creole_links_file.html +6 -0
  89. data/unittest/expected_creole/test_creole_links_file.latex +8 -0
  90. data/unittest/expected_creole/test_creole_links_file.text +4 -0
  91. data/unittest/expected_creole/test_creole_links_implicit_end.creole +4 -0
  92. data/unittest/expected_creole/test_creole_links_implicit_end.html +3 -0
  93. data/unittest/expected_creole/test_creole_links_implicit_end.latex +4 -0
  94. data/unittest/expected_creole/test_creole_list_ol.html +12 -0
  95. data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
  96. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
  97. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
  98. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
  99. data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
  100. data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
  101. data/unittest/expected_creole/test_creole_list_ul.html +22 -0
  102. data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
  103. data/unittest/expected_creole/test_creole_list_ul.normsource +85 -0
  104. data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +83 -0
  105. data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
  106. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
  107. data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +6 -0
  108. data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +12 -0
  109. data/unittest/expected_creole/test_creole_mix_titles_list.html +10 -0
  110. data/unittest/expected_creole/test_creole_mix_titles_list.latex +18 -0
  111. data/unittest/expected_creole/test_creole_mix_titles_list.text +12 -0
  112. data/unittest/expected_creole/test_creole_newline.html +9 -0
  113. data/unittest/expected_creole/test_creole_newline.latex +11 -0
  114. data/unittest/expected_creole/test_creole_newline.text +7 -0
  115. data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
  116. data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
  117. data/unittest/expected_creole/test_creole_paragraphs.normsource +26 -0
  118. data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +27 -0
  119. data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
  120. data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
  121. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
  122. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
  123. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
  124. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
  125. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
  126. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
  127. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
  128. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
  129. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
  130. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
  131. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
  132. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
  133. data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.html +5 -0
  134. data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.latex +6 -0
  135. data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.text +4 -0
  136. data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.wiki +4 -0
  137. data/unittest/expected_creole/test_creole_picture_link.html +6 -0
  138. data/unittest/expected_creole/test_creole_pictures.html +10 -0
  139. data/unittest/expected_creole/test_creole_pictures.latex +13 -0
  140. data/unittest/expected_creole/test_creole_pictures_css.html +6 -0
  141. data/unittest/expected_creole/test_creole_pictures_css.latex +8 -0
  142. data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
  143. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
  144. data/unittest/expected_creole/test_creole_pictures_longdesc.html +3 -0
  145. data/unittest/expected_creole/test_creole_pictures_width.html +3 -0
  146. data/unittest/expected_creole/test_creole_pictures_width.latex +4 -0
  147. data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
  148. data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
  149. data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
  150. data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
  151. data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
  152. data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
  153. data/unittest/expected_creole/test_creole_short_html.html +3 -0
  154. data/unittest/expected_creole/test_creole_short_html.latex +4 -0
  155. data/unittest/expected_creole/test_creole_short_html.text +2 -0
  156. data/unittest/expected_creole/test_creole_shy.creole +6 -0
  157. data/unittest/expected_creole/test_creole_shy.html +6 -0
  158. data/unittest/expected_creole/test_creole_shy.latex +8 -0
  159. data/unittest/expected_creole/test_creole_shy.text +4 -0
  160. data/unittest/expected_creole/test_creole_tabular.creole +22 -0
  161. data/unittest/expected_creole/test_creole_tabular.html +20 -0
  162. data/unittest/expected_creole/test_creole_tabular.latex +22 -0
  163. data/unittest/expected_creole/test_creole_tabular_creole.creole +21 -0
  164. data/unittest/expected_creole/test_creole_tabular_creole.html +20 -0
  165. data/unittest/expected_creole/test_creole_tabular_creole.latex +21 -0
  166. data/unittest/expected_creole/test_creole_tabular_css.creole +24 -0
  167. data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
  168. data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
  169. data/unittest/expected_creole/test_creole_tabular_multicols.creole +16 -0
  170. data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
  171. data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
  172. data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +22 -0
  173. data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
  174. data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +20 -0
  175. data/unittest/expected_creole/test_creole_toc.html +13 -0
  176. data/unittest/expected_creole/test_creole_toc.latex +22 -0
  177. data/unittest/expected_creole/test_creole_toc.text +4 -0
  178. data/unittest/expected_creole/test_creole_toc_level.html +7 -0
  179. data/unittest/expected_creole/test_creole_toc_level.latex +10 -0
  180. data/unittest/expected_creole/test_creole_toc_level.text +3 -0
  181. data/unittest/expected_creole/test_creole_toc_level_text.html +8 -0
  182. data/unittest/expected_creole/test_creole_toc_level_text.latex +9 -0
  183. data/unittest/expected_creole/test_creole_toc_text.html +5 -0
  184. data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
  185. data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
  186. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
  187. data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
  188. data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
  189. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  190. data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
  191. data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
  192. data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
  193. data/unittest/expected_creole/test_creole_verbatim.html +25 -0
  194. data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
  195. data/unittest/expected_creole/test_creole_verbatim.text +17 -0
  196. data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
  197. data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
  198. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
  199. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
  200. data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
  201. data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
  202. data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
  203. data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
  204. data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
  205. data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
  206. data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
  207. data/unittest/expected_rubycode4doc/creole_output.html +2 -0
  208. data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
  209. data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
  210. data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
  211. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
  212. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
  213. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
  214. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
  215. data/unittest/unittest_creole.rb +1379 -0
  216. data/unittest/unittest_creole_placeholders.rb +161 -0
  217. data/unittest/unittest_creole_plugin_rail.rb +148 -0
  218. data/unittest/unittest_creole_plugin_rubycode4doc.rb +123 -0
  219. data/unittest/unittest_creole_plugin_struktex.rb +26 -0
  220. data/unittest/unittest_creole_tabular.rb +212 -0
  221. metadata +529 -0
@@ -0,0 +1,131 @@
1
+ =begin rdoc
2
+ Creole characters
3
+
4
+ This classes define special characters as inclusions.
5
+
6
+ * Inclusions are used later with {{xx}}
7
+ more at http://www.wikicreole.org/wiki/Inclusion
8
+ =end
9
+
10
+ #
11
+
12
+ module Docgenerator
13
+ module Creole
14
+
15
+ =begin rdoc
16
+ Define special characters as inclusions.
17
+
18
+ See also Creole::CHARACTERS
19
+ =end
20
+ module Characters
21
+ =begin rdoc
22
+ Define a 'shy' as {{shy}}
23
+ =end
24
+ class Creole_shy < Creole_inclusion_and_plugin
25
+ set_inclusions_key '-'
26
+ set_inclusions_key 'shy'
27
+
28
+ def to_doc(target, options = {})
29
+ element(:shy).to_doc(target, options)
30
+ end
31
+ end #Creole_shy
32
+ =begin rdoc
33
+ Define a 'thinsp' as {{thinsp}}
34
+
35
+ Could be used as Soft hypen (&shy;) without dash:
36
+ http://stackoverflow.com/questions/5038920/html-soft-hypen-shy-without-dash
37
+ =end
38
+ class Creole_thinsp < Creole_inclusion_and_plugin
39
+ set_inclusions_key 'thinsp'
40
+
41
+ def to_doc(target, options = {})
42
+ element(:thinsp).to_doc(target, options)
43
+ end
44
+ end #Creole_thinsp
45
+ =begin rdoc
46
+ Define a 'wbr' as {{wbr}}
47
+ =end
48
+ class Creole_wbr < Creole_inclusion_and_plugin
49
+ set_inclusions_key 'wbr'
50
+
51
+ def to_doc(target, options = {})
52
+ element(:wbr).to_doc(target, options)
53
+ end
54
+ end #Creole_wbr
55
+ =begin rdoc
56
+ Define a 'radic' as {{radic}}
57
+ =end
58
+ class Creole_radic < Creole_inclusion_and_plugin
59
+ set_inclusions_key 'radic'
60
+
61
+ def to_doc(target, options = {})
62
+ element(:radic).to_doc(target, options)
63
+ end
64
+ end #Creole_shy
65
+
66
+ =begin rdoc
67
+ Define a 'nil' as {{nil}}
68
+ =end
69
+ class Creole_nil < Creole_inclusion_and_plugin
70
+ set_inclusions_key 'nil'
71
+
72
+ def to_doc(target, options = {})
73
+ ''
74
+ end
75
+ end #Creole_nil
76
+
77
+ =begin rdoc
78
+ =end
79
+ class Creole_gt < Creole_inclusion_and_plugin
80
+ set_inclusions_key 'gt'
81
+ set_inclusions_key '>'
82
+
83
+ def to_doc(target, options = {})
84
+ element(:gt).to_doc(target, options)
85
+ end
86
+ end #Creole_gt
87
+ =begin rdoc
88
+ =end
89
+ class Creole_lt < Creole_inclusion_and_plugin
90
+ set_inclusions_key '<'
91
+
92
+ def to_doc(target, options = {})
93
+ element(:lt).to_doc(target, options)
94
+ end
95
+ end #Creole_lt
96
+
97
+ =begin rdoc
98
+ =end
99
+ class Creole_gg < Creole_inclusion_and_plugin
100
+ set_inclusions_key 'dgt'
101
+ set_inclusions_key '>>'
102
+
103
+ def to_doc(target, options = {})
104
+ element(:gg).to_doc(target, options)
105
+ end
106
+ end #Creole_gt
107
+ =begin rdoc
108
+ =end
109
+ class Creole_ll < Creole_inclusion_and_plugin
110
+ set_inclusions_key 'dlt'
111
+ set_inclusions_key '<<'
112
+
113
+ def to_doc(target, options = {})
114
+ element(:ll).to_doc(target, options)
115
+ end
116
+ end #Creole_ll
117
+
118
+ =begin rdoc
119
+ =end
120
+ class Creole_ldots < Creole_inclusion_and_plugin
121
+ set_inclusions_key 'hellip'
122
+ set_inclusions_key '...'
123
+
124
+ def to_doc(target, options = {})
125
+ element(:ldots).to_doc(target, options)
126
+ end
127
+ end #Creole_ldots
128
+
129
+ end #module Characters
130
+ end #module Creole
131
+ end #module Docgenerator
@@ -0,0 +1,708 @@
1
+ #encoding: utf-8
2
+ =begin rdoc
3
+ Define class Docgenerator::Creole::Creole
4
+ =end
5
+
6
+ module Docgenerator
7
+
8
+ =begin rdoc
9
+ Collect the classes to handle Creole-input.
10
+
11
+ More about creole at http://www.wikicreole.org/
12
+ =end
13
+ module Creole
14
+
15
+ =begin rdoc
16
+ Creole is a standard wiki-syntax for wikitexts.
17
+ Definition see http://www.wikicreole.org
18
+
19
+ I liked this definition.
20
+ When you look at the website, you get a definition and
21
+ you get an explanation, why it is like this. - great!
22
+
23
+ This class gets a creole-text and translate it to elements of the docgenerator,
24
+ they can be used by Document or directly like Element#to_doc.
25
+
26
+ Example:
27
+ wiki = Creole.new()
28
+ wiki << <<txt
29
+ =Test document
30
+ This is a little test text with **bold** and //italic// text.
31
+ txt
32
+ wiki.to_latex()
33
+
34
+ Often I use it in combination with "Here"-Documents with __END__:
35
+
36
+ require 'docgenerator/creole'
37
+
38
+ doc = Docgenerator::Creole::Creole_document.new()
39
+ doc << DATA
40
+ doc.save('test.html')
41
+ __ END__
42
+ Content
43
+ --
44
+ Im Code beispiel steht __<space>END__
45
+ Würde dort __END__ stehen, hätte rdoc einen Fehler.
46
+ ++
47
+ =end
48
+ class Creole
49
+ class << Creole
50
+ #Define a default for targetdir-option in Creole.new.
51
+ attr_accessor :targetdir
52
+ end
53
+
54
+ =begin rdoc
55
+ Define the Creole-object.
56
+
57
+ Options:
58
+ * :log => Logger to catch information.
59
+
60
+ Alternativ you have access to the default logger via Creole#log
61
+ * :targetdir => directory, where you want to save the result.
62
+
63
+ This directory is important for checks for internal links.
64
+
65
+ You may change the default '.' with
66
+ Docgenerator::Creole::Creole.targetdir = 'mysubdir'
67
+ * :ignore: A regex describing parts to be ignored during text parsing. e.g. /^#~.*$/ for usage with scite.
68
+ * :encoding: The encoding used for creole.
69
+ Default is UTF-8
70
+ =end
71
+ def initialize( options = {} )
72
+ @options = {
73
+ :logname => 'Creole', #Just a name for easier debugging/logging
74
+ :targetdir => self.class.targetdir || '.',
75
+ :wrap_at => 75, #Default line wrapping
76
+ #~ :parsetest => false #Make an immediate test for parsing #fixme
77
+ #~ :placeholders =
78
+ #Definition how to handle the sectioning.
79
+ :title_levels => {
80
+ 0 => nil,
81
+ 1 => :h1,
82
+ 2 => :h2,
83
+ 3 => :h3,
84
+ 4 => :h4,
85
+ 5 => :h5,
86
+ 6 => :h6,
87
+ },
88
+ :ignore => nil, #Define a "local" comment, e.g /^#~.*$/
89
+ :encoding => __ENCODING__,
90
+ }.update(options)
91
+ @placeholders = Placeholders::Collection.dup
92
+ @inclusions = Inclusions::Collection.dup
93
+ @plugins = Plugins::Collection.dup
94
+
95
+ #Store the given source text
96
+ @source = []
97
+ #Store the pre-parsed content
98
+ @normsource = []
99
+ @toc = [] #Collection of all heading lines
100
+ @footnotegroups = {} #Collection of footnote groups
101
+
102
+ @targetdir = @options[:targetdir] if @options[:targetdir]
103
+
104
+ @log = @options[:log]
105
+ @log = Log4r::Logger.new(@options[:logname], Log4r::INFO) unless @log
106
+ @log.outputters = Log4r::StdoutOutputter.new('log_stdout') if @log.outputters.empty?
107
+
108
+ @creation_caller = caller.first
109
+ self << @options[:content] if @options[:content]
110
+ end
111
+
112
+ #Hash with placeholders.
113
+ #
114
+ #Placeholders are used with <<<'name'.
115
+ #This accessor is needed to add more placeholders for specific wikis.
116
+ #Default: Creole::Placeholders
117
+ attr_reader :placeholders
118
+ attr_reader :options
119
+
120
+ #Hash with inclusions.
121
+ #This accessor is needed to add more inclusions for specific wikis.
122
+ #Default: Creole::Inclusions
123
+ attr_reader :inclusions
124
+ #Hash with all plugins
125
+ #This accessor is needed to add more plugins for specific wikis.
126
+ #Default: Creole::Plugins
127
+ attr_reader :plugins
128
+ #All footnotegroups of the wiki
129
+ attr_reader :footnotegroups
130
+
131
+ #Error Class
132
+ class InputError < ArgumentError; end
133
+ =begin rdoc
134
+ Get some content.
135
+ Strings are taken like strings.
136
+ Array items are handled like lines.
137
+
138
+ It is possible to add the content of a file. Just add the open file handle.
139
+ In case of ruby scripts, the part after __END__ is used as input.
140
+
141
+ Content added with << starts always with a new paragraph, but it may contain
142
+ multiple paragraphs, lists...
143
+ =end
144
+ def << ( input )
145
+ case input
146
+ when String
147
+ source = input
148
+ when Array
149
+ #Items of the array are handled like single lines.
150
+ #The chomp avoid double \n (the array items may already have their own newlines).
151
+ source = input.map{|item| item.chomp}.join("\n") #ohne doppelte xx
152
+ when File
153
+ #If file is a ruby script, then use the wiki-code after __END__
154
+ #
155
+ #Often scripts contains there own text content after __END__.
156
+ #So we have to catch, if << is called with DATA
157
+ if /\.rb\Z/ =~ input.path and $0 != input.path
158
+ @log.info("Take content of #{input.inspect} after __END__") if @log.info?
159
+ begin
160
+ line = input.readline while line != "__END__\n"
161
+ rescue EOFError
162
+ @log.error("No __END__ found in #{input.inspect}") if @log.error?
163
+ end
164
+ end
165
+ #Read the code
166
+ source = input.readlines.join
167
+ else
168
+ raise InputError, "Don't know, how to handle #{input.class} in Creole#<<"
169
+ end
170
+ begin
171
+ source_enc = source.encode(@options[:encoding])
172
+ rescue Encoding::UndefinedConversionError => err
173
+ @log.warn("Encoding conversion error <#{err}>") if @log.warn?
174
+ source_enc = source.encode(@options[:encoding], :undef => :replace)
175
+ end
176
+ @source << source_enc
177
+ #Parse the given source.
178
+ #This is done immediate, so you have a chance to localize the line, where an error occurs.
179
+ #(Some errors are reported later during to_doc).
180
+ #fixme: option to parse immediate at << or later
181
+ #immediate_parse => true...
182
+ @normsource.push( *parse( source_enc ) )
183
+ end #<< ( input )
184
+ =begin rdoc
185
+ Parse the given creole code and build a "normalized source"
186
+ =end
187
+ def parse( source = @source )
188
+
189
+ normsource = []
190
+ statusflag = nil #Variable to store the actual status. nil = nothing special.
191
+ normsource << Creole_line.new(:dummy)
192
+
193
+ if ! source.respond_to?(:each_with_index)
194
+ #Ruby 1.9 removed each from String
195
+ if source.respond_to? :each_line
196
+ source = source.each_line
197
+ else
198
+ @log.fatal("Unable to parse #{source.class}: #{source.inspect}" ) if @log.fatal?
199
+ return normsource
200
+ end
201
+ end
202
+
203
+
204
+ #
205
+ #Check code line by line
206
+ #
207
+ source.each_with_index{|line, lineno|
208
+ #Check special status
209
+ case statusflag
210
+ when nil #Nothing to do
211
+ when :pre
212
+ line =~ /\}\}\}/ ? statusflag = nil : normsource.last.content << line
213
+ next
214
+ when :placeholder
215
+ #~ if line =~ /^>>>$/ #did not catch each system specific line end.
216
+ if line =~ /^>>>(\r\n?|\n)/ #finish placeholder (started with <<<)
217
+ statusflag = nil
218
+ normsource.last.content.close
219
+ else
220
+ normsource.last.content << line
221
+ end
222
+ next
223
+ else
224
+ @log.fatal("Undefined status #{statusflag}: #{line.inspect}" ) if @log.fatal?
225
+ end #statusflag
226
+
227
+ #
228
+ #Parse the wiki text on line level (main structure)
229
+ case line
230
+ #Skip this line, if it correspond to a special comment-pattern.
231
+ #Can be used for application-specific comments.
232
+ #
233
+ #Example:
234
+ # :ignore => /^(#~.*)$/
235
+ #This comment is created by scite using Ctrl-Q (for ruby-scripts).
236
+ when @options[:ignore]
237
+ @log.info("Found comment in line %2i: %s" % [
238
+ lineno, #line.inspect
239
+ [$~.pre_match, '<<', $1, '>>', $~.post_match].join.strip,
240
+ ]) if @log.info?
241
+ #Headings
242
+ #http://www.wikicreole.org/wiki/Headings
243
+ #
244
+ #Modification of standard: Labels are possible.
245
+ when /^(=+)(?:\[(.*)\])?(.+?)(=*)\s*$/
246
+ normsource << Creole_line.new(:title, $3, :level => $1.size, :label => $2 )
247
+ @toc << normsource.last
248
+ #Creole doesn't need a trailing ===, but when it is ther, it should be correct
249
+ if $1.size != $4.size and $4.size > 0
250
+ @log.warn("Heading problem #{$1} doesn't match <#{$4}>: #{line.inspect}" ) if @log.warn?
251
+ end
252
+ if $~.post_match !~ /\s*/
253
+ @log.warn("Ignore text #{$~.post_match.inspect} after title <#{line.inspect}>" ) if @log.warn?
254
+ end
255
+ #And close the actual level
256
+ #See unit test test_creole_mix_titles_list
257
+ normsource << Creole_line.new(:dummy )
258
+ #Empty line
259
+ when /^\s*$/
260
+ normsource << Creole_line.new(:dummy )
261
+ when /^----\s*$/
262
+ normsource << Creole_line.new(:hr )
263
+ #List entry
264
+ when /^\s*((\*|\#)+)/
265
+ normsource << Creole_line.new(:list, $~.post_match, :listtype => $1 )
266
+ #Tabular
267
+ when /^\|/
268
+ #fixme tab soll in par...
269
+ #~ normsource.last << Creole_line.new(:placeholder,
270
+ #~ ... unless anpassen...
271
+ normsource << Creole_line.new(:placeholder,
272
+ @placeholders['creole_tabular'].new(self),
273
+ :start => lineno
274
+ ) unless normsource.last.content.is_a?(Creole_tab)
275
+ normsource.last.content << line
276
+ #http://www.wikicreole.org/wiki/PreformattedAndNowiki
277
+ when /^\{\{\{\s*$/ #Kind of verbatim
278
+ normsource << Creole_line.new(:pre, [], :start => lineno )
279
+ statusflag = :pre
280
+ #~ when /^<<<(.*)\|?(.*?)/ #fixme options for placeholders?
281
+ when /^<<<(.*)/ #placeholder (collect everything until >>>
282
+ ph, par = $1.split(/\|/,2)
283
+ placeholder = @placeholders[ph].new(self, par)
284
+ if placeholder.instance_of?(Placeholders::Dummy)
285
+ @log.warn("Unknown placeholder #{ph.inspect} used in line #{lineno}" ) if @log.warn?
286
+ end
287
+ normsource << Creole_line.new(:placeholder, placeholder, :start => lineno )
288
+ statusflag = :placeholder
289
+ else
290
+ case normsource.last.type
291
+ when :par, :list
292
+ normsource.last.content << line
293
+ else
294
+ normsource << Creole_line.new(:par, line )
295
+ end
296
+ end
297
+ }
298
+ case statusflag
299
+ when nil #ok
300
+ when :pre
301
+ @log.warn("Unclosed verbatim found (start at #{normsource.last.add_info[:start]})" ) if @log.warn?
302
+ #~ raise ''
303
+ when :placeholder
304
+ #One possible source: Regexp $ is system specific.
305
+ @log.warn("Unclosed placeholder #{normsource.last.type} (start at #{normsource.last.add_info[:start]})" ) if @log.warn?
306
+ else
307
+ @log.warn("Wiki ends with status #{statusflag.inspect}" ) if @log.warn?
308
+ end
309
+ return normsource
310
+ end #parse
311
+ #Logger to collect messages.
312
+ attr_reader :log
313
+ #Returns the source as it was received
314
+ attr_reader :source
315
+ #The pre-parsed content.
316
+ attr_reader :normsource
317
+ #Directory for the target.
318
+ #Can be used to check internal links (images, local files...)
319
+ attr_reader :targetdir
320
+
321
+ =begin rdoc
322
+ Return a table of contents as a list.
323
+ =end
324
+ def toc( i_options = {})
325
+ options = {
326
+ :listtype => :ul,
327
+ :level => 4,
328
+ #~ :startlevel => 1,
329
+ }.update(i_options)
330
+
331
+ if ! options[:level].is_a?(Integer)
332
+ @log.error("Toc: toclevel is no number but '#{options[:level].inspect}'. Set 4") if @log.error?
333
+ options[:level] = 4
334
+ end
335
+
336
+
337
+ toclist = []
338
+ toclabel = [0] #help variable to construct labels
339
+ listtype = '*'
340
+ case options[:listtype]
341
+ when '*', :ul, :itemize
342
+ listtype = '*'
343
+ when '#', :ol, :enumerate
344
+ listtype = '#'
345
+ else
346
+ @log.error("Toc: Unknown listtype #{options[:listtype]}") if @log.error?
347
+ end
348
+
349
+ @toc.each{|tocentry|
350
+ level = tocentry.add_info[:level]
351
+ #Skip deeper levels then wanted.
352
+ next if level > options[:level]
353
+
354
+ #Build the label
355
+ if level > toclabel.size
356
+ toclabel << 0
357
+ elsif level < toclabel.size
358
+ toclabel.pop
359
+ end
360
+ #Happens if there is a jump gap on section levels (subsubsection inside section without subsection)
361
+ if ! toclabel[level-1]
362
+ @log.warn("Missing toclevel for <#{tocentry.content}> #{tocentry.add_info.inspect}")
363
+ #add dummy level
364
+ toclabel << 0
365
+ toclist << "#{listtype * ( level - 1)} ---"
366
+ end
367
+ toclabel[level-1] = toclabel[level-1] + 1
368
+
369
+ #Check if there was already a label.
370
+ #If yes: use it. If not: build a new one with the help of toclabel.
371
+ if tocentry.add_info[:label]
372
+ label = tocentry.add_info[:label]
373
+ else
374
+ label = tocentry.add_info[:label] = toclabel.join('-')
375
+ end
376
+
377
+ #Feature to create the toc if higher levels are missing /start at h3...)
378
+ #~ if level < options[:startlevel]
379
+ #~ @log.warn( "toc: TOC starts not at #{options[:startlevel]}, but level #{level}" ) if @log.warn?
380
+ #~ next
381
+ #~ end
382
+
383
+ toclist << "#{listtype * level}[[##{label}|#{tocentry.content}]]"
384
+ }
385
+ toclist = <<toc
386
+ <<<html
387
+ <div class = 'toc'>
388
+ >>>
389
+ #{toclist.join("\n")}
390
+ <<<html
391
+ </div>
392
+ >>>
393
+ toc
394
+
395
+ return Creole.new( :content => toclist, :log => @log )
396
+ end #toc
397
+ =begin rdoc
398
+ Wrapping mechanism for texts.
399
+
400
+ Don't do anything, if line_width is 0.
401
+
402
+ See also http://stackoverflow.com/questions/7548968/format-output-to-40-characters-long-per-line/7549032#7549032
403
+ and http://forum.ruby-portal.de/viewtopic.php?t=3844&p=24578
404
+ =end
405
+ def word_wrap(text, line_width = @options[:wrap_at] )
406
+ return text if line_width <= 0
407
+ text.gsub(/\n/, ' ').gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
408
+ end
409
+ =begin rdoc
410
+ Prepare document.
411
+ =end
412
+ def to_doc( target, options = {} )
413
+ options[:log] = @log unless options[:log]
414
+ #
415
+ #Delete again all footnotegroups.
416
+ #Else you get footnotes doubled.
417
+ @footnotegroups = {} #Collection of footnote groups
418
+ return normsource2elements( @normsource, options ).to_doc(target, options)
419
+ end #to_doc
420
+ =begin rdoc
421
+ Take the given normsource and build a list of elements.
422
+ Used by
423
+ - Creole#to_doc
424
+ - Creole_ruby#to_doc
425
+ =end
426
+ def normsource2elements( normsource, options )
427
+ doc = []
428
+ elements = {} #little collector for lists
429
+ normsource.each{|line|
430
+ case line.type
431
+ when :dummy
432
+ elements = {}
433
+ #Here we define the sectioning.
434
+ #line.add_info[:level] contains the number of = from the wiki.
435
+ #
436
+ when :title
437
+ options[:log].error("%s: Undefined title level %i" % [__method__,line.add_info[:level]]) if options[:log].error? and ! @options[:title_levels][line.add_info[:level]]
438
+ doc << element(@options[:title_levels][line.add_info[:level]], {
439
+ :id => line.add_info[:label]
440
+ #inline or not?
441
+ #Required for filenames with _
442
+ #But: http://www.wikicreole.org/wiki/Headings says no.
443
+ #Make decision depending on a setting?
444
+ }, line.content ).cr
445
+ #~ }, inline(line.content, options ) ).cr
446
+ when :list
447
+ key = line.add_info[:listtype]
448
+ if ! elements[key]
449
+ case key[-1,1]
450
+ when '*'; elements[key] = element(:ul).cR
451
+ when '#'; elements[key] = element(:ol).cR
452
+ else
453
+ options[:log].error("Undefined listtype #{key[-1,1]}") if options[:log].error?
454
+ end
455
+ if key.size == 1 #new list, add to document
456
+ doc << elements[key]
457
+ elsif parent_list = elements[key[0,key.size-1]] #new sublist, add to "parent"
458
+ parent_list << element(:li).cr unless parent_list.content.last.is_a?(:li)
459
+ parent_list.content.last << elements[key]
460
+ else #sublist without parent.
461
+ options[:log].error("List #{key} with missing superlist") if options[:log].error?
462
+ doc << element(:comment,{},'Sublist without superlist - move on top level').cr #add pending list on top level.
463
+ doc << elements[key] #add pending list on top level.
464
+ end
465
+ end
466
+ elements.each{|ekey, list|
467
+ case ekey
468
+ when key
469
+ list << element(:li,{}, inline(line.content, options) ).cr
470
+ else
471
+ elements.delete(ekey) if ekey.size >= key.size
472
+ end
473
+ }
474
+ when :pre
475
+ doc << element(:verbatim, {}, line.content ).cR
476
+ when :hr
477
+ doc << element(:hr).cr
478
+ when :placeholder
479
+ doc << line.content
480
+ when :par
481
+ doc << element(:par, {}, inline(line.content, options)).cR
482
+ else
483
+ options[:log].error("Wrong line type #{ line.type.inspect }") if options[:log].error?
484
+ end
485
+ }
486
+
487
+ return doc
488
+ end #to_doc_internal
489
+ =begin rdoc
490
+ Parse the inline text.
491
+
492
+ Options is a Hash and may contain:
493
+ * :log (default: @log)
494
+ =end
495
+ def inline( text, options )
496
+
497
+ raise ArgumentError, "Creole#inline: Options no Hash" unless options.is_a?(Hash)
498
+ options[:log] = @log unless options[:log]
499
+ options[:plugins] = @plugins unless options[:plugins]
500
+ options[:inclusions] = @inclusions unless options[:inclusions]
501
+
502
+ res = [] #result
503
+ stack = [] #
504
+
505
+ #~ http_regex =
506
+ #fixme: Only once to reduce runtime
507
+ splitregex = Regexp.new(
508
+ '(' + [
509
+ '\[\[.+?\]\]', # [[...links]]
510
+ 'https?:\/\/.+?(\s|\Z)', #including the next space!!
511
+ '\*\*', #bold
512
+ '\/\/', #emph
513
+ '\\\\\\\\', #newline
514
+ '\{\{\{.*?\}\}\}', #inline verbatim
515
+ '\{\{.*?\}\}', #images/inclusion
516
+ '<<.*?>>', #Plugins
517
+ #Catch characters with special meaning in regexp, e.g. $
518
+ CHARACTERS.keys.map{|key| key.sub(/([\$])/, '\\\\\1')}.join('|')
519
+ ].join('|') + ')'
520
+ )
521
+ #Splitt along 'active' elements.
522
+ #~ @options[:wrap_at]
523
+ #~ text.gsub(/\n/, ' ').split(splitregex).each{|el|
524
+ text.split(splitregex).each{|el|
525
+ case el
526
+ when '**' #bold
527
+ if stack.last.is_a?(:textbf)
528
+ stack.pop #leave bold area
529
+ else
530
+ stack << newel = element(:textbf) #enter bold area
531
+ if stack.size > 1
532
+ stack[-2] << newel
533
+ else
534
+ res << newel
535
+ end
536
+ end
537
+ when '//' #italic
538
+ if stack.last.is_a?(:emph)
539
+ stack.pop #leave italic area
540
+ else
541
+ stack << newel = element(:emph) #enter italic area
542
+ if stack.size > 1
543
+ stack[-2] << newel
544
+ else
545
+ res << newel
546
+ end
547
+ end
548
+ when '\\\\' #newline
549
+ ( stack.last ? stack.last : res ) << element(:newline).cr
550
+ #Something like [[http:...]]
551
+ when %r{^\[\[(.+?)(?:\|(.*?))?\]\]} #Link
552
+ link = $1
553
+ linktext = $2 ? $2 : $1
554
+ case link
555
+ when /^(https?|ftp):\/\/.+?/
556
+ link = link
557
+ #local file via file://...
558
+ when /^(file):\/\/(.+)/
559
+ link = link
560
+ check_link_existence( $2, options[:log] )
561
+ when /^\./, /\S:[\\\/]/ #lokal file
562
+ link = link
563
+ check_link_existence( link, options[:log] )
564
+ when /^#/ #internal link
565
+ link = link
566
+ #fixme tex?
567
+ else #internal link
568
+ #This is normally the wiki-links.
569
+ #But this is no wiki, it's a documentgenerator with wiki syntax.
570
+ options[:log].warn("Unclear link <#{el}> #{self.inspect}") if options[:log].warn?
571
+ link = link
572
+ end
573
+ if link == linktext #Avoid replacement of // inside linktext
574
+ href = element(:a, {:href=>link}, linktext )
575
+ else
576
+ href = element(:a, {:href=>link}, inline(linktext, options) )
577
+ end
578
+ if stack.last
579
+ stack.last << href
580
+ else
581
+ res << href
582
+ end
583
+ #All links should be catched before
584
+ when %r{\[\[(.*)\]\]}
585
+ options[:log].error("Lost link <#{el}>") if options[:log].error?
586
+ #fixme: there are obsolete 2 additional spaces in the result.
587
+ when /^http/ #implicit link
588
+ #~ href = element(:a, {:href=>el.strip}, el.strip ) #This makes problems with TeX (unmasked _,%...)
589
+ href = element(:url, {}, el.strip )
590
+ el =~ /(\s|\Z)$/ #get the end-space/newline if available
591
+ endspace = ( $1.empty? ? nil : $1 )
592
+ if stack.last
593
+ stack.last << href
594
+ #~ stack.last << last_char #add again the
595
+ else
596
+ res << href
597
+ #~ res << last_char #add again the end-space/newline
598
+ end
599
+ #No-wiki inline: {{{text}}}
600
+ when /\{\{\{(.*)\}\}\}/ #verbatim
601
+ if stack.last
602
+ stack.last << element(:verb,{},$1)
603
+ else
604
+ res << element(:verb,{},$1)
605
+ end
606
+ #Inclusion
607
+ #creole implements a general inclusion.
608
+ #Main usage are pictures/images ({{picname|alt}}),
609
+ #but it can be more...
610
+ #
611
+ #Available inclusions are defined in Creole::Inclusions resp. Creole#inclusions,
612
+ when /\{\{(.+?)(?:\|(.*))?\}\}/ #Inclusion (e.g. images)
613
+ if stack.last
614
+ stack.last << inclusion_or_plugin($1, $2, options[:inclusions])
615
+ else
616
+ res << inclusion_or_plugin($1, $2, options[:inclusions])
617
+ end
618
+ #Plugin
619
+ #Used like Inclusions.
620
+ #
621
+ #available plugins are defined in Creole::Plugins resp. Creole#plugins
622
+ when /<<(.+?)(?:\|(.*))?>>/
623
+ if stack.last
624
+ stack.last << inclusion_or_plugin($1, $2, options[:plugins])
625
+ else
626
+ res << inclusion_or_plugin($1, $2, options[:plugins])
627
+ end
628
+ #No special wiki command. The text is "normal" text.
629
+ else #text to add
630
+ #Replace characters.
631
+ if CHARACTERS[el]
632
+ insertion = CHARACTERS[el]
633
+ startspace = endspace = nil
634
+ else
635
+ startspace = ( el[0,1] =~ /\s/ )
636
+ endspace = ( el[-1,1] =~ /\s/ )
637
+ insertion = word_wrap( el ) #wrap content
638
+ end
639
+ if stack.last
640
+ stack.last << insertion
641
+ #This adds some obsolete spaces in case of newlines at the end.
642
+ #But if I compare with ' ', then words will be concatenated without separator.
643
+ stack.last << ' ' if endspace
644
+ else #Just some text without any format
645
+ res << ' ' if startspace #Keep space
646
+ res << insertion
647
+ res << ' ' if endspace #Keep space
648
+ end
649
+ end
650
+ }
651
+ res
652
+ end #inline
653
+ =begin rdoc
654
+ Inclusion or Plugin.
655
+ Creole implements a general inclusion.
656
+ Main usage are pictures/images ({{picname|alt}}),
657
+ but it can be more...
658
+
659
+ The last paramter contains a hash with the supported inclusions/plugins.
660
+ =end
661
+ def inclusion_or_plugin( link, p_additions, inclusions )
662
+
663
+ addition, additions = nil
664
+ #Splitt additions at |
665
+ if p_additions
666
+ addition, *additions = p_additions.split(/\|/)
667
+ end
668
+
669
+ inclusion = inclusions[link]
670
+ #check inclusion.ancestors?
671
+ #~ if inclusion.superclass != Creole_inclusion_and_plugin
672
+ if inclusion.is_a?(Creole_inclusion_and_plugin)
673
+ @log.error( "Wrong inclusion/plugin definition for #{link} (#{inclusion.inspect}, expected #{inclusions.default.superclass})") if @log.error?
674
+ return nil
675
+ end
676
+ ip = inclusion.new( link, addition, additions, self )
677
+ return ip
678
+ end #inclusion
679
+ =begin rdoc
680
+ Check for links and pictures if the target exist.
681
+
682
+ Absolute DOS-Pathes are detected (C:\...).
683
+ Relative pathes are searched from @options[:targetdir] (default '.').
684
+
685
+ Different locations are not supported (e.g. to implement LaTeXs \graphicspath)
686
+ =end
687
+ def check_link_existence( filename, log )
688
+ case filename
689
+ when /^.:/#absolute DOS-path (e.g. c:\...)
690
+ path = filename.dup
691
+ else #relative path
692
+ path = "#{@options[:targetdir]}/#{filename}".sub(/^\//, '')
693
+ end
694
+ path.sub!(/(\.html?)#.*$/, '\1') #Don't check anchor inside html
695
+ if ! File.exist?(path)
696
+ log.warn("Reference not found: <#{filename}> (looking at <#{path}>)") if log.warn?
697
+ #~ log.debug("Reference not found: <#{path}>") if log.debug?
698
+ fpath = File.expand_path("#{Dir.pwd}/#{path}")
699
+ log.debug("Reference not found: <#{fpath}>") if log.debug?
700
+ end
701
+ end #check_link_existence
702
+
703
+ def inspect()
704
+ "<#{self.class} (created #{@creation_caller})>"
705
+ end
706
+ end #Creole
707
+ end #module Creole
708
+ end #module Docgenerator