mmarkdown 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mmarkdown/version.rb +1 -1
- data/lib/mmarkdown.rb +12 -7
- data/test/test.html +0 -1
- data/test/test_mmarkdown.rb +43 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b7233d3c397aa996268f8b85551e98b21ca7bf
|
4
|
+
data.tar.gz: ca4a64a6d88b53ea915713cbd59c4ad67207f3a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1337a3452fba6d10d81c5e7738e020db7e7797e67d94a0403f24a0ab2b6e1900c3bfb1325cb953646d9e0c00c9c852405526ae538f56706250f57080040c8ec1
|
7
|
+
data.tar.gz: d1dffa61c7de3df835358fcfb2baf784767d3db8ce865d92dc854a218a30334bedc981bfbbc2f9ed7748d58019244e31a6d84b5d677c2f6fc8903306f203faed
|
data/lib/mmarkdown/version.rb
CHANGED
data/lib/mmarkdown.rb
CHANGED
@@ -4,26 +4,24 @@ require "redcarpet"
|
|
4
4
|
require "#{__dir__}/mmarkdown/version"
|
5
5
|
|
6
6
|
class MMarkdown
|
7
|
-
|
8
7
|
def initialize md_string
|
9
|
-
md_mathml = equations_to_mathml(md_string)
|
10
|
-
|
11
|
-
renderer = Redcarpet::Render::HTML
|
8
|
+
@md_mathml = equations_to_mathml(md_string)
|
12
9
|
|
13
10
|
parse_extensions = {no_intra_emphasis: true,
|
14
11
|
tables: true,
|
15
12
|
fenced_code_blocks: true,
|
16
13
|
autolink: true,
|
17
|
-
disable_indented_code_blocks:
|
14
|
+
disable_indented_code_blocks: false,
|
15
|
+
superscript: true,
|
18
16
|
underline: true,
|
19
17
|
highlight: true,
|
20
18
|
footnotes: true}
|
21
19
|
|
22
20
|
render_extensions = {with_toc_data: true}
|
23
21
|
|
24
|
-
render =
|
22
|
+
render = Redcarpet::Render::HTML.new(render_extensions)
|
25
23
|
|
26
|
-
@md = Redcarpet::Markdown.new(render, parse_extensions).render(md_mathml)
|
24
|
+
@md = Redcarpet::Markdown.new(render, parse_extensions).render(@md_mathml)
|
27
25
|
end
|
28
26
|
|
29
27
|
def equations_to_mathml string
|
@@ -41,6 +39,13 @@ class MMarkdown
|
|
41
39
|
return string_mathml
|
42
40
|
end
|
43
41
|
|
42
|
+
def toc_html nesting_level = 3
|
43
|
+
render_toc = Redcarpet::Render::HTML_TOC.new
|
44
|
+
toc_html = Redcarpet::Markdown.new(render_toc).render(@md_mathml)
|
45
|
+
|
46
|
+
return toc_html
|
47
|
+
end
|
48
|
+
|
44
49
|
def to_str
|
45
50
|
@md.to_str
|
46
51
|
end
|
data/test/test.html
CHANGED
data/test/test_mmarkdown.rb
CHANGED
@@ -13,5 +13,48 @@ class MMarkdownTest < MiniTest::Test
|
|
13
13
|
assert_equal(Nokogiri::HTML::DocumentFragment.parse(html_expected).to_html,
|
14
14
|
Nokogiri::HTML::DocumentFragment.parse(html_actual).to_html)
|
15
15
|
end
|
16
|
+
|
17
|
+
def test_toc_html
|
18
|
+
md_string = File.open("#{__dir__}/test.md").read
|
19
|
+
|
20
|
+
mmarkdown = MMarkdown.new(md_string)
|
21
|
+
toc_actual = mmarkdown.toc_html
|
22
|
+
|
23
|
+
toc_expected = <<EOF
|
24
|
+
<ul>
|
25
|
+
<li>
|
26
|
+
<a href="#test">Test</a>
|
27
|
+
<ul>
|
28
|
+
<li>
|
29
|
+
<a href="#equation">Equation</a>
|
30
|
+
</li>
|
31
|
+
<li>
|
32
|
+
<a href="#markdown">Markdown</a>
|
33
|
+
<ul>
|
34
|
+
<li>
|
35
|
+
<a href="#list">List</a>
|
36
|
+
</li>
|
37
|
+
<li>
|
38
|
+
<a href="#quote">Quote</a>
|
39
|
+
</li>
|
40
|
+
<li>
|
41
|
+
<a href="#table">Table</a>
|
42
|
+
</li>
|
43
|
+
<li>
|
44
|
+
<a href="#syntax-highlight">Syntax highlight</a>
|
45
|
+
</li>
|
46
|
+
<li>
|
47
|
+
<a href="#link">Link</a>
|
48
|
+
</li>
|
49
|
+
</ul>
|
50
|
+
</li>
|
51
|
+
</ul>
|
52
|
+
</li>
|
53
|
+
</ul>
|
54
|
+
EOF
|
55
|
+
|
56
|
+
assert_equal(toc_expected, toc_actual)
|
57
|
+
|
58
|
+
end
|
16
59
|
end
|
17
60
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroyuki Tanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|