docgenerator 2.1.1 → 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.
- checksums.yaml +4 -4
- data/lib/docgenerator.rb +18 -18
- data/lib/docgenerator/characters.rb +1 -0
- data/lib/docgenerator/css.rb +5 -0
- data/lib/docgenerator/document.rb +7 -2
- data/lib/docgenerator/element.rb +2 -2
- data/lib/docgenerator/elements.rb +69 -2
- data/lib/docgenerator/index.rb +1 -1
- data/lib/docgenerator/packages/listings.rb +94 -94
- data/lib/docgenerator/packages/multicol.rb +1 -1
- data/lib/docgenerator/packages/pdfpages.rb +2 -1
- data/lib/docgenerator/packages/rubycode4doc.rb +173 -172
- data/lib/docgenerator/packages/struktex.rb +395 -379
- data/lib/docgenerator/packages/todonotes.rb +2 -2
- data/lib/docgenerator/packages/url.rb +4 -0
- data/lib/docgenerator/sections.rb +24 -2
- data/lib/docgenerator/tabular.rb +59 -14
- data/lib/docgenerator/templates/docgenerator_template.rb +1 -0
- data/lib/docgenerator/templates/docgenerator_template.yaml +30 -1
- data/lib/docgenerator/version.rb +13 -1
- data/meta_test_and_doc/build__meta.rb +3 -10
- data/meta_test_and_doc/build_doc.rb +4 -2
- data/meta_test_and_doc/build_test.rb +21 -17
- data/meta_test_and_doc/manpages/images.rb +152 -0
- data/unittest/expected/test_document_toc_article.latex +6 -6
- data/unittest/expected_struktex/test_struktex_krug.creole +5 -5
- data/unittest/expected_struktex/test_struktex_krug.wiki +5 -5
- data/unittest/expected_struktex/test_struktex_statement.creole +4 -4
- data/unittest/expected_struktex/test_struktex_statement.wiki +4 -4
- data/unittest/expected_templates/test_report_utf8.tex +34 -0
- data/unittest/expected_templates/test_standalone.tex +2 -1
- data/unittest/unittest_docgenerator.rb +37 -30
- data/unittest/unittest_docgenerator_characters.rb +113 -60
- data/unittest/unittest_docgenerator_runtex.rb +16 -12
- data/unittest/unittest_packages_multicol.rb +4 -9
- data/unittest/unittest_packages_struktex.rb +66 -90
- data/unittest/unittest_rubycode4doc.rb +38 -241
- data/unittest/unittest_templates.rb +4 -8
- metadata +23 -560
- data/examples/creole_example.rb +0 -81
- data/examples/creole_example_footnote.rb +0 -67
- data/examples/creole_example_new_plugin.rb +0 -51
- data/examples/creole_example_placeholder.rb +0 -77
- data/examples/creole_example_rail.rb +0 -154
- data/examples/creole_example_rubycode.rb +0 -144
- data/examples/creole_example_struktex.rb +0 -169
- data/examples/creole_example_tabular.rb +0 -97
- data/examples/wiki2docgenerator_example.rb +0 -299
- data/lib/creole/creole2doc.rb +0 -954
- data/lib/creole/creole_characters.rb +0 -120
- data/lib/creole/creole_inclusion_and_plugins.rb +0 -96
- data/lib/creole/creole_inclusions.rb +0 -154
- data/lib/creole/creole_placeholder.rb +0 -171
- data/lib/creole/creole_plugins.rb +0 -230
- data/lib/creole/creole_tabular.rb +0 -401
- data/lib/creole/plugins/rail.rb +0 -181
- data/lib/creole/plugins/rubycode4creole.rb +0 -136
- data/lib/creole/plugins/struktex.rb +0 -59
- data/lib/creole/plugins/todonotes.rb +0 -77
- data/lib/wiki2doc/plugins/rubycode4wiki.rb +0 -53
- data/lib/wiki2doc/plugins/struktex.rb +0 -12
- data/lib/wiki2doc/wiki2docgenerator.rb +0 -1276
- data/lib/wiki2doc/wikimedia_document.rb +0 -24
- data/meta_test_and_doc/manpages/packages.rb +0 -13
- data/unittest/Red_Flower.jpg +0 -0
- data/unittest/creole1.0test.txt +0 -128
- data/unittest/creole_testtext.creole +0 -11
- data/unittest/expected_creole/test_creole.html +0 -3
- data/unittest/expected_creole/test_creole_characters_all.creole +0 -28
- data/unittest/expected_creole/test_creole_characters_all.html +0 -18
- data/unittest/expected_creole/test_creole_characters_all.latex +0 -36
- data/unittest/expected_creole/test_creole_characters_special.html +0 -10
- data/unittest/expected_creole/test_creole_characters_special.latex +0 -18
- data/unittest/expected_creole/test_creole_comment.context +0 -11
- data/unittest/expected_creole/test_creole_comment.creole +0 -12
- data/unittest/expected_creole/test_creole_comment.html +0 -9
- data/unittest/expected_creole/test_creole_comment.latex +0 -11
- data/unittest/expected_creole/test_creole_countdown.html +0 -3
- data/unittest/expected_creole/test_creole_countdown.latex +0 -4
- data/unittest/expected_creole/test_creole_creole1.0test.html +0 -182
- data/unittest/expected_creole/test_creole_creole1.0test.latex +0 -253
- data/unittest/expected_creole/test_creole_creole1.0test.text +0 -160
- data/unittest/expected_creole/test_creole_footnotes.html +0 -9
- data/unittest/expected_creole/test_creole_footnotes.latex +0 -14
- data/unittest/expected_creole/test_creole_footnotes_groupid.html +0 -15
- data/unittest/expected_creole/test_creole_footnotes_label.html +0 -9
- data/unittest/expected_creole/test_creole_headings.html +0 -17
- data/unittest/expected_creole/test_creole_headings.latex +0 -19
- data/unittest/expected_creole/test_creole_headings.text +0 -48
- data/unittest/expected_creole/test_creole_headings.wiki +0 -37
- data/unittest/expected_creole/test_creole_hr.html +0 -7
- data/unittest/expected_creole/test_creole_hr.latex +0 -9
- data/unittest/expected_creole/test_creole_hr.text +0 -4
- data/unittest/expected_creole/test_creole_ignore.html +0 -3
- data/unittest/expected_creole/test_creole_ignore.latex +0 -4
- data/unittest/expected_creole/test_creole_ignore.text +0 -2
- data/unittest/expected_creole/test_creole_inline.html +0 -3
- data/unittest/expected_creole/test_creole_inline.latex +0 -4
- data/unittest/expected_creole/test_creole_inline.text +0 -2
- data/unittest/expected_creole/test_creole_inline_apostroph.html +0 -6
- data/unittest/expected_creole/test_creole_inline_apostroph.latex +0 -8
- data/unittest/expected_creole/test_creole_inline_apostroph.text +0 -4
- data/unittest/expected_creole/test_creole_inline_ruby.html +0 -12
- data/unittest/expected_creole/test_creole_inline_ruby.latex +0 -20
- data/unittest/expected_creole/test_creole_inline_ruby_raw.html +0 -6
- data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +0 -8
- data/unittest/expected_creole/test_creole_input.normsource +0 -25
- data/unittest/expected_creole/test_creole_input.normsource_1.8 +0 -23
- data/unittest/expected_creole/test_creole_input_file_simple.html +0 -15
- data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +0 -15
- data/unittest/expected_creole/test_creole_label.html +0 -12
- data/unittest/expected_creole/test_creole_label.latex +0 -15
- data/unittest/expected_creole/test_creole_line_break.html +0 -6
- data/unittest/expected_creole/test_creole_line_break.latex +0 -8
- data/unittest/expected_creole/test_creole_links_explicit_internal.html +0 -6
- data/unittest/expected_creole/test_creole_links_explicit_internal.text +0 -4
- data/unittest/expected_creole/test_creole_links_explicit_with_em.html +0 -3
- data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +0 -4
- data/unittest/expected_creole/test_creole_links_explicit_with_em.text +0 -2
- data/unittest/expected_creole/test_creole_links_external.html +0 -6
- data/unittest/expected_creole/test_creole_links_external.latex +0 -8
- data/unittest/expected_creole/test_creole_links_external.text +0 -4
- data/unittest/expected_creole/test_creole_links_external_implicit.html +0 -9
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +0 -12
- data/unittest/expected_creole/test_creole_links_external_implicit.text +0 -6
- data/unittest/expected_creole/test_creole_links_file.html +0 -6
- data/unittest/expected_creole/test_creole_links_file.latex +0 -8
- data/unittest/expected_creole/test_creole_links_file.text +0 -4
- data/unittest/expected_creole/test_creole_links_implicit_end.creole +0 -4
- data/unittest/expected_creole/test_creole_links_implicit_end.html +0 -3
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +0 -4
- data/unittest/expected_creole/test_creole_list_ol.html +0 -12
- data/unittest/expected_creole/test_creole_list_ol.latex +0 -22
- data/unittest/expected_creole/test_creole_list_ol_after_ul.html +0 -12
- data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +0 -20
- data/unittest/expected_creole/test_creole_list_ol_after_ul.text +0 -6
- data/unittest/expected_creole/test_creole_list_ol_ul.html +0 -15
- data/unittest/expected_creole/test_creole_list_ol_ul.latex +0 -26
- data/unittest/expected_creole/test_creole_list_ul.html +0 -22
- data/unittest/expected_creole/test_creole_list_ul.latex +0 -40
- data/unittest/expected_creole/test_creole_list_ul.normsource +0 -89
- data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +0 -83
- data/unittest/expected_creole/test_creole_list_ul_too_much.html +0 -24
- data/unittest/expected_creole/test_creole_list_ul_too_much.latex +0 -44
- data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +0 -6
- data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +0 -12
- data/unittest/expected_creole/test_creole_mix_titles_list.html +0 -10
- data/unittest/expected_creole/test_creole_mix_titles_list.latex +0 -18
- data/unittest/expected_creole/test_creole_mix_titles_list.text +0 -12
- data/unittest/expected_creole/test_creole_newline.html +0 -9
- data/unittest/expected_creole/test_creole_newline.latex +0 -11
- data/unittest/expected_creole/test_creole_newline.text +0 -7
- data/unittest/expected_creole/test_creole_paragraphs.html +0 -6
- data/unittest/expected_creole/test_creole_paragraphs.latex +0 -8
- data/unittest/expected_creole/test_creole_paragraphs.normsource +0 -29
- data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +0 -27
- data/unittest/expected_creole/test_creole_paragraphs.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs.wiki +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap.html +0 -5
- data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +0 -6
- data/unittest/expected_creole/test_creole_paragraphs_wrap.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +0 -9
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +0 -11
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +0 -7
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +0 -7
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +0 -5
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +0 -6
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +0 -4
- data/unittest/expected_creole/test_creole_picture_link.html +0 -6
- data/unittest/expected_creole/test_creole_pictures.html +0 -10
- data/unittest/expected_creole/test_creole_pictures.latex +0 -13
- data/unittest/expected_creole/test_creole_pictures_css.html +0 -6
- data/unittest/expected_creole/test_creole_pictures_css.latex +0 -8
- data/unittest/expected_creole/test_creole_pictures_imgclass.html +0 -6
- data/unittest/expected_creole/test_creole_pictures_imgclass.latex +0 -8
- data/unittest/expected_creole/test_creole_pictures_longdesc.html +0 -3
- data/unittest/expected_creole/test_creole_pictures_width.html +0 -3
- data/unittest/expected_creole/test_creole_pictures_width.latex +0 -4
- data/unittest/expected_creole/test_creole_placeholders_html.html +0 -7
- data/unittest/expected_creole/test_creole_placeholders_html.latex +0 -8
- data/unittest/expected_creole/test_creole_placeholders_html.text +0 -4
- data/unittest/expected_creole/test_creole_placeholders_latex.html +0 -6
- data/unittest/expected_creole/test_creole_placeholders_latex.latex +0 -9
- data/unittest/expected_creole/test_creole_placeholders_latex.text +0 -4
- data/unittest/expected_creole/test_creole_short_html.html +0 -3
- data/unittest/expected_creole/test_creole_short_html.latex +0 -4
- data/unittest/expected_creole/test_creole_short_html.text +0 -2
- data/unittest/expected_creole/test_creole_shy.creole +0 -6
- data/unittest/expected_creole/test_creole_shy.html +0 -6
- data/unittest/expected_creole/test_creole_shy.latex +0 -8
- data/unittest/expected_creole/test_creole_shy.text +0 -4
- data/unittest/expected_creole/test_creole_tabular.creole +0 -22
- data/unittest/expected_creole/test_creole_tabular.html +0 -20
- data/unittest/expected_creole/test_creole_tabular.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_creole.creole +0 -19
- data/unittest/expected_creole/test_creole_tabular_creole.html +0 -18
- data/unittest/expected_creole/test_creole_tabular_creole.latex +0 -19
- data/unittest/expected_creole/test_creole_tabular_css.creole +0 -24
- data/unittest/expected_creole/test_creole_tabular_css.html +0 -20
- data/unittest/expected_creole/test_creole_tabular_css.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_multicols.creole +0 -16
- data/unittest/expected_creole/test_creole_tabular_multicols.html +0 -14
- data/unittest/expected_creole/test_creole_tabular_multicols.latex +0 -16
- data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +0 -21
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +0 -20
- data/unittest/expected_creole/test_creole_toc.html +0 -13
- data/unittest/expected_creole/test_creole_toc.latex +0 -22
- data/unittest/expected_creole/test_creole_toc.text +0 -4
- data/unittest/expected_creole/test_creole_toc_level.html +0 -7
- data/unittest/expected_creole/test_creole_toc_level.latex +0 -10
- data/unittest/expected_creole/test_creole_toc_level.text +0 -3
- data/unittest/expected_creole/test_creole_toc_level_text.html +0 -8
- data/unittest/expected_creole/test_creole_toc_level_text.latex +0 -9
- data/unittest/expected_creole/test_creole_toc_text.html +0 -5
- data/unittest/expected_creole/test_creole_toc_text.latex +0 -5
- data/unittest/expected_creole/test_creole_ul_multiple_line.html +0 -7
- data/unittest/expected_creole/test_creole_ul_multiple_line.latex +0 -14
- data/unittest/expected_creole/test_creole_ul_with_blank.html +0 -11
- data/unittest/expected_creole/test_creole_ul_with_blank.latex +0 -20
- data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.html +0 -11
- data/unittest/expected_creole/test_creole_ul_with_bold.latex +0 -18
- data/unittest/expected_creole/test_creole_ul_with_bold.text +0 -7
- data/unittest/expected_creole/test_creole_verbatim.html +0 -25
- data/unittest/expected_creole/test_creole_verbatim.latex +0 -33
- data/unittest/expected_creole/test_creole_verbatim.text +0 -17
- data/unittest/expected_creole/test_creole_verbatim_inline.html +0 -6
- data/unittest/expected_creole/test_creole_verbatim_inline.latex +0 -8
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +0 -6
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +0 -8
- data/unittest/expected_creole_rail/test_rail_creole_object.tex +0 -33
- data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +0 -40
- data/unittest/expected_rubycode4doc/creole_complete.html +0 -26
- data/unittest/expected_rubycode4doc/creole_complete.tex +0 -40
- data/unittest/expected_rubycode4doc/creole_in_tab.html +0 -4
- data/unittest/expected_rubycode4doc/creole_in_tab.tex +0 -6
- data/unittest/expected_rubycode4doc/creole_inline_ruby.html +0 -7
- data/unittest/expected_rubycode4doc/creole_output.html +0 -2
- data/unittest/expected_rubycode4doc/creole_output.tex +0 -4
- data/unittest/expected_rubycode4doc/creole_rubycode.html +0 -1
- data/unittest/expected_rubycode4doc/creole_rubycode.tex +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +0 -1
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +0 -5
- data/unittest/expected_rubycode4doc/wiki_1.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_2.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_3.html +0 -9
- data/unittest/expected_rubycode4doc/wiki_immediate_1.html +0 -5
- data/unittest/expected_rubycode4doc/wiki_immediate_2.html +0 -5
- data/unittest/expected_rubycode4doc/wiki_immediate_3.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_immediate_full.html +0 -21
- data/unittest/expected_wikimedia/test_wiki.html +0 -6
- data/unittest/expected_wikimedia/test_wiki.latex +0 -12
- data/unittest/expected_wikimedia/test_wiki.text +0 -14
- data/unittest/expected_wikimedia/test_wiki.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_description.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_description.latex +0 -11
- data/unittest/expected_wikimedia/test_wiki_description.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_description.wiki +0 -6
- data/unittest/expected_wikimedia/test_wiki_footnote.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_footnote.latex +0 -17
- data/unittest/expected_wikimedia/test_wiki_footnote.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_footnote.wiki +0 -10
- data/unittest/expected_wikimedia/test_wiki_footnote_2.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_footnote_groupid.html +0 -21
- data/unittest/expected_wikimedia/test_wiki_html_code.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_html_code.latex +0 -10
- data/unittest/expected_wikimedia/test_wiki_html_code.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_html_code.wiki +0 -6
- data/unittest/expected_wikimedia/test_wiki_inline.html +0 -6
- data/unittest/expected_wikimedia/test_wiki_inline.latex +0 -12
- data/unittest/expected_wikimedia/test_wiki_inline.text +0 -8
- data/unittest/expected_wikimedia/test_wiki_inline.wiki +0 -8
- data/unittest/expected_wikimedia/test_wiki_label.html +0 -6
- data/unittest/expected_wikimedia/test_wiki_link.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_link.latex +0 -17
- data/unittest/expected_wikimedia/test_wiki_link.wiki +0 -11
- data/unittest/expected_wikimedia/test_wiki_list_ol.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ol.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.html +0 -16
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.latex +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.text +0 -8
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.wiki +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ul.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ul.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ul.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ul.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.html +0 -39
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.latex +0 -51
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.text +0 -11
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.wiki +0 -15
- data/unittest/expected_wikimedia/test_wiki_picture.html +0 -55
- data/unittest/expected_wikimedia/test_wiki_picture.latex +0 -76
- data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +0 -5
- data/unittest/expected_wikimedia/test_wiki_tab1.html +0 -30
- data/unittest/expected_wikimedia/test_wiki_tab1.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_tab1.wiki +0 -29
- data/unittest/expected_wikimedia/test_wiki_textformatting.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_textformatting.latex +0 -16
- data/unittest/expected_wikimedia/test_wiki_textformatting.text +0 -11
- data/unittest/expected_wikimedia/test_wiki_textformatting.wiki +0 -9
- data/unittest/expected_wikimedia/test_wiki_toc.html +0 -9
- data/unittest/expected_wikimedia/test_wiki_toc.latex +0 -18
- data/unittest/expected_wikimedia/test_wiki_toc.text +0 -21
- data/unittest/expected_wikimedia/test_wiki_toc.wiki +0 -18
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.html +0 -18
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.latex +0 -19
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.wiki +0 -7
- data/unittest/unittest_creole.rb +0 -1361
- data/unittest/unittest_creole_placeholders.rb +0 -150
- data/unittest/unittest_creole_plugin_rail.rb +0 -147
- data/unittest/unittest_creole_tabular.rb +0 -207
- data/unittest/unittest_wikimedia.rb +0 -479
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
=begin rdoc
|
|
2
|
-
Creole plugins
|
|
3
|
-
|
|
4
|
-
This classes define plugins for creole.
|
|
5
|
-
|
|
6
|
-
Plugins are used later with <<xx>>
|
|
7
|
-
more at http://www.wikicreole.org/wiki/Plugin
|
|
8
|
-
|
|
9
|
-
You can extend Wikis with additional Plugin:
|
|
10
|
-
|
|
11
|
-
wiki = Creole.new()
|
|
12
|
-
wiki.plugin['xxx'] = Creole_plugin_xxx
|
|
13
|
-
=end
|
|
14
|
-
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
module Docgenerator
|
|
18
|
-
module Creole
|
|
19
|
-
|
|
20
|
-
=begin rdoc
|
|
21
|
-
Creole plugins
|
|
22
|
-
|
|
23
|
-
This classes define plugins for creole.
|
|
24
|
-
|
|
25
|
-
Plugins are used later with <<xx>>
|
|
26
|
-
more at http://www.wikicreole.org/wiki/Plugin
|
|
27
|
-
|
|
28
|
-
You can extend Wikis with additional Plugin:
|
|
29
|
-
|
|
30
|
-
wiki = Creole.new()
|
|
31
|
-
wiki.plugin['xxx'] = Creole_plugin_xxx
|
|
32
|
-
=end
|
|
33
|
-
module Plugins
|
|
34
|
-
|
|
35
|
-
=begin rdoc
|
|
36
|
-
Default Plugin for Creole.
|
|
37
|
-
<<xx>>
|
|
38
|
-
=end
|
|
39
|
-
class Creole_default_plugin < Creole_inclusion_and_plugin
|
|
40
|
-
def initialize( pluginname, description, options, wiki )
|
|
41
|
-
super
|
|
42
|
-
@wiki.log.warn("Use Default plugin instead requested #{pluginname}- nothing special done.") if @wiki.log.warn?
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
#Collection of Plugins
|
|
47
|
-
Collection = Hash.new(Creole_default_plugin)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
=begin rdoc
|
|
51
|
-
Collection of footnotes.
|
|
52
|
-
|
|
53
|
-
Makes sense for HTML-output.
|
|
54
|
-
|
|
55
|
-
For LaTeX the support of bigfoot/manyfoot... may be an idea.
|
|
56
|
-
=end
|
|
57
|
-
class Creole_footnote_group < Creole_inclusion_and_plugin
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
Collection['footnotes'] = self
|
|
61
|
-
|
|
62
|
-
def initialize( inclusionname, description, options, wiki )
|
|
63
|
-
super
|
|
64
|
-
description = Footnotegroup::DEFAULTGROUPID unless description
|
|
65
|
-
@footnotesgroup = wiki.footnotegroups[description]
|
|
66
|
-
wiki.log.error("Footnotesgroup #{description.inspect} not found") if ! @footnotesgroup and wiki.log.error?
|
|
67
|
-
end
|
|
68
|
-
=begin rdoc
|
|
69
|
-
Call Docgenerator::Footnotegroup#to_doc
|
|
70
|
-
=end
|
|
71
|
-
def to_doc(target, options = {})
|
|
72
|
-
#remove options for Docgenerator::Footnotegroup
|
|
73
|
-
l_options = options.dup
|
|
74
|
-
l_options.delete(:plugins)
|
|
75
|
-
l_options.delete(:inclusions)
|
|
76
|
-
@footnotesgroup.to_doc(target, l_options)
|
|
77
|
-
end
|
|
78
|
-
end #Creole_inclusion_footnote_group
|
|
79
|
-
|
|
80
|
-
=begin rdoc
|
|
81
|
-
One footnote
|
|
82
|
-
|
|
83
|
-
Usage:
|
|
84
|
-
<<footnote|text>>
|
|
85
|
-
<<footnote|text|label=l1>>
|
|
86
|
-
<<footnote|text|groupid=g1>>
|
|
87
|
-
|
|
88
|
-
Bug: If you create more documents, you get a common footnote counting.
|
|
89
|
-
|
|
90
|
-
Solution:
|
|
91
|
-
* LaTeX: no problem, LaTeX has it's own output mechanism.
|
|
92
|
-
* HTML: Use grouping.
|
|
93
|
-
=end
|
|
94
|
-
class Creole_footnote < Creole_inclusion_and_plugin
|
|
95
|
-
Collection['footnote'] = self
|
|
96
|
-
|
|
97
|
-
def initialize( inclusionname, description, options, wiki )
|
|
98
|
-
super
|
|
99
|
-
|
|
100
|
-
@groupid = Footnotegroup::DEFAULTGROUPID
|
|
101
|
-
label = nil
|
|
102
|
-
|
|
103
|
-
options.each{|option|
|
|
104
|
-
case option
|
|
105
|
-
when /label\s*=\s*(.*)/
|
|
106
|
-
label = $1
|
|
107
|
-
when /groupid\s*=\s*(.*)/
|
|
108
|
-
@groupid = $1
|
|
109
|
-
else
|
|
110
|
-
@wiki.log.warn("Footnote with unknown option #{option.inspect} not found") if @wiki.log.warn?
|
|
111
|
-
end
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if ! wiki.footnotegroups[@groupid]
|
|
115
|
-
wiki.footnotegroups[@groupid] = Footnotegroup.new(@groupid)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
group = wiki.footnotegroups[@groupid]
|
|
119
|
-
|
|
120
|
-
@footnote = element(:footnote,{
|
|
121
|
-
:group => group,
|
|
122
|
-
:label => label,
|
|
123
|
-
}, description )
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
end
|
|
127
|
-
def to_doc(target, options ={})
|
|
128
|
-
@footnote.to_doc(target, options)
|
|
129
|
-
end
|
|
130
|
-
end #Creole_inclusion_footnote
|
|
131
|
-
|
|
132
|
-
=begin rdoc
|
|
133
|
-
Some short latex
|
|
134
|
-
|
|
135
|
-
Usage:
|
|
136
|
-
<<latex|code>>
|
|
137
|
-
|
|
138
|
-
Note:
|
|
139
|
-
There is also a placeholder for larger latex:
|
|
140
|
-
<<<latex
|
|
141
|
-
content
|
|
142
|
-
>>>
|
|
143
|
-
=end
|
|
144
|
-
class Creole_short_latex < Creole_inclusion_and_plugin
|
|
145
|
-
#We don't use it as inclusion. Closing } from latex may be confusing as in:
|
|
146
|
-
# {{latex|\texttt{kursuiv}}}
|
|
147
|
-
set_plugin_key 'latex'
|
|
148
|
-
|
|
149
|
-
def initialize( inclusionname, description, options, wiki )
|
|
150
|
-
super
|
|
151
|
-
options.each{|option|
|
|
152
|
-
#~ case option
|
|
153
|
-
#~ else
|
|
154
|
-
@wiki.log.warn("latex with unknown option #{option.inspect} not found") if @wiki.log.warn?
|
|
155
|
-
#~ end
|
|
156
|
-
}
|
|
157
|
-
@source = description
|
|
158
|
-
|
|
159
|
-
end
|
|
160
|
-
#Return content only for latex
|
|
161
|
-
def to_doc( target, options = {})
|
|
162
|
-
target == :latex ? @source.to_doc( target, options ) : ''
|
|
163
|
-
end
|
|
164
|
-
end #Creole_short_latex
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
=begin rdoc
|
|
168
|
-
Eval the given ruby-code and put it as "raw text".
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
This is defined as a plugin.
|
|
172
|
-
=end
|
|
173
|
-
class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
|
|
174
|
-
set_plugin_key 'ruby_raw'
|
|
175
|
-
|
|
176
|
-
def initialize( inclusionname, description, options, wiki )
|
|
177
|
-
#The ruby-code may contain | - so we have to ad it again
|
|
178
|
-
description << "|#{options.join('|')}" unless options.empty?
|
|
179
|
-
options = nil
|
|
180
|
-
super
|
|
181
|
-
@code = description
|
|
182
|
-
begin
|
|
183
|
-
@result = eval(@code)
|
|
184
|
-
rescue => bang
|
|
185
|
-
wiki.log.error("Plugin ruby_raw: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
|
|
186
|
-
end
|
|
187
|
-
end #initialize
|
|
188
|
-
def to_doc(target, options ={})
|
|
189
|
-
@result.to_s
|
|
190
|
-
end
|
|
191
|
-
def inspect()
|
|
192
|
-
"#<Creole_plugin_ruby_raw:#{@code}>"
|
|
193
|
-
end
|
|
194
|
-
end #Creole_plugin_ruby
|
|
195
|
-
|
|
196
|
-
=begin rdoc
|
|
197
|
-
Eval the given ruby-code and add it as a interpreted code.
|
|
198
|
-
|
|
199
|
-
This is defined as a plugin.
|
|
200
|
-
|
|
201
|
-
Ideas for further development: eval later, at doc generation.
|
|
202
|
-
=end
|
|
203
|
-
class Creole_plugin_ruby < Creole_inclusion_and_plugin
|
|
204
|
-
set_plugin_key 'ruby'
|
|
205
|
-
|
|
206
|
-
def initialize( inclusionname, description, options, wiki )
|
|
207
|
-
#The ruby-code may contain | - so we have to ad it again
|
|
208
|
-
description << "|#{options.join('|')}" unless options.empty?
|
|
209
|
-
options = nil
|
|
210
|
-
super
|
|
211
|
-
|
|
212
|
-
@code = description
|
|
213
|
-
begin
|
|
214
|
-
@result = eval(@code)
|
|
215
|
-
rescue => bang
|
|
216
|
-
wiki.log.error("Plugin ruby: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
|
|
217
|
-
end
|
|
218
|
-
end #initialize
|
|
219
|
-
def to_doc(target, options = {})
|
|
220
|
-
@wiki.normsource2elements(
|
|
221
|
-
@wiki.parse(@result.to_s ), options
|
|
222
|
-
).to_doc(target, options )
|
|
223
|
-
end
|
|
224
|
-
def inspect()
|
|
225
|
-
"#<Creole_plugin_ruby:#{@code}>"
|
|
226
|
-
end
|
|
227
|
-
end #Creole_plugin_ruby
|
|
228
|
-
end #module Plugins
|
|
229
|
-
end #module Creole
|
|
230
|
-
end #module Docgenerator
|
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
#encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
if $0 == __FILE__ #for immediate tests
|
|
4
|
-
$:.unshift('..')
|
|
5
|
-
require 'creole/creole2doc.rb'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
module Docgenerator
|
|
9
|
-
module Creole
|
|
10
|
-
=begin
|
|
11
|
-
"Original" creole tab.
|
|
12
|
-
|
|
13
|
-
Defined as a collector, so we can collect the content first and
|
|
14
|
-
build the tabular later.
|
|
15
|
-
|
|
16
|
-
Details see http://www.wikicreole.org/wiki/Tables
|
|
17
|
-
|
|
18
|
-
Usage:
|
|
19
|
-
Tables are done like this:
|
|
20
|
-
|=header col1|=header col2|
|
|
21
|
-
|col1|col2|
|
|
22
|
-
|you |can |
|
|
23
|
-
|also |align\\ it. |
|
|
24
|
-
|
|
25
|
-
=end
|
|
26
|
-
class Creole_tab < Placeholder
|
|
27
|
-
set_placeholder_key 'creole_tabular' #original creole-tab definition
|
|
28
|
-
|
|
29
|
-
#Extend the class by a little structure
|
|
30
|
-
Cell = Struct.new('Cell', :content, :type )
|
|
31
|
-
|
|
32
|
-
#Finish the tabular.
|
|
33
|
-
#Each cell is added left justified.
|
|
34
|
-
def close(options)
|
|
35
|
-
#~ @log.error("Standard creole tabulars not supported yet" )
|
|
36
|
-
|
|
37
|
-
step = 0 #start
|
|
38
|
-
head = []
|
|
39
|
-
content = []
|
|
40
|
-
@source.each{|line|
|
|
41
|
-
content << []
|
|
42
|
-
#delete trailing empty cells
|
|
43
|
-
line.chomp.gsub(/\|\s*$/,'').split(/\|/)[1..-1].each{|cell|
|
|
44
|
-
case cell
|
|
45
|
-
when /^=/
|
|
46
|
-
content.last << Cell.new(@wiki.inline($~.post_match.strip, options),:th)
|
|
47
|
-
else
|
|
48
|
-
content.last << Cell.new(@wiki.inline(cell.strip, options), :td)
|
|
49
|
-
end
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
max_size = 0
|
|
54
|
-
content.each{|line|
|
|
55
|
-
max_size = [max_size, line.size].max
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@tab = element(:tabular, {#:style => tab_css,
|
|
59
|
-
:columns => max_size,
|
|
60
|
-
:columndescription => 'l' * max_size,
|
|
61
|
-
}).cR
|
|
62
|
-
content.each{|line|
|
|
63
|
-
@tab << row = element(:row).cr
|
|
64
|
-
line.each{|cell|
|
|
65
|
-
row << element(cell.type,{}, cell.content).cr
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
end
|
|
69
|
-
def to_doc( target, options = {})
|
|
70
|
-
self.close(options) unless @tab
|
|
71
|
-
@tab.to_doc( target, options )
|
|
72
|
-
end
|
|
73
|
-
end #Creole_tab
|
|
74
|
-
|
|
75
|
-
=begin rdoc
|
|
76
|
-
Create tabulars analog to Wikimedia.
|
|
77
|
-
|
|
78
|
-
Usage:
|
|
79
|
-
before
|
|
80
|
-
<<<tabular
|
|
81
|
-
|!columns=3
|
|
82
|
-
|!columndescription=ccc
|
|
83
|
-
|!border=1px
|
|
84
|
-
|!css= color: red
|
|
85
|
-
|=1
|
|
86
|
-
|=2
|
|
87
|
-
|=3
|
|
88
|
-
|-
|
|
89
|
-
|eins
|
|
90
|
-
|zwei
|
|
91
|
-
|drei
|
|
92
|
-
|-
|
|
93
|
-
|one
|
|
94
|
-
|two
|
|
95
|
-
|three
|
|
96
|
-
>>>
|
|
97
|
-
after
|
|
98
|
-
|
|
99
|
-
You can add additional settings to cells:
|
|
100
|
-
<<<tabular
|
|
101
|
-
|!columns=3
|
|
102
|
-
|eins||css=color: red
|
|
103
|
-
|css = zwei
|
|
104
|
-
|||class=empty
|
|
105
|
-
>>>
|
|
106
|
-
=end
|
|
107
|
-
class Creole_tabular < Placeholder
|
|
108
|
-
set_placeholder_key 'tabular'
|
|
109
|
-
|
|
110
|
-
#Define a container for cells
|
|
111
|
-
class Row
|
|
112
|
-
#Flag for hline
|
|
113
|
-
attr_accessor :hline
|
|
114
|
-
#Flag for toprule
|
|
115
|
-
attr_accessor :toprule
|
|
116
|
-
#Flag for midrule
|
|
117
|
-
attr_accessor :midrule
|
|
118
|
-
#Add a cell to a row
|
|
119
|
-
def << (cell)
|
|
120
|
-
@cells = [] unless @cells
|
|
121
|
-
@cells << cell
|
|
122
|
-
end
|
|
123
|
-
def each
|
|
124
|
-
@cells.each{|cell| yield cell }
|
|
125
|
-
end
|
|
126
|
-
#Return number of cells
|
|
127
|
-
def size; @cells.size; end
|
|
128
|
-
end
|
|
129
|
-
#Extend the class by a little structure
|
|
130
|
-
class Cell
|
|
131
|
-
=begin rdoc
|
|
132
|
-
The content of a cell is separated from settings by two ||
|
|
133
|
-
|
|
134
|
-
If you have an empty cell with additional setting, you must write three |
|
|
135
|
-
|
|
136
|
-
Supported additional settings:
|
|
137
|
-
* css= define css-style options
|
|
138
|
-
* class= define HTML-class
|
|
139
|
-
* title= define a title (results in popup during mouse-over)
|
|
140
|
-
=end
|
|
141
|
-
def initialize( content, type, wiki, local_options )
|
|
142
|
-
@content, options = content.split(/\|\|/,2)
|
|
143
|
-
@content = '' unless @content #just in case of empty content
|
|
144
|
-
@options = {}
|
|
145
|
-
options.split(/\|/).each{|option|
|
|
146
|
-
case option
|
|
147
|
-
when /class\s*=\s*/
|
|
148
|
-
@options[:class] = $~.post_match
|
|
149
|
-
when /css\s*=\s*/
|
|
150
|
-
@options[:style] = $~.post_match
|
|
151
|
-
when /title\s*=\s*/
|
|
152
|
-
@options[:title] = $~.post_match
|
|
153
|
-
when /pos\s*=\s*/ #only for multicol
|
|
154
|
-
@options[:pos] = $~.post_match
|
|
155
|
-
when /columns\s*=\s*/
|
|
156
|
-
wiki.log.debug("Creole_tabular::Cell #{type} converted to multicol")
|
|
157
|
-
type = :multicolumn #loose th/td-information -- fixme
|
|
158
|
-
@options[:colspan] = $~.post_match.to_i
|
|
159
|
-
when '' #ignore them
|
|
160
|
-
else
|
|
161
|
-
wiki.log.warn("Creole_tabular::Cell: Undefined option #{option.inspect}")
|
|
162
|
-
end
|
|
163
|
-
} if options
|
|
164
|
-
@type = type #:td or :th
|
|
165
|
-
@wiki = wiki
|
|
166
|
-
@local_options = local_options
|
|
167
|
-
end
|
|
168
|
-
#Return the content as a element.
|
|
169
|
-
def cell_element()
|
|
170
|
-
element(@type,@options, @wiki.inline(@content, @local_options)).cr
|
|
171
|
-
end
|
|
172
|
-
end #class Cell
|
|
173
|
-
|
|
174
|
-
#Build the tabular.
|
|
175
|
-
def close()
|
|
176
|
-
#~ fixme:
|
|
177
|
-
#~ *CSS-format
|
|
178
|
-
#~ *generelle def
|
|
179
|
-
|
|
180
|
-
step = 0 #start
|
|
181
|
-
head = []
|
|
182
|
-
content = [Row.new]
|
|
183
|
-
|
|
184
|
-
options = { :log => @log }
|
|
185
|
-
local_options = {
|
|
186
|
-
:log => @log,
|
|
187
|
-
:inclusions => @wiki.inclusions,
|
|
188
|
-
:plugins => @wiki.plugins.dup
|
|
189
|
-
}
|
|
190
|
-
#No footnotes inside tabulars
|
|
191
|
-
local_options[:plugins].delete('footnote')
|
|
192
|
-
local_options[:plugins].delete('footnotes')
|
|
193
|
-
|
|
194
|
-
tab_css = CSS.new( :log => @log )
|
|
195
|
-
@source.each{|cell|
|
|
196
|
-
case cell
|
|
197
|
-
when /^\|!/ #generell cell definition
|
|
198
|
-
case $~.post_match().strip
|
|
199
|
-
when /columns\s*=\s*(.*)/
|
|
200
|
-
options[:columns] = $1.to_i
|
|
201
|
-
when /border\s*=\s*(.*)/
|
|
202
|
-
options[:border] = $1
|
|
203
|
-
when /columndescription\s*=\s*(.*)/
|
|
204
|
-
options[:columndescription] = $1
|
|
205
|
-
when /css\s*=\s*(.*)\s*:\s*(.*)/
|
|
206
|
-
tab_css[$1] = $2
|
|
207
|
-
when '' #
|
|
208
|
-
else
|
|
209
|
-
@log.warn("#{self}: Unknown tabular option #{$1}") if @log.warn?
|
|
210
|
-
end
|
|
211
|
-
when /^\|-(.*)/ #new line
|
|
212
|
-
if $1 #there are options for the row
|
|
213
|
-
$1.split(/\|/).each{|option|
|
|
214
|
-
case option
|
|
215
|
-
when /hline/; content.last.hline = true
|
|
216
|
-
when /toprule/; content.last.toprule = true
|
|
217
|
-
when /midrule/; content.last.midrule = true
|
|
218
|
-
when /\A\s*\Z/, nil
|
|
219
|
-
else
|
|
220
|
-
@log.warn("#{self}: Unknown row option #{option.inspect}") if @log.warn?
|
|
221
|
-
end
|
|
222
|
-
}
|
|
223
|
-
end
|
|
224
|
-
content << Row.new #Start new row
|
|
225
|
-
when /^\|=/ #header cell
|
|
226
|
-
#~ content.last << Cell.new(@wiki.inline($~.post_match.strip, local_options), :th)
|
|
227
|
-
content.last << Cell.new($~.post_match.strip, :th, @wiki, local_options)
|
|
228
|
-
when /^\|/ #content of a cell
|
|
229
|
-
#~ content.last << Cell.new(@wiki.inline($~.post_match.strip, local_options), :td)
|
|
230
|
-
content.last << Cell.new($~.post_match.strip, :td, @wiki, local_options)
|
|
231
|
-
else #error!
|
|
232
|
-
raise "cell/log-warning in #{cell.inspect}"
|
|
233
|
-
end
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
max_size = 0
|
|
237
|
-
content.each{|line|
|
|
238
|
-
max_size = [max_size, line.size].max
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if options[:columns] and options[:columns] < max_size
|
|
242
|
-
@log.warn("Creole-tabular: Defined size #{options[:columns]} < no of columns (#{max_size})") if @log.warn?
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
if self.is_a?(Docgenerator::Creole::Creole_longtable)
|
|
246
|
-
@tab = element(:longtable, { :style => tab_css,
|
|
247
|
-
}.merge(options) ).cR
|
|
248
|
-
#~ elsif self.is_a?(Docgenerator::Creole::Creole_supertabular) #Not supported
|
|
249
|
-
#~ @tab = element(:supertabular, { :style => tab_css,
|
|
250
|
-
#~ }.merge(options) ).cR
|
|
251
|
-
elsif self.is_a?(Docgenerator::Creole::Creole_tabular)
|
|
252
|
-
@tab = element(:tabular, { :style => tab_css,
|
|
253
|
-
}.merge(options) ).cR
|
|
254
|
-
else
|
|
255
|
-
raise ArgumentError, "Unsupported tabular-class #{self.class}"
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
content.each{|line|
|
|
259
|
-
@tab << row = element(:row).cr
|
|
260
|
-
row.hline if line.hline
|
|
261
|
-
row.toprule if line.toprule
|
|
262
|
-
row.midrule if line.midrule
|
|
263
|
-
line.each{|cell|
|
|
264
|
-
row << cell.cell_element.cr
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
end
|
|
268
|
-
def to_doc( target, options = {})
|
|
269
|
-
@tab.to_doc( target, options )
|
|
270
|
-
end
|
|
271
|
-
end #Creole_tabular
|
|
272
|
-
|
|
273
|
-
class Creole_longtable < Creole_tabular
|
|
274
|
-
set_placeholder_key 'longtable'
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
#~ class Creole_supertabular < Creole_tabular ##Not supported
|
|
278
|
-
#~ set_placeholder_key 'supertabular'
|
|
279
|
-
#~ end
|
|
280
|
-
=begin rdoc
|
|
281
|
-
This class needs the CSV-package (the user is responsible to load it).
|
|
282
|
-
|
|
283
|
-
The LaTeX document needs the booktabs-package
|
|
284
|
-
|
|
285
|
-
Options:
|
|
286
|
-
* headers=false: Firest line contains headers (default: true)
|
|
287
|
-
* format or columndescription: LaTeX header description
|
|
288
|
-
|
|
289
|
-
Fixmes:
|
|
290
|
-
* More parameters:
|
|
291
|
-
** toprule, hline,
|
|
292
|
-
** Other table (supertabular...)
|
|
293
|
-
* Bug: CSV without header returns Array of array
|
|
294
|
-
|
|
295
|
-
=end
|
|
296
|
-
class Creole_tabular_csv < Placeholder
|
|
297
|
-
set_placeholder_key 'tabular_csv'
|
|
298
|
-
def to_doc( target, options = {})
|
|
299
|
-
if ! defined? CSV
|
|
300
|
-
@log.fatal("tabular_csv needs CSV-package")
|
|
301
|
-
raise "tabular_csv needs CSV-package"
|
|
302
|
-
end
|
|
303
|
-
@log.fatal("tabular_csv needs parameters (format, col_sep)") unless @parameters.respond_to? :split
|
|
304
|
-
columndescription = nil
|
|
305
|
-
headers = true #first CSV-line contains
|
|
306
|
-
colsep = ';'
|
|
307
|
-
@parameters.split(/[|;]/).each{|parameter|
|
|
308
|
-
case parameter
|
|
309
|
-
when /headers=false/; headers = false
|
|
310
|
-
when /(format|columndescription)=(.*)/; columndescription = $2
|
|
311
|
-
#Some separator get a name. This is made especially, of the separator is also used as parameter separator.
|
|
312
|
-
when /(col_sep)=(.*)/; colsep = {'semicolon' => ';', 'tab' => "\t", 'bar' => '|'}[$2] || $2
|
|
313
|
-
@log.warn("tabular_csv with undefined separator (use semicolon, tab or bar)" % parameter) unless colsep
|
|
314
|
-
else
|
|
315
|
-
@log.warn("tabular_csv with unknown option %s" % parameter)
|
|
316
|
-
end
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
csv = CSV.parse(@source.join, :col_sep => colsep, :headers => true)
|
|
320
|
-
if ! columndescription
|
|
321
|
-
columndescription = 'c' * csv.headers.size
|
|
322
|
-
@log.warn("tabular_csv without LaTeX columndescription. Use %s" % columndescription)
|
|
323
|
-
end
|
|
324
|
-
tab = element(:tabular, { :columns => csv.headers.size, :columndescription => columndescription }).cR
|
|
325
|
-
tab << row = element(:row).cr.toprule
|
|
326
|
-
csv.headers.each{|title|row << element(:th,{}, title) }
|
|
327
|
-
csv.each{|line|
|
|
328
|
-
tab << row = element(:row).cr
|
|
329
|
-
line.each{|cell|
|
|
330
|
-
row << element(:td,{}, cell.last)
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
tab.to_doc( target, options )
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
end #module Creole
|
|
338
|
-
|
|
339
|
-
end #module Docgenerator
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if $0 == __FILE__
|
|
343
|
-
|
|
344
|
-
creole = Docgenerator::Creole::Creole.new(
|
|
345
|
-
:name => 'tabular_creole',
|
|
346
|
-
:content => <<'creole'
|
|
347
|
-
<<<tabular
|
|
348
|
-
|!columns=3
|
|
349
|
-
|!columndescription=ccc
|
|
350
|
-
|=a
|
|
351
|
-
|=b
|
|
352
|
-
|=c
|
|
353
|
-
|-
|
|
354
|
-
|a
|
|
355
|
-
|b
|
|
356
|
-
|c
|
|
357
|
-
>>>
|
|
358
|
-
creole
|
|
359
|
-
)
|
|
360
|
-
require 'csv'
|
|
361
|
-
creole = Docgenerator::Creole::Creole.new(
|
|
362
|
-
:name => 'tabular_creole',
|
|
363
|
-
:content => <<'creole'
|
|
364
|
-
<<<tabular_csv|columndescription=rrr|col_sep=semicolon
|
|
365
|
-
1;2;3
|
|
366
|
-
yy;yy;yy;
|
|
367
|
-
xx;xx;xx;
|
|
368
|
-
>>>
|
|
369
|
-
creole
|
|
370
|
-
) #if false
|
|
371
|
-
|
|
372
|
-
puts creole.to_html #testcode
|
|
373
|
-
puts creole.to_latex #testcode
|
|
374
|
-
end
|
|
375
|
-
__END__
|
|
376
|
-
|
|
377
|
-
class Creole_tabular_cvs
|
|
378
|
-
include Placeholder
|
|
379
|
-
|
|
380
|
-
<<<tabular_csv|CSV-Options
|
|
381
|
-
yy;yy;yy;
|
|
382
|
-
yy;yy;yy;
|
|
383
|
-
yy;yy;yy;
|
|
384
|
-
<<<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
Die Syntax:
|
|
388
|
-
*{| beginnt eine Tabelle. Hier können zusätzliche Formatierungseigenschaften kommen.
|
|
389
|
-
**Zumindest columns==__ sollte gesetzt sein
|
|
390
|
-
*! beginnt eine neue Zelle einer Titelzeile
|
|
391
|
-
*| beginnt eine neue Zelle
|
|
392
|
-
*|format| z.B. rowspan...
|
|
393
|
-
*|format|| Zwei || beenden die Parameter der Zelle.
|
|
394
|
-
Dann sinnvoll, wenn im Text selbst ein | vorkommt
|
|
395
|
-
(z.B. ein Macro verwendet wird)
|
|
396
|
-
*|- trennt zwei Zeilen der Tabelle
|
|
397
|
-
**hline: Zusätzlicher Trennstrich über der Zeile
|
|
398
|
-
**toprule, midrule, bottomrule: Zusätzlicher Trennstrich über der Zeile (erfordert booktabs.sty)
|
|
399
|
-
*|} beendet eine Tabelle
|
|
400
|
-
|
|
401
|
-
|