kramdown 0.13.4 → 0.13.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kramdown might be problematic. Click here for more details.
- data/CONTRIBUTERS +2 -1
- data/ChangeLog +237 -0
- data/Rakefile +5 -4
- data/VERSION +1 -1
- data/bin/kramdown +1 -1
- data/doc/bg.png +0 -0
- data/doc/default.scss.css +127 -473
- data/doc/default.template +27 -40
- data/doc/design.scss.css +441 -0
- data/doc/documentation.page +4 -1
- data/doc/index.page +4 -9
- data/doc/installation.page +3 -3
- data/doc/news.page +1 -1
- data/doc/quickref.page +1 -1
- data/doc/sidebar.template +21 -0
- data/doc/syntax.page +65 -38
- data/doc/tests.page +6 -4
- data/lib/kramdown.rb +1 -1
- data/lib/kramdown/compatibility.rb +17 -3
- data/lib/kramdown/converter.rb +1 -1
- data/lib/kramdown/converter/base.rb +1 -1
- data/lib/kramdown/converter/html.rb +3 -2
- data/lib/kramdown/converter/kramdown.rb +13 -7
- data/lib/kramdown/converter/latex.rb +1 -1
- data/lib/kramdown/converter/toc.rb +1 -1
- data/lib/kramdown/document.rb +2 -2
- data/lib/kramdown/element.rb +1 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +1 -1
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +1 -1
- data/lib/kramdown/parser/html.rb +5 -5
- data/lib/kramdown/parser/kramdown.rb +1 -1
- data/lib/kramdown/parser/kramdown/abbreviation.rb +1 -1
- data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
- data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
- data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
- data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
- data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
- data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
- data/lib/kramdown/parser/kramdown/emphasis.rb +1 -1
- data/lib/kramdown/parser/kramdown/eob.rb +1 -1
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
- data/lib/kramdown/parser/kramdown/extensions.rb +1 -1
- data/lib/kramdown/parser/kramdown/footnote.rb +1 -1
- data/lib/kramdown/parser/kramdown/header.rb +1 -1
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +2 -2
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +1 -1
- data/lib/kramdown/parser/kramdown/list.rb +1 -1
- data/lib/kramdown/parser/kramdown/math.rb +4 -3
- data/lib/kramdown/parser/kramdown/paragraph.rb +1 -1
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
- data/lib/kramdown/parser/kramdown/table.rb +1 -1
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/markdown.rb +1 -1
- data/lib/kramdown/utils.rb +6 -1
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +2 -2
- data/lib/kramdown/utils/ordered_hash.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/man/man1/kramdown.1 +100 -100
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +1 -1
- data/test/testcases/block/04_header/with_auto_ids.html +2 -0
- data/test/testcases/block/04_header/with_auto_ids.text +3 -0
- data/test/testcases/block/09_html/html5_attributes.html +13 -0
- data/test/testcases/block/09_html/html5_attributes.text +13 -0
- data/test/testcases/block/09_html/simple.text +1 -1
- data/test/testcases/block/15_math/normal.html +2 -2
- data/test/testcases/span/05_html/normal.html +1 -1
- data/test/testcases/span/05_html/normal.text +1 -1
- data/test/testcases/span/math/normal.html +4 -0
- data/test/testcases/span/math/normal.text +5 -1
- metadata +55 -35
data/doc/documentation.page
CHANGED
@@ -9,9 +9,12 @@ kramdown is first and foremost a library for converting text written in a supers
|
|
9
9
|
HTML. However, due to its modular architecture it is able to support additional input and output
|
10
10
|
formats. The following input and output formats are currently supported:
|
11
11
|
|
12
|
-
* Input: [kramdown](parser/kramdown.html) (a superset of Markdown), [Markdown](parser/markdown.html),
|
12
|
+
* Input: [kramdown](parser/kramdown.html) (a superset of Markdown), [Markdown](parser/markdown.html),
|
13
|
+
[HTML](parser/html.html)
|
13
14
|
* Output: [HTML](converter/html.html), [LaTeX](converter/latex.html), [kramdown](converter/kramdown.html)
|
14
15
|
|
16
|
+
The [kramdown syntax page](syntax.html) describes in detail what is supported and how it differs
|
17
|
+
from standard Markdown.
|
15
18
|
|
16
19
|
## Usage
|
17
20
|
|
data/doc/index.page
CHANGED
@@ -8,8 +8,9 @@ sort_info: 1
|
|
8
8
|
If you want to get started with kramdown, have a look at the [installation page](installation.html)
|
9
9
|
to see how you can install it on your system. Then look through the
|
10
10
|
[documentation](documentation.html) for finding information about how to actually use kramdown and
|
11
|
-
its parsers/converters. The [
|
12
|
-
superset of Markdown which kramdown supports
|
11
|
+
its parsers/converters. The [quick reference](quickref.html) provides a overview of the syntax -- if
|
12
|
+
you need a more detailed description of the superset of Markdown which kramdown supports the [syntax
|
13
|
+
page](syntax.html) is the place to go!
|
13
14
|
|
14
15
|
{tikz:: path: overview.png
|
15
16
|
img_attr: {style: 'background:transparent'}
|
@@ -79,20 +80,14 @@ Markdown implementations because kramdown borrowed many ideas from existing pack
|
|
79
80
|
|
80
81
|
--- name:intro
|
81
82
|
|
82
|
-
## Welcome to the kramdown site
|
83
|
-
|
84
83
|
**kramdown** (sic, not Kramdown or KramDown, just kramdown) is a *free* GPL-licensed
|
85
84
|
[Ruby](http://www.ruby-lang.org) library for parsing and converting a superset of Markdown. It is
|
86
85
|
completely written in Ruby, supports standard Markdown (with some minor modifications) and various
|
87
86
|
extensions that have been made popular by the [PHP Markdown Extra] package and [Maruku].
|
88
87
|
|
89
|
-
It is probably the fastest pure-Ruby Markdown converter available (
|
88
|
+
It is probably the fastest pure-Ruby Markdown converter available (February 2012), being about 4x
|
90
89
|
faster than [Maruku] and about 5x faster than [BlueFeather].
|
91
90
|
|
92
|
-
<p class="a-center">
|
93
|
-
The latest version of kramdown is <b>0.13.4</b> and it was released on <b>2011-12-16</b>.
|
94
|
-
</p>
|
95
|
-
|
96
91
|
[PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/
|
97
92
|
[Maruku]: http://maruku.rubyforge.org
|
98
93
|
[BlueFeather]: http://ruby.morphball.net/bluefeather/index_en.html
|
data/doc/installation.page
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
title:
|
2
|
+
title: Installation
|
3
3
|
in_menu: true
|
4
4
|
sort_info: 5
|
5
5
|
---
|
@@ -8,7 +8,7 @@ sort_info: 5
|
|
8
8
|
## Dependencies
|
9
9
|
|
10
10
|
Since kramdown is written in Ruby, you just need the [Ruby interpreter](http://www.ruby-lang.org),
|
11
|
-
version 1.8.5, 1.8.6, 1.8.7 or 1.9.
|
11
|
+
version 1.8.5, 1.8.6, 1.8.7, 1.9.2 or 1.9.3. There are no other dependencies.
|
12
12
|
|
13
13
|
|
14
14
|
## Compatibility Notes
|
@@ -16,7 +16,7 @@ version 1.8.5, 1.8.6, 1.8.7 or 1.9.2. There are no other dependencies.
|
|
16
16
|
kramdown should work on any platform which supports Ruby. It has been successfully tested on the
|
17
17
|
following platforms:
|
18
18
|
|
19
|
-
* Linux with Ruby 1.8.5, 1.8.6, 1.8.7, 1.9.2 and jruby 1.
|
19
|
+
* Linux with Ruby 1.8.5, 1.8.6, 1.8.7, 1.9.2, 1.9.3 and jruby 1.6.0.
|
20
20
|
|
21
21
|
See the platform specific installation notes for more information!
|
22
22
|
|
data/doc/news.page
CHANGED
data/doc/quickref.page
CHANGED
@@ -90,7 +90,7 @@ If you set the option `auto_ids` to `false` (for example, by using the `options`
|
|
90
90
|
[Extensions](#extensions)), then the automatic header ID generation is turned off:
|
91
91
|
|
92
92
|
{kdexample::}
|
93
|
-
{
|
93
|
+
{::options auto_ids="false" /}
|
94
94
|
|
95
95
|
# A header without an ID
|
96
96
|
{kdexample}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h2>News</h2>
|
2
|
+
|
3
|
+
<p>The latest version of kramdown is <b>0.13.5</b> and it was released
|
4
|
+
on <b>2012-02-19</b>.</p>
|
5
|
+
|
6
|
+
<p>More <a href="news.html">news</a>…</p>
|
7
|
+
|
8
|
+
<h2>Support kramdown</h2>
|
9
|
+
|
10
|
+
<p>If you like kramdown and would like to support it, you are welcome to make a small
|
11
|
+
donation (PayPal or Pledgie) -- it will surely be appreciated! Thanks!</p>
|
12
|
+
|
13
|
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
14
|
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
15
|
+
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
|
16
|
+
" />
|
17
|
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
|
18
|
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
|
19
|
+
</form>
|
20
|
+
|
21
|
+
<a href='http://www.pledgie.com/campaigns/16657'><img alt='Click here to lend your support to: kramdown and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/16657.png?skin_name=chrome' border='0' /></a>
|
data/doc/syntax.page
CHANGED
@@ -449,24 +449,26 @@ elements. All other list markers in the list may be indented up to three spaces
|
|
449
449
|
spaces used for the indentation of the last list item minus one, whichever number is smaller. For
|
450
450
|
example:
|
451
451
|
|
452
|
-
* This is the first line. Since the first non-space characters appears in
|
453
|
-
indented lines have to be indented 2 spaces.
|
454
|
-
However, one could be lazy and not indent a line but this is not
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
452
|
+
* This is the first line. Since the first non-space characters appears in
|
453
|
+
column 3, all other indented lines have to be indented 2 spaces.
|
454
|
+
However, one could be lazy and not indent a line but this is not
|
455
|
+
recommended.
|
456
|
+
* This is the another item of the list. It uses a different number
|
457
|
+
of spaces for indentation which is okay but should generally be avoided.
|
458
|
+
* The list item marker is indented 3 spaces which is allowed but should
|
459
|
+
also be avoided and starts the third list item. Note that the lazy
|
460
|
+
line in the second list item may make you believe that this is a
|
461
|
+
sub-list which it isn't! So avoid being lazy!
|
460
462
|
|
461
463
|
So, while the above is possible and creates one list with three items, it is not advised to use
|
462
464
|
different (marker and list content) indents for same level list items as well as lazy indentation!
|
463
465
|
It is much better to write such a list in the following way:
|
464
466
|
|
465
|
-
* This is the first list item bla blabla blabla blabla blabla blabla
|
466
|
-
blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
|
467
|
+
* This is the first list item bla blabla blabla blabla blabla blabla
|
468
|
+
blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
|
467
469
|
blabla blabla blabla bla
|
468
|
-
* This is the another item of the list. bla blabla blabla blabla blabla
|
469
|
-
blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
|
470
|
+
* This is the another item of the list. bla blabla blabla blabla blabla
|
471
|
+
blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
|
470
472
|
|
471
473
|
> The original Markdown syntax also allows you to indent the marker, however, the behaviour of what
|
472
474
|
> happens with the list items is not clearly specified and may surprise you.
|
@@ -478,12 +480,13 @@ When using tabs for indenting the content of a list item, remember that tab stop
|
|
478
480
|
of four for kramdown. Tabs are correctly converted to spaces for calculating the indentation. For
|
479
481
|
example:
|
480
482
|
|
481
|
-
* Using a tab to indent this line, the tab only counts as three spaces
|
482
|
-
overall indentation is four spaces.
|
483
|
+
* Using a tab to indent this line, the tab only counts as three spaces
|
484
|
+
and therefore the overall indentation is four spaces.
|
483
485
|
|
484
|
-
1. The tab after the marker counts here as three spaces. Since the
|
485
|
-
marker is three spaces and the marker itself
|
486
|
-
|
486
|
+
1. The tab after the marker counts here as three spaces. Since the
|
487
|
+
indentation of the marker is three spaces and the marker itself
|
488
|
+
takes two characters, the overall indentation needed for the
|
489
|
+
following lines is eight spaces or two tabs.
|
487
490
|
|
488
491
|
It is clear that you might get unexpected results if you mix tabs and spaces or if you don't have
|
489
492
|
the tab stops set to multiples of four in your editor! Therefore this should be avoided!
|
@@ -556,7 +559,8 @@ problem when you want to have a code block as first element. The solution to thi
|
|
556
559
|
following construct:
|
557
560
|
|
558
561
|
*
|
559
|
-
This is a code block (indentation needs to be 4(1)+4(1)
|
562
|
+
This is a code block (indentation needs to be 4(1)+4(1)
|
563
|
+
spaces (tabs)).
|
560
564
|
{: .show-whitespaces .ws-lr}
|
561
565
|
|
562
566
|
Note that the list marker needs to be followed with at least one space or tab! Otherwise the line is
|
@@ -639,12 +643,15 @@ definition minus one, whichever number is smaller. For example:
|
|
639
643
|
|
640
644
|
definition term 1
|
641
645
|
definition term 2
|
642
|
-
: This is the first line. Since the first non-space characters appears in
|
643
|
-
lines have to be indented 2 spaces (or lazy syntax may
|
644
|
-
tells kramdown that the lines
|
645
|
-
|
646
|
-
|
647
|
-
|
646
|
+
: This is the first line. Since the first non-space characters appears in
|
647
|
+
column 3, all other lines have to be indented 2 spaces (or lazy syntax may
|
648
|
+
be used after an indented line). This tells kramdown that the lines
|
649
|
+
belong to the definition.
|
650
|
+
: This is the another definition for the same term. It uses a
|
651
|
+
different number of spaces for indentation which is okay but
|
652
|
+
should generally be avoided.
|
653
|
+
: The definition marker is indented 3 spaces which is allowed but
|
654
|
+
should also be avoided.
|
648
655
|
|
649
656
|
So, while the above is possible and creates a definition list with two terms and three definitions
|
650
657
|
for them, it is not advised to use different (definition marker and definition) indents in the same
|
@@ -655,12 +662,13 @@ preceded by a blank line, the first part of the definition will just be text if
|
|
655
662
|
paragraph otherwise:
|
656
663
|
|
657
664
|
definition term
|
658
|
-
: This definition will just be text because it would normally be a
|
659
|
-
no preceding blank line.
|
665
|
+
: This definition will just be text because it would normally be a
|
666
|
+
paragraph and the there is no preceding blank line.
|
660
667
|
|
661
668
|
> although the definition contains other block-level elements
|
662
669
|
|
663
|
-
: This definition *will* be a paragraph since it is preceded by a
|
670
|
+
: This definition *will* be a paragraph since it is preceded by a
|
671
|
+
blank line.
|
664
672
|
|
665
673
|
The rules about having any block-level element as first element in a list item also apply to a
|
666
674
|
definition.
|
@@ -885,12 +893,23 @@ $$
|
|
885
893
|
$$
|
886
894
|
|
887
895
|
Using inline math is also easy: just surround your math content with two dollar signs, like with a
|
888
|
-
math block.
|
896
|
+
math block. If you don't want to start an inline math statement, just escape the dollar signs and
|
897
|
+
they will be treated as simple dollar signs.
|
889
898
|
|
890
|
-
If you
|
891
|
-
|
892
|
-
the beginning of a paragraph, just escape the first dollar sign.
|
899
|
+
If you have a paragraph that looks like a math block but should actually be a paragraph with just an
|
900
|
+
inline math statement, you need to escape the first dollar sign:
|
893
901
|
|
902
|
+
The following is a math block:
|
903
|
+
|
904
|
+
$$ 5 + 5 $$
|
905
|
+
|
906
|
+
But next comes a paragraph with an inline math statement:
|
907
|
+
|
908
|
+
\$$ 5 + 5 $$
|
909
|
+
|
910
|
+
If you don't even won't the inline math statement, escape the first two dollar signs:
|
911
|
+
|
912
|
+
\$\$ 5 + 5 $$
|
894
913
|
|
895
914
|
## HTML Blocks
|
896
915
|
|
@@ -919,9 +938,10 @@ content is parsed:
|
|
919
938
|
raw HTML again. However, if a tag has a `markdown` attribute, this attribute controls parsing of
|
920
939
|
this one tag (see below).
|
921
940
|
|
922
|
-
Note that only correct XHTML
|
923
|
-
|
924
|
-
tag is found, it is
|
941
|
+
Note that the parser basically supports only correct XHTML! However, there are some exceptions.
|
942
|
+
For example, attributes without values (i.e. boolean attributes) are also supported and elements
|
943
|
+
without content like `<hr />` can be written as `<hr>`. If an invalid closing tag is found, it is
|
944
|
+
ignored.
|
925
945
|
|
926
946
|
* Parse as block-level elements: If the HTML/XML tag content should be parsed as text containing
|
927
947
|
block-level elements, the remaining text on the line will be parsed by the block-level parser as
|
@@ -940,6 +960,8 @@ inside a raw HTML block.
|
|
940
960
|
|
941
961
|
Also, if an invalid closing tag is found, it is ignored.
|
942
962
|
|
963
|
+
Note that all HTML tag and attribute names are converted to lowercase!
|
964
|
+
|
943
965
|
By default, kramdown parses all block HTML tags and all XML tags as raw HTML blocks. However, this
|
944
966
|
can be configured with the `parse_block_html`. If this is set to `true`, then syntax parsing in HTML
|
945
967
|
blocks is globally enabled. It is also possible to enable/disable syntax parsing on a tag per tag
|
@@ -1014,7 +1036,8 @@ appears after a start/end tag but on the same line, is processed as if it appear
|
|
1014
1036
|
which is continued here.
|
1015
1037
|
</div>
|
1016
1038
|
|
1017
|
-
<p markdown="1">This works without problems because it is parsed as
|
1039
|
+
<p markdown="1">This works without problems because it is parsed as
|
1040
|
+
span-level elements</p>
|
1018
1041
|
|
1019
1042
|
<div markdown="1">The end tag is not found because
|
1020
1043
|
this line is parsed as a paragraph</div>
|
@@ -1220,7 +1243,8 @@ You can insert one optional space after the starting and before the ending delim
|
|
1220
1243
|
are not used in the output). For example:
|
1221
1244
|
|
1222
1245
|
Here is a literal `` ` `` backtick.
|
1223
|
-
And here is `` `some` `` text (note the two spaces so that one is left
|
1246
|
+
And here is `` `some` `` text (note the two spaces so that one is left
|
1247
|
+
in the output!).
|
1224
1248
|
|
1225
1249
|
A single backtick surrounded by spaces is treated as literal backtick. If you want to force the
|
1226
1250
|
literal meaning of a backtick you can backslash-escape it:
|
@@ -1510,8 +1534,11 @@ class names
|
|
1510
1534
|
{:id: class="cls1 cls2}
|
1511
1535
|
|
1512
1536
|
As can be seen from the example of the class names, attributes that are defined earlier are
|
1513
|
-
overwritten by ones with the same name defined later.
|
1514
|
-
|
1537
|
+
overwritten by ones with the same name defined later.
|
1538
|
+
|
1539
|
+
> Also, everything in the attribute definitions part that does not match one of the above four types
|
1540
|
+
> is ignored.
|
1541
|
+
{:.information}
|
1515
1542
|
|
1516
1543
|
If there is more than one ALD with the same reference name, the attribute definitions of all the
|
1517
1544
|
ALDs are processed like they are defined in one ALD.
|
data/doc/tests.page
CHANGED
@@ -17,12 +17,14 @@ to verify that the implementation matches the kramdown specification.
|
|
17
17
|
|
18
18
|
If you believe you have found a bug in the implementation, please follow these steps:
|
19
19
|
|
20
|
-
* Check the syntax page and see if the behaviour is not intended.
|
20
|
+
* Check the [syntax page](syntax.html) and see if the behaviour is not intended.
|
21
21
|
|
22
22
|
* If the behaviour is not intended and it seems that kramdown should parse some text in another
|
23
|
-
fashion, please open a bug report and attach two files: one with the text and one with the HTML
|
23
|
+
fashion, please open a [bug report] and attach two files: one with the text and one with the HTML
|
24
24
|
conversion you think is correct.
|
25
25
|
|
26
|
+
[bug report]: http://rubyforge.org/tracker/?atid=28673&group_id=7403&func=browse
|
27
|
+
|
26
28
|
|
27
29
|
# Benchmark
|
28
30
|
|
@@ -30,7 +32,7 @@ kramdown comes with a small benchmark to test how fast it is in regard to four o
|
|
30
32
|
implementations: Maruku, BlueFeather, BlueCloth and RDiscount. The first two are written using only
|
31
33
|
Ruby, the latter two use the C discount library for the actual hard work (which makes them really
|
32
34
|
fast but they do not provide additional syntax elements). As one can see below, kramdown is
|
33
|
-
currently (
|
35
|
+
currently (February 2012) ~3-4x faster than Maruku, ~4-5x faster than BlueFeather but ~30x slower
|
34
36
|
than BlueCloth and rdiscount:
|
35
37
|
|
36
38
|
<pre><code>
|
@@ -46,7 +48,7 @@ different Ruby interpreters:
|
|
46
48
|
![ruby 1.8.7p249]({relocatable: img/graph-ruby-1.8.7-249.png})
|
47
49
|
![ruby 1.8.7p302]({relocatable: img/graph-ruby-1.8.7-302.png})
|
48
50
|
![ruby 1.9.2p136]({relocatable: img/graph-ruby-1.9.2p136-136.png})
|
49
|
-
![ruby 1.9.
|
51
|
+
![ruby 1.9.3p125]({relocatable: img/graph-ruby-1.9.3p125-125.png})
|
50
52
|
|
51
53
|
[Markdown Test Suite]: http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip
|
52
54
|
[MDTest]: http://www.michelf.com/docs/projets/mdtest-1.0.zip
|
data/lib/kramdown.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown.
|
7
7
|
#
|
@@ -23,13 +23,27 @@
|
|
23
23
|
#
|
24
24
|
# :stopdoc:
|
25
25
|
|
26
|
-
if RUBY_VERSION
|
26
|
+
if RUBY_VERSION <= '1.8.6'
|
27
27
|
require 'rexml/parsers/baseparser'
|
28
28
|
module REXML
|
29
29
|
module Parsers
|
30
30
|
class BaseParser
|
31
|
-
UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
|
31
|
+
UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}" unless const_defined?(:UNAME_STR)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
if !String.instance_methods.include?("start_with?")
|
37
|
+
|
38
|
+
class String
|
39
|
+
def start_with?(str)
|
40
|
+
self[0, str.length] == str
|
41
|
+
end
|
42
|
+
def end_with?(str)
|
43
|
+
self[-str.length, str.length] == str
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
35
49
|
end
|
data/lib/kramdown/converter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown.
|
7
7
|
#
|
@@ -315,7 +315,8 @@ module Kramdown
|
|
315
315
|
|
316
316
|
def convert_math(el, indent)
|
317
317
|
block = (el.options[:category] == :block)
|
318
|
-
|
318
|
+
value = (el.value =~ /<|&/ ? "<![CDATA[#{el.value}]]>" : el.value)
|
319
|
+
"<script type=\"math/tex#{block ? '; mode=display' : ''}\">#{value}</script>#{block ? "\n" : ''}"
|
319
320
|
end
|
320
321
|
|
321
322
|
def convert_abbreviation(el, indent)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown.
|
7
7
|
#
|
@@ -96,7 +96,13 @@ module Kramdown
|
|
96
96
|
first, second, *rest = inner(el, opts).strip.gsub(/(.{1,#{w}})( +|$\n?)/, "\\1\n").split(/\n/)
|
97
97
|
first.gsub!(/^(?:(#|>)|(\d+)\.|([+-]\s))/) { $1 || $3 ? "\\#{$1 || $3}" : "#{$2}\\."} if first
|
98
98
|
second.gsub!(/^([=-]+\s*?)$/, "\\\1") if second
|
99
|
-
[first, second, *rest].compact.join("\n") + "\n"
|
99
|
+
res = [first, second, *rest].compact.join("\n") + "\n"
|
100
|
+
if el.children.length == 1 && el.children.first.type == :math
|
101
|
+
res = "\\#{res}"
|
102
|
+
elsif res.start_with?('\$$') && res.end_with?("\\$$\n")
|
103
|
+
res.sub!(/^\\\$\$/, '\$\$')
|
104
|
+
end
|
105
|
+
res
|
100
106
|
end
|
101
107
|
|
102
108
|
|
@@ -112,7 +118,7 @@ module Kramdown
|
|
112
118
|
def convert_header(el, opts)
|
113
119
|
res = ''
|
114
120
|
res << "#{'#' * el.options[:level]} #{inner(el, opts)}"
|
115
|
-
res << " {##{el.attr['id']}}" if el.attr['id']
|
121
|
+
res << " {##{el.attr['id']}}" if el.attr['id'] && !el.attr['id'].strip.empty?
|
116
122
|
res << "\n"
|
117
123
|
end
|
118
124
|
|
@@ -351,7 +357,7 @@ module Kramdown
|
|
351
357
|
end
|
352
358
|
|
353
359
|
def convert_math(el, opts)
|
354
|
-
|
360
|
+
"$$#{el.value}$$" + (el.options[:category] == :block ? "\n" : '')
|
355
361
|
end
|
356
362
|
|
357
363
|
def convert_abbreviation(el, opts)
|
@@ -398,12 +404,12 @@ module Kramdown
|
|
398
404
|
def ial_for_element(el)
|
399
405
|
res = el.attr.map do |k,v|
|
400
406
|
next if [:img, :a].include?(el.type) && ['href', 'src', 'alt', 'title'].include?(k)
|
401
|
-
next if el.type == :header && k == 'id'
|
407
|
+
next if el.type == :header && k == 'id' && !v.strip.empty?
|
402
408
|
if v.nil?
|
403
409
|
''
|
404
|
-
elsif k == 'class'
|
410
|
+
elsif k == 'class' && !v.empty?
|
405
411
|
" " + v.split(/\s+/).map {|w| ".#{w}"}.join(" ")
|
406
|
-
elsif k == 'id'
|
412
|
+
elsif k == 'id' && !v.strip.empty?
|
407
413
|
" ##{v}"
|
408
414
|
else
|
409
415
|
" #{k}=\"#{v.to_s}\""
|