maruku 0.6.0 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE.txt +20 -0
- data/bin/maruku +153 -152
- data/bin/marutex +2 -29
- data/data/entities.xml +261 -0
- data/docs/markdown_syntax.md +9 -21
- data/docs/math.md +14 -18
- data/lib/maruku.rb +65 -78
- data/lib/maruku/attributes.rb +109 -214
- data/lib/maruku/defaults.rb +45 -67
- data/lib/maruku/document.rb +44 -0
- data/lib/maruku/element.rb +138 -0
- data/lib/maruku/errors.rb +80 -0
- data/lib/maruku/ext/div.rb +105 -113
- data/lib/maruku/ext/fenced_code.rb +97 -0
- data/lib/maruku/ext/math.rb +22 -26
- data/lib/maruku/ext/math/elements.rb +20 -26
- data/lib/maruku/ext/math/mathml_engines/blahtex.rb +92 -104
- data/lib/maruku/ext/math/mathml_engines/itex2mml.rb +33 -26
- data/lib/maruku/ext/math/mathml_engines/none.rb +11 -19
- data/lib/maruku/ext/math/mathml_engines/ritex.rb +2 -4
- data/lib/maruku/ext/math/parsing.rb +121 -115
- data/lib/maruku/ext/math/to_html.rb +202 -187
- data/lib/maruku/ext/math/to_latex.rb +34 -21
- data/lib/maruku/helpers.rb +158 -257
- data/lib/maruku/html.rb +251 -0
- data/lib/maruku/input/charsource.rb +272 -319
- data/lib/maruku/input/extensions.rb +62 -63
- data/lib/maruku/input/html_helper.rb +233 -189
- data/lib/maruku/input/linesource.rb +90 -110
- data/lib/maruku/input/mdline.rb +131 -0
- data/lib/maruku/input/parse_block.rb +736 -613
- data/lib/maruku/input/parse_doc.rb +145 -217
- data/lib/maruku/input/parse_span.rb +740 -0
- data/lib/maruku/inspect_element.rb +60 -0
- data/lib/maruku/maruku.rb +14 -30
- data/lib/maruku/output/entity_table.rb +37 -0
- data/lib/maruku/output/s5/fancy.rb +462 -462
- data/lib/maruku/output/s5/to_s5.rb +115 -135
- data/lib/maruku/output/to_html.rb +907 -983
- data/lib/maruku/output/to_latex.rb +571 -563
- data/lib/maruku/output/to_markdown.rb +207 -162
- data/lib/maruku/output/to_s.rb +10 -52
- data/lib/maruku/string_utils.rb +129 -179
- data/lib/maruku/toc.rb +185 -196
- data/lib/maruku/version.rb +33 -38
- data/spec/block_docs/abbrev.md +776 -0
- data/{tests/unittest → spec/block_docs}/abbreviations.md +11 -20
- data/spec/block_docs/abbreviations2.md +27 -0
- data/{tests/unittest → spec/block_docs}/alt.md +2 -14
- data/{tests/unittest/pending → spec/block_docs}/amps.md +1 -13
- data/spec/block_docs/attribute_sanitize.md +22 -0
- data/{tests/unittest → spec/block_docs}/attributes/att2.md +0 -12
- data/{tests/unittest → spec/block_docs}/attributes/att3.md +2 -14
- data/{tests/unittest → spec/block_docs}/attributes/attributes.md +12 -16
- data/{tests/unittest → spec/block_docs}/attributes/circular.md +0 -12
- data/{tests/unittest → spec/block_docs}/attributes/default.md +1 -13
- data/spec/block_docs/atx_headers.md +22 -0
- data/spec/block_docs/auto_cdata.md +48 -0
- data/spec/block_docs/bad_cites.md +30 -0
- data/spec/block_docs/bad_divrefs.md +30 -0
- data/{tests/unittest → spec/block_docs}/blank.md +0 -12
- data/{tests/unittest → spec/block_docs}/blanks_in_code.md +16 -15
- data/spec/block_docs/block_quotes.md +66 -0
- data/{tests/unittest/loss.md → spec/block_docs/bug_def.md} +6 -18
- data/{tests/unittest → spec/block_docs}/bug_table.md +7 -19
- data/spec/block_docs/cites.md +37 -0
- data/{tests/unittest → spec/block_docs}/code.md +7 -14
- data/{tests/unittest → spec/block_docs}/code2.md +4 -14
- data/{tests/unittest → spec/block_docs}/code3.md +12 -16
- data/spec/block_docs/code4.md +79 -0
- data/{tests/unittest → spec/block_docs}/data_loss.md +2 -14
- data/spec/block_docs/div_without_newline.md +16 -0
- data/{tests/unittest → spec/block_docs}/divs/div1.md +0 -12
- data/{tests/unittest → spec/block_docs}/divs/div2.md +0 -12
- data/{tests/unittest → spec/block_docs}/divs/div3_nest.md +3 -15
- data/{tests/unittest → spec/block_docs}/easy.md +1 -13
- data/spec/block_docs/email.md +29 -0
- data/spec/block_docs/empty_cells.md +31 -0
- data/{tests/unittest → spec/block_docs}/encoding/iso-8859-1.md +1 -14
- data/{tests/unittest → spec/block_docs}/encoding/utf-8.md +0 -12
- data/{tests/unittest → spec/block_docs}/entities.md +33 -41
- data/{tests/unittest/notyet → spec/block_docs}/escape.md +2 -14
- data/{tests/unittest → spec/block_docs}/escaping.md +11 -22
- data/{tests/unittest → spec/block_docs}/extra_dl.md +2 -13
- data/{tests/unittest → spec/block_docs}/extra_header_id.md +14 -20
- data/{tests/unittest → spec/block_docs}/extra_table1.md +9 -21
- data/spec/block_docs/fenced_code_blocks.md +58 -0
- data/spec/block_docs/fenced_code_blocks_highlighted.md +17 -0
- data/{tests/unittest → spec/block_docs}/footnotes.md +12 -24
- data/spec/block_docs/footnotes2.md +82 -0
- data/spec/block_docs/hard.md +25 -0
- data/spec/block_docs/header_after_par.md +62 -0
- data/{tests/unittest → spec/block_docs}/headers.md +10 -18
- data/{tests/unittest → spec/block_docs}/hex_entities.md +7 -18
- data/{tests/unittest → spec/block_docs}/hrule.md +5 -12
- data/{tests/unittest → spec/block_docs}/html3.md +1 -13
- data/{tests/unittest → spec/block_docs}/html4.md +2 -14
- data/{tests/unittest → spec/block_docs}/html5.md +2 -14
- data/spec/block_docs/html_block_in_para.md +22 -0
- data/spec/block_docs/html_inline.md +25 -0
- data/spec/block_docs/html_trailing.md +31 -0
- data/spec/block_docs/ie.md +62 -0
- data/spec/block_docs/iframe.md +29 -0
- data/spec/block_docs/ignore_bad_header.md +9 -0
- data/{tests/unittest → spec/block_docs}/images.md +22 -28
- data/{tests/unittest → spec/block_docs}/images2.md +7 -17
- data/{tests/unittest → spec/block_docs}/inline_html.md +37 -67
- data/{tests/unittest → spec/block_docs}/inline_html2.md +1 -13
- data/spec/block_docs/inline_html_beginning.md +10 -0
- data/spec/block_docs/issue106.md +78 -0
- data/spec/block_docs/issue115.md +20 -0
- data/spec/block_docs/issue117.md +13 -0
- data/spec/block_docs/issue120.md +48 -0
- data/spec/block_docs/issue123.md +11 -0
- data/spec/block_docs/issue124.md +16 -0
- data/spec/block_docs/issue126.md +9 -0
- data/spec/block_docs/issue130.md +11 -0
- data/spec/block_docs/issue20.md +9 -0
- data/spec/block_docs/issue26.md +22 -0
- data/spec/block_docs/issue29.md +9 -0
- data/spec/block_docs/issue30.md +30 -0
- data/spec/block_docs/issue31.md +25 -0
- data/spec/block_docs/issue40.md +52 -0
- data/spec/block_docs/issue64.md +55 -0
- data/spec/block_docs/issue67.md +19 -0
- data/spec/block_docs/issue70.md +11 -0
- data/spec/block_docs/issue72.md +17 -0
- data/spec/block_docs/issue74.md +38 -0
- data/spec/block_docs/issue79.md +15 -0
- data/spec/block_docs/issue83.md +13 -0
- data/spec/block_docs/issue85.md +25 -0
- data/spec/block_docs/issue88.md +19 -0
- data/spec/block_docs/issue89.md +12 -0
- data/spec/block_docs/issue90.md +38 -0
- data/{tests/unittest/pending → spec/block_docs}/link.md +21 -18
- data/{tests/unittest → spec/block_docs}/links.md +33 -32
- data/spec/block_docs/links2.md +21 -0
- data/{tests/unittest → spec/block_docs}/list1.md +0 -12
- data/{tests/unittest → spec/block_docs}/list12.md +2 -14
- data/{tests/unittest → spec/block_docs}/list2.md +2 -14
- data/spec/block_docs/list_multipara.md +42 -0
- data/{tests/unittest → spec/block_docs}/lists.md +28 -29
- data/{tests/unittest → spec/block_docs}/lists10.md +2 -14
- data/spec/block_docs/lists11.md +23 -0
- data/spec/block_docs/lists12.md +43 -0
- data/spec/block_docs/lists13.md +55 -0
- data/spec/block_docs/lists14.md +61 -0
- data/spec/block_docs/lists15.md +36 -0
- data/spec/block_docs/lists6.md +88 -0
- data/spec/block_docs/lists7b.md +58 -0
- data/spec/block_docs/lists9.md +53 -0
- data/{tests/unittest → spec/block_docs}/lists_after_paragraph.md +19 -25
- data/spec/block_docs/lists_blank.md +35 -0
- data/{tests/unittest/list3.md → spec/block_docs/lists_blockquote_code.md} +2 -14
- data/{tests/unittest/list4.md → spec/block_docs/lists_need_blank_line.md} +44 -29
- data/spec/block_docs/lists_nested.md +44 -0
- data/spec/block_docs/lists_nested_blankline.md +34 -0
- data/spec/block_docs/lists_nested_deep.md +43 -0
- data/spec/block_docs/lists_ol.md +129 -0
- data/spec/block_docs/lists_ol2.md +147 -0
- data/spec/block_docs/lists_paraindent.md +42 -0
- data/spec/block_docs/lists_tab.md +54 -0
- data/spec/block_docs/loss.md +17 -0
- data/spec/block_docs/math-blahtex/equations.md +29 -0
- data/spec/block_docs/math-blahtex/inline.md +48 -0
- data/spec/block_docs/math-blahtex/math2.md +52 -0
- data/spec/block_docs/math-blahtex/table.md +25 -0
- data/spec/block_docs/math/embedded_invalid_svg.md +108 -0
- data/spec/block_docs/math/embedded_svg.md +136 -0
- data/spec/block_docs/math/equations.md +49 -0
- data/spec/block_docs/math/inline.md +46 -0
- data/spec/block_docs/math/math2.md +53 -0
- data/{tests/unittest → spec/block_docs}/math/notmath.md +0 -12
- data/spec/block_docs/math/raw_mathml.md +87 -0
- data/spec/block_docs/math/spaces_after_inline_math.md +17 -0
- data/spec/block_docs/math/table.md +25 -0
- data/{tests/unittest → spec/block_docs}/math/table2.md +11 -23
- data/{tests/unittest → spec/block_docs}/misc_sw.md +184 -121
- data/{tests/unittest → spec/block_docs}/olist.md +6 -18
- data/{tests/unittest → spec/block_docs}/one.md +0 -12
- data/{tests/unittest → spec/block_docs}/paragraph.md +0 -12
- data/{tests/unittest → spec/block_docs}/paragraph_rules/dont_merge_ref.md +4 -12
- data/{tests/unittest → spec/block_docs}/paragraph_rules/tab_is_blank.md +0 -12
- data/{tests/unittest → spec/block_docs}/paragraphs.md +1 -13
- data/{tests/unittest → spec/block_docs}/recover/recover_links.md +4 -16
- data/{tests/unittest/pending/ref.md → spec/block_docs/ref_with_period.md} +7 -16
- data/spec/block_docs/ref_with_title.md +22 -0
- data/{tests/unittest → spec/block_docs}/references/long_example.md +16 -23
- data/{tests/unittest → spec/block_docs}/references/spaces_and_numbers.md +0 -12
- data/{tests/unittest → spec/block_docs}/smartypants.md +24 -31
- data/{tests/unittest → spec/block_docs}/syntax_hl.md +13 -17
- data/{tests/unittest → spec/block_docs}/table_attributes.md +6 -20
- data/spec/block_docs/table_colspan.md +41 -0
- data/spec/block_docs/tables.md +47 -0
- data/spec/block_docs/tables2.md +74 -0
- data/{tests/unittest → spec/block_docs}/test.md +1 -13
- data/{tests/unittest/notyet → spec/block_docs}/ticks.md +1 -13
- data/spec/block_docs/toc.md +87 -0
- data/{tests/unittest/notyet → spec/block_docs}/triggering.md +14 -25
- data/{tests/unittest → spec/block_docs}/underscore_in_words.md +0 -12
- data/{tests/unittest → spec/block_docs}/wrapping.md +4 -16
- data/spec/block_docs/xml.md +33 -0
- data/spec/block_docs/xml3.md +24 -0
- data/spec/block_docs/xml_comments.md +32 -0
- data/{tests/unittest → spec/block_docs}/xml_instruction.md +9 -20
- data/spec/block_spec.rb +110 -0
- data/spec/cli_spec.rb +8 -0
- data/spec/span_spec.rb +263 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/to_html_utf8_spec.rb +13 -0
- metadata +218 -202
- data/Rakefile +0 -73
- data/bin/marudown +0 -29
- data/bin/marutest +0 -345
- data/docs/changelog.md +0 -334
- data/lib/maruku/errors_management.rb +0 -92
- data/lib/maruku/ext/math/latex_fix.rb +0 -12
- data/lib/maruku/input/parse_span_better.rb +0 -746
- data/lib/maruku/input/rubypants.rb +0 -225
- data/lib/maruku/input/type_detection.rb +0 -147
- data/lib/maruku/output/to_latex_entities.rb +0 -367
- data/lib/maruku/output/to_latex_strings.rb +0 -64
- data/lib/maruku/structures.rb +0 -167
- data/lib/maruku/structures_inspect.rb +0 -87
- data/lib/maruku/structures_iterators.rb +0 -61
- data/lib/maruku/tests/benchmark.rb +0 -82
- data/lib/maruku/tests/new_parser.rb +0 -373
- data/lib/maruku/tests/tests.rb +0 -136
- data/lib/maruku/usage/example1.rb +0 -33
- data/maruku_gem.rb +0 -33
- data/tests/bugs/code_in_links.md +0 -101
- data/tests/bugs/complex_escaping.md +0 -38
- data/tests/math/syntax.md +0 -46
- data/tests/math_usage/document.md +0 -13
- data/tests/others/abbreviations.md +0 -11
- data/tests/others/blank.md +0 -4
- data/tests/others/code.md +0 -5
- data/tests/others/code2.md +0 -8
- data/tests/others/code3.md +0 -16
- data/tests/others/email.md +0 -4
- data/tests/others/entities.md +0 -19
- data/tests/others/escaping.md +0 -16
- data/tests/others/extra_dl.md +0 -101
- data/tests/others/extra_header_id.md +0 -13
- data/tests/others/extra_table1.md +0 -40
- data/tests/others/footnotes.md +0 -17
- data/tests/others/headers.md +0 -10
- data/tests/others/hrule.md +0 -10
- data/tests/others/images.md +0 -20
- data/tests/others/inline_html.md +0 -42
- data/tests/others/links.md +0 -38
- data/tests/others/list1.md +0 -4
- data/tests/others/list2.md +0 -5
- data/tests/others/list3.md +0 -8
- data/tests/others/lists.md +0 -32
- data/tests/others/lists_after_paragraph.md +0 -44
- data/tests/others/lists_ol.md +0 -39
- data/tests/others/misc_sw.md +0 -105
- data/tests/others/one.md +0 -1
- data/tests/others/paragraphs.md +0 -13
- data/tests/others/sss06.md +0 -352
- data/tests/others/test.md +0 -4
- data/tests/s5/s5profiling.md +0 -48
- data/tests/unittest/bug_def.md +0 -28
- data/tests/unittest/email.md +0 -32
- data/tests/unittest/hang.md +0 -29
- data/tests/unittest/html2.md +0 -34
- data/tests/unittest/ie.md +0 -61
- data/tests/unittest/links2.md +0 -34
- data/tests/unittest/lists11.md +0 -28
- data/tests/unittest/lists6.md +0 -53
- data/tests/unittest/lists9.md +0 -76
- data/tests/unittest/lists_ol.md +0 -274
- data/tests/unittest/math/equations.md +0 -86
- data/tests/unittest/math/inline.md +0 -58
- data/tests/unittest/math/math2.md +0 -57
- data/tests/unittest/math/table.md +0 -37
- data/tests/unittest/notyet/header_after_par.md +0 -70
- data/tests/unittest/pending/empty_cells.md +0 -49
- data/tests/unittest/red_tests/abbrev.md +0 -1388
- data/tests/unittest/red_tests/lists7.md +0 -68
- data/tests/unittest/red_tests/lists7b.md +0 -128
- data/tests/unittest/red_tests/lists8.md +0 -76
- data/tests/unittest/red_tests/xml.md +0 -70
- data/tests/unittest/xml2.md +0 -31
- data/tests/unittest/xml3.md +0 -38
- data/tests/utf8-files/simple.md +0 -1
- data/unit_test_block.sh +0 -5
- data/unit_test_span.sh +0 -3
data/docs/markdown_syntax.md
CHANGED
@@ -1,17 +1,6 @@
|
|
1
|
-
css: style.css
|
2
|
-
|
3
1
|
Markdown: Syntax
|
4
2
|
================
|
5
3
|
|
6
|
-
<ul id="ProjectSubmenu">
|
7
|
-
<li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
|
8
|
-
<li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
|
9
|
-
<li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
|
10
|
-
<li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
|
11
|
-
<li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
|
12
|
-
</ul>
|
13
|
-
|
14
|
-
|
15
4
|
* [Overview](#overview)
|
16
5
|
* [Philosophy](#philosophy)
|
17
6
|
* [Inline HTML](#html)
|
@@ -256,7 +245,7 @@ wrap the text and put a `>` before every line:
|
|
256
245
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
257
246
|
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
258
247
|
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
259
|
-
>
|
248
|
+
>
|
260
249
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
261
250
|
> id sem consectetuer libero luctus adipiscing.
|
262
251
|
|
@@ -283,12 +272,12 @@ Blockquotes can contain other Markdown elements, including headers, lists,
|
|
283
272
|
and code blocks:
|
284
273
|
|
285
274
|
> ## This is a header.
|
286
|
-
>
|
275
|
+
>
|
287
276
|
> 1. This is the first list item.
|
288
277
|
> 2. This is the second list item.
|
289
|
-
>
|
278
|
+
>
|
290
279
|
> Here's some example code:
|
291
|
-
>
|
280
|
+
>
|
292
281
|
> return shell_exec("echo $input | $markdown_script");
|
293
282
|
|
294
283
|
Any decent text editor should make email-style quoting easy. For
|
@@ -569,7 +558,7 @@ Will produce:
|
|
569
558
|
If you're referring to a local resource on the same server, you can
|
570
559
|
use relative paths:
|
571
560
|
|
572
|
-
See my [About](/about/) page for details.
|
561
|
+
See my [About](/about/) page for details.
|
573
562
|
|
574
563
|
Reference-style links use a second set of square brackets, inside
|
575
564
|
which you place a label of your choosing to identify the link:
|
@@ -643,7 +632,7 @@ multiple words in the link text:
|
|
643
632
|
Visit [Daring Fireball][] for more information.
|
644
633
|
|
645
634
|
And then define the link:
|
646
|
-
|
635
|
+
|
647
636
|
[Daring Fireball]: http://daringfireball.net/
|
648
637
|
|
649
638
|
Link definitions can be placed anywhere in your Markdown document. I
|
@@ -767,13 +756,13 @@ one after the opening, one before the closing. This allows you to place
|
|
767
756
|
literal backtick characters at the beginning or end of a code span:
|
768
757
|
|
769
758
|
A single backtick in a code span: `` ` ``
|
770
|
-
|
759
|
+
|
771
760
|
A backtick-delimited string in a code span: `` `foo` ``
|
772
761
|
|
773
762
|
will produce:
|
774
763
|
|
775
764
|
<p>A single backtick in a code span: <code>`</code></p>
|
776
|
-
|
765
|
+
|
777
766
|
<p>A backtick-delimited string in a code span: <code>`foo`</code></p>
|
778
767
|
|
779
768
|
With a code span, ampersands and angle brackets are encoded as HTML
|
@@ -844,7 +833,7 @@ use regular HTML `<img>` tags.
|
|
844
833
|
Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
|
845
834
|
|
846
835
|
<http://example.com/>
|
847
|
-
|
836
|
+
|
848
837
|
Markdown will turn this into:
|
849
838
|
|
850
839
|
<a href="http://example.com/">http://example.com/</a>
|
@@ -896,4 +885,3 @@ Markdown provides backslash escapes for the following characters:
|
|
896
885
|
- minus sign (hyphen)
|
897
886
|
. dot
|
898
887
|
! exclamation mark
|
899
|
-
|
data/docs/math.md
CHANGED
@@ -9,11 +9,7 @@ Math support in Maruku
|
|
9
9
|
|
10
10
|
This document describes Maruku's support of inline LaTeX-style math.
|
11
11
|
|
12
|
-
|
13
|
-
buggy and the syntax and implementation are bound to change in
|
14
|
-
the near future.
|
15
|
-
|
16
|
-
Also, there are many subtleties of which one must care for
|
12
|
+
There are many subtleties of which one must care for
|
17
13
|
correctly serving the XHTML+MathML document to browsers.
|
18
14
|
In fact, *this documentation is __not__ enough to get you started*,
|
19
15
|
unless you feel very adventurous.
|
@@ -118,7 +114,7 @@ You have to enable the math extension like this:
|
|
118
114
|
|
119
115
|
Use the following to choose the engine:
|
120
116
|
|
121
|
-
MaRuKu::Globals[:html_math_engine] = '
|
117
|
+
MaRuKu::Globals[:html_math_engine] = 'itex2mml'
|
122
118
|
MaRuKu::Globals[:html_png_engine] = 'blahtex'
|
123
119
|
|
124
120
|
Available MathML engines are 'none', 'itex2mml', 'blahtex'.
|
@@ -129,21 +125,13 @@ External libraries needed
|
|
129
125
|
|
130
126
|
To output MathML or PNGs, it is needed to install one of the following libraries
|
131
127
|
|
132
|
-
### Using `ritex` ### {#using_ritex}
|
133
|
-
|
134
|
-
Install with
|
135
|
-
|
136
|
-
$ gem install ritex
|
137
|
-
|
138
|
-
ritex's abilities are very limited, but it is the easiest to install.
|
139
|
-
|
140
128
|
### Using `itex2mml` ### {#using_itex2mml}
|
141
129
|
|
142
130
|
itex2mml supports much more LaTeX commands/environments than ritex.
|
143
131
|
|
144
|
-
Install
|
132
|
+
Install itextomml with
|
145
133
|
|
146
|
-
|
134
|
+
$ gem install itextomml
|
147
135
|
|
148
136
|
This is a summary of the available LaTeX commands:
|
149
137
|
|
@@ -152,10 +140,18 @@ This is a summary of the available LaTeX commands:
|
|
152
140
|
Moreover, [Jacques Distler] is integrating Maruku+itex2mml+[Instiki].
|
153
141
|
You can find more information here:
|
154
142
|
|
155
|
-
> <http://golem.ph.utexas.edu
|
143
|
+
> <http://golem.ph.utexas.edu/wiki/instiki/show/HomePage>
|
156
144
|
|
157
145
|
[Jacques Distler]: http://golem.ph.utexas.edu/~distler
|
158
|
-
[instiki]: http://
|
146
|
+
[instiki]: http://golem.ph.utexas.edu/wiki/instiki/show/HomePage
|
147
|
+
|
148
|
+
### Using `ritex` ### {#using_ritex}
|
149
|
+
|
150
|
+
Install with
|
151
|
+
|
152
|
+
$ gem install ritex
|
153
|
+
|
154
|
+
ritex's abilities are very limited, but it is the easiest to install since, unlike `itextomml`, it is a pure-ruby implementation.
|
159
155
|
|
160
156
|
### Using `blahtex` ### {#using_blahtex}
|
161
157
|
|
data/lib/maruku.rb
CHANGED
@@ -1,83 +1,74 @@
|
|
1
1
|
#--
|
2
|
-
#
|
2
|
+
# Copyright (c) 2006 Andrea Censi
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
22
|
#++
|
20
23
|
|
21
|
-
require 'rexml/document'
|
22
|
-
|
23
|
-
# :include:MaRuKu.txt
|
24
24
|
module MaRuKu
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
class MDDocument < MDElement
|
63
|
-
include In::Markdown
|
64
|
-
include In::Markdown::SpanLevelParser
|
65
|
-
include In::Markdown::BlockLevelParser
|
66
|
-
end
|
25
|
+
module In
|
26
|
+
module Markdown
|
27
|
+
module SpanLevelParser; end
|
28
|
+
module BlockLevelParser; end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Out
|
33
|
+
module Markdown; end
|
34
|
+
module HTML; end
|
35
|
+
module Latex; end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Strings; end
|
39
|
+
|
40
|
+
module Helpers; end
|
41
|
+
|
42
|
+
module Errors; end
|
43
|
+
|
44
|
+
class MDElement
|
45
|
+
include MaRuKu
|
46
|
+
include Out::Markdown
|
47
|
+
include Out::HTML
|
48
|
+
include Out::Latex
|
49
|
+
include Strings
|
50
|
+
include Helpers
|
51
|
+
include Errors
|
52
|
+
end
|
53
|
+
|
54
|
+
class MDDocument < MDElement
|
55
|
+
include In::Markdown
|
56
|
+
include In::Markdown::SpanLevelParser
|
57
|
+
include In::Markdown::BlockLevelParser
|
58
|
+
end
|
67
59
|
end
|
68
60
|
|
69
|
-
# This is the public interface
|
70
61
|
class Maruku < MaRuKu::MDDocument; end
|
71
62
|
|
72
63
|
|
73
|
-
|
74
|
-
require 'rexml/document'
|
75
|
-
|
76
64
|
# Structures definition
|
77
|
-
require 'maruku/
|
78
|
-
require 'maruku/
|
65
|
+
require 'maruku/attributes'
|
66
|
+
require 'maruku/element'
|
67
|
+
require 'maruku/document'
|
68
|
+
require 'maruku/inspect_element'
|
79
69
|
|
80
70
|
require 'maruku/defaults'
|
71
|
+
|
81
72
|
# Less typing
|
82
73
|
require 'maruku/helpers'
|
83
74
|
|
@@ -87,7 +78,7 @@ require 'maruku/input/parse_doc'
|
|
87
78
|
# Ugly things kept in a closet
|
88
79
|
require 'maruku/string_utils'
|
89
80
|
require 'maruku/input/linesource'
|
90
|
-
require 'maruku/input/
|
81
|
+
require 'maruku/input/mdline'
|
91
82
|
|
92
83
|
# A class for reading and sanitizing inline HTML
|
93
84
|
require 'maruku/input/html_helper'
|
@@ -97,34 +88,31 @@ require 'maruku/input/parse_block'
|
|
97
88
|
|
98
89
|
# Code for parsing Markdown span-level elements
|
99
90
|
require 'maruku/input/charsource'
|
100
|
-
require 'maruku/input/
|
101
|
-
require 'maruku/input/rubypants'
|
91
|
+
require 'maruku/input/parse_span'
|
102
92
|
|
103
93
|
require 'maruku/input/extensions'
|
104
94
|
|
105
|
-
require 'maruku/
|
106
|
-
|
107
|
-
require 'maruku/structures_iterators'
|
108
|
-
|
109
|
-
require 'maruku/errors_management'
|
95
|
+
require 'maruku/errors'
|
110
96
|
|
111
97
|
# Code for creating a table of contents
|
112
98
|
require 'maruku/toc'
|
113
99
|
|
114
100
|
# Support for div Markdown extension
|
115
101
|
require 'maruku/ext/div'
|
102
|
+
# Support for fenced codeblocks extension
|
103
|
+
require 'maruku/ext/fenced_code'
|
116
104
|
|
117
105
|
# Version and URL
|
118
106
|
require 'maruku/version'
|
119
107
|
|
108
|
+
# Entity conversion for HTML and LaTeX
|
109
|
+
require 'maruku/output/entity_table'
|
120
110
|
|
121
111
|
# Exporting to html
|
122
112
|
require 'maruku/output/to_html'
|
123
113
|
|
124
114
|
# Exporting to latex
|
125
115
|
require 'maruku/output/to_latex'
|
126
|
-
require 'maruku/output/to_latex_strings'
|
127
|
-
require 'maruku/output/to_latex_entities'
|
128
116
|
|
129
117
|
# Pretty print
|
130
118
|
require 'maruku/output/to_markdown'
|
@@ -138,4 +126,3 @@ require 'maruku/output/to_s'
|
|
138
126
|
|
139
127
|
# class Maruku is the global interface
|
140
128
|
require 'maruku/maruku'
|
141
|
-
|
data/lib/maruku/attributes.rb
CHANGED
@@ -1,227 +1,122 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#++
|
1
|
+
module MaRuKu
|
2
|
+
# This represents a list of attributes specified in the Markdown document
|
3
|
+
# that apply to a Markdown-generated tag.
|
4
|
+
# What was `{#id .class key="val" ref}` in the Markdown
|
5
|
+
# is parsed into `[[:id, 'id'], [:class, 'class'], ['key', 'val'], [:ref, 'ref']]`.
|
6
|
+
class AttributeList < Array
|
7
|
+
def to_s
|
8
|
+
map do |k, v|
|
9
|
+
value = quote_if_needed(v)
|
10
|
+
case k
|
11
|
+
when :id; "#" + value
|
12
|
+
when :class; "." + value
|
13
|
+
when :ref; value
|
14
|
+
else quote_if_needed(k) + "=" + value
|
15
|
+
end
|
16
|
+
end.join(' ')
|
17
|
+
end
|
18
|
+
alias to_md to_s
|
20
19
|
|
20
|
+
private
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
else
|
27
|
-
self
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module MaRuKu;
|
33
|
-
MagicChar = ':'
|
34
|
-
|
35
|
-
class AttributeList < Array
|
36
|
-
|
37
|
-
# An attribute list becomes
|
38
|
-
# {#id .cl key="val" ref}
|
39
|
-
# [ [:id, 'id'], [:class, 'id'], ['key', 'val'], [ :ref, 'ref' ]]
|
22
|
+
def quote_if_needed(str)
|
23
|
+
(str =~ /[\s'"]/) ? str.inspect : str
|
24
|
+
end
|
25
|
+
end
|
40
26
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
push [key, val]
|
46
|
-
end
|
47
|
-
def push_ref(ref_id);
|
48
|
-
|
49
|
-
raise "Bad :ref #{ref_id.inspect}" if not ref_id
|
50
|
-
push [:ref, ref_id+""]
|
27
|
+
module In::Markdown::SpanLevelParser
|
28
|
+
def md_al(s = [])
|
29
|
+
AttributeList.new(s)
|
30
|
+
end
|
51
31
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
def push_id(val);
|
59
|
-
raise "Bad :id #{val.inspect}" if not val
|
60
|
-
push [:id, val]
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_s
|
64
|
-
map do |k,v|
|
65
|
-
case k
|
66
|
-
when :id; "#" + v.quote_if_needed
|
67
|
-
when :class; "." + v.quote_if_needed
|
68
|
-
when :ref; v.quote_if_needed
|
69
|
-
else k.quote_if_needed + "=" + v.quote_if_needed
|
70
|
-
end
|
71
|
-
end . join(' ')
|
72
|
-
end
|
73
|
-
alias to_md to_s
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
32
|
+
# @return [AttributeList, nil]
|
33
|
+
def read_attribute_list(src, con=nil, break_on_chars=nil)
|
34
|
+
break_on_chars = Array(break_on_chars)
|
35
|
+
separators = break_on_chars + ['=', ' ', "\t"]
|
36
|
+
escaped = Maruku::EscapedCharInQuotes
|
77
37
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
[ "", [], "Empty lists are allowed" ],
|
83
|
-
[ "=", :throw, "Bad char to begin a list with." ],
|
84
|
-
[ "a =b", :throw, "No whitespace before `=`." ],
|
85
|
-
[ "a= b", :throw, "No whitespace after `=`." ],
|
38
|
+
al = AttributeList.new
|
39
|
+
loop do
|
40
|
+
src.consume_whitespace
|
41
|
+
break if break_on_chars.include? src.cur_char
|
86
42
|
|
87
|
-
|
88
|
-
|
89
|
-
|
43
|
+
case src.cur_char
|
44
|
+
when ':'
|
45
|
+
src.ignore_char
|
46
|
+
when nil
|
47
|
+
break # we're done here.
|
48
|
+
when '=' # error
|
49
|
+
src.ignore_char
|
50
|
+
maruku_error "In attribute lists, cannot start identifier with `=`."
|
51
|
+
tell_user "Ignoring and continuing."
|
52
|
+
when '#' # id definition
|
53
|
+
src.ignore_char
|
54
|
+
if id = read_quoted_or_unquoted(src, con, escaped, separators)
|
55
|
+
al << [:id, id]
|
56
|
+
else
|
57
|
+
maruku_error 'Could not read `id` attribute.', src, con
|
58
|
+
tell_user 'Ignoring bad `id` attribute.'
|
59
|
+
end
|
60
|
+
when '.' # class definition
|
61
|
+
src.ignore_char
|
62
|
+
if klass = read_quoted_or_unquoted(src, con, escaped, separators)
|
63
|
+
al << [:class, klass]
|
64
|
+
else
|
65
|
+
maruku_error 'Could not read `class` attribute.', src, con
|
66
|
+
tell_user 'Ignoring bad `class` attribute.'
|
67
|
+
end
|
68
|
+
else
|
69
|
+
unless key = read_quoted_or_unquoted(src, con, escaped, separators)
|
70
|
+
maruku_error 'Could not read key or reference.'
|
71
|
+
next
|
72
|
+
end
|
90
73
|
|
91
|
-
|
92
|
-
|
74
|
+
if src.cur_char != '=' && key.length > 0
|
75
|
+
al << [:ref, key]
|
76
|
+
next
|
77
|
+
end
|
93
78
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
79
|
+
src.ignore_char # skip the =
|
80
|
+
if val = read_quoted_or_unquoted(src, con, escaped, separators)
|
81
|
+
al << [key, val]
|
82
|
+
else
|
83
|
+
maruku_error "Could not read value for key #{key.inspect}.", src, con
|
84
|
+
tell_user "Ignoring key #{key.inspect}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
al
|
89
|
+
end
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
['"', :throw, "Unclosed quotes"],
|
104
|
-
["'"],
|
105
|
-
["'a "],
|
106
|
-
['"a '],
|
107
|
-
|
108
|
-
[ "#a", [[:id, 'a']], "Simple ID" ],
|
109
|
-
[ "#'a'" ],
|
110
|
-
[ '#"a"' ],
|
91
|
+
def merge_ial(elements, src, con)
|
92
|
+
# Apply each IAL to the element before
|
93
|
+
(elements + [nil]).each_cons(3) do |before, e, after|
|
94
|
+
next unless ial?(e)
|
111
95
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
(comment == last && (comment += (@count+=1).to_s)) || @count = 1
|
127
|
-
expected = [md_ial(expected)] if expected.kind_of? Array
|
128
|
-
["{#{MagicChar}#{s}}", expected, "Attributes: #{comment}"]
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
|
-
def md_al(s=[]); AttributeList.new(s) end
|
96
|
+
if before.kind_of? MDElement
|
97
|
+
before.al = e.ial
|
98
|
+
elsif after.kind_of? MDElement
|
99
|
+
after.al = e.ial
|
100
|
+
else
|
101
|
+
maruku_error <<ERR, src, con
|
102
|
+
It's unclear which element the attribute list {:#{e.ial.to_s}}
|
103
|
+
is referring to. The element before is a #{before.class},
|
104
|
+
the element after is a #{after.class}.
|
105
|
+
before: #{before.inspect}
|
106
|
+
after: #{after.inspect}
|
107
|
+
ERR
|
108
|
+
end
|
109
|
+
end
|
133
110
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
escaped = Maruku::EscapedCharInQuotes
|
139
|
-
|
140
|
-
al = AttributeList.new
|
141
|
-
while true
|
142
|
-
src.consume_whitespace
|
143
|
-
break if break_on_chars.include? src.cur_char
|
144
|
-
|
145
|
-
case src.cur_char
|
146
|
-
when nil
|
147
|
-
maruku_error "Attribute list terminated by EOF:\n "+
|
148
|
-
"#{al.inspect}" , src, con
|
149
|
-
tell_user "I try to continue and return partial attribute list:\n"+
|
150
|
-
al.inspect
|
151
|
-
break
|
152
|
-
when ?= # error
|
153
|
-
maruku_error "In attribute lists, cannot start identifier with `=`."
|
154
|
-
tell_user "I try to continue"
|
155
|
-
src.ignore_char
|
156
|
-
when ?# # id definition
|
157
|
-
src.ignore_char
|
158
|
-
if id = read_quoted_or_unquoted(src, con, escaped, separators)
|
159
|
-
al.push_id id
|
160
|
-
else
|
161
|
-
maruku_error 'Could not read `id` attribute.', src, con
|
162
|
-
tell_user 'Trying to ignore bad `id` attribute.'
|
163
|
-
end
|
164
|
-
when ?. # class definition
|
165
|
-
src.ignore_char
|
166
|
-
if klass = read_quoted_or_unquoted(src, con, escaped, separators)
|
167
|
-
al.push_class klass
|
168
|
-
else
|
169
|
-
maruku_error 'Could not read `class` attribute.', src, con
|
170
|
-
tell_user 'Trying to ignore bad `class` attribute.'
|
171
|
-
end
|
172
|
-
else
|
173
|
-
if key = read_quoted_or_unquoted(src, con, escaped, separators)
|
174
|
-
if src.cur_char == ?=
|
175
|
-
src.ignore_char # skip the =
|
176
|
-
if val = read_quoted_or_unquoted(src, con, escaped, separators)
|
177
|
-
al.push_key_val(key, val)
|
178
|
-
else
|
179
|
-
maruku_error "Could not read value for key #{key.inspect}.",
|
180
|
-
src, con
|
181
|
-
tell_user "Ignoring key #{key.inspect}."
|
182
|
-
end
|
183
|
-
else
|
184
|
-
al.push_ref key
|
185
|
-
end
|
186
|
-
else
|
187
|
-
maruku_error 'Could not read key or reference.'
|
188
|
-
end
|
189
|
-
end # case
|
190
|
-
end # while true
|
191
|
-
al
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
# We need a helper
|
196
|
-
def is_ial(e); e.kind_of? MDElement and e.node_type == :ial end
|
111
|
+
unless Globals[:debug_keep_ials]
|
112
|
+
elements.delete_if {|x| ial?(x) && x != elements.first}
|
113
|
+
end
|
114
|
+
end
|
197
115
|
|
198
|
-
|
116
|
+
private
|
199
117
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
if before.kind_of? MDElement
|
206
|
-
before.al = e.ial
|
207
|
-
elsif after.kind_of? MDElement
|
208
|
-
after.al = e.ial
|
209
|
-
else
|
210
|
-
maruku_error "It is not clear to me what element this IAL {:#{e.ial.to_md}} \n"+
|
211
|
-
"is referring to. The element before is a #{before.class.to_s}, \n"+
|
212
|
-
"the element after is a #{after.class.to_s}.\n"+
|
213
|
-
"\n before: #{before.inspect}"+
|
214
|
-
"\n after: #{after.inspect}",
|
215
|
-
src, con
|
216
|
-
# xxx dire se c'è empty vicino
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
if not Globals[:debug_keep_ials]
|
222
|
-
elements.delete_if {|x| is_ial(x) unless x == elements.first}
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
end end end end
|
227
|
-
#module MaRuKu; module In; module Markdown; module SpanLevelParser
|
118
|
+
def ial?(e)
|
119
|
+
e.is_a?(MDElement) && e.node_type == :ial
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|