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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f378dd22e8df8783e44b2c4bb1a8684633803a68
4
- data.tar.gz: cfcc3fbe7e81ccd0caba7faa3331fceb44a76816
3
+ metadata.gz: d1b7233d3c397aa996268f8b85551e98b21ca7bf
4
+ data.tar.gz: ca4a64a6d88b53ea915713cbd59c4ad67207f3a1
5
5
  SHA512:
6
- metadata.gz: 6be939fb9b4107b94999da64d2c25e7928b2c185a4b536a2e7b89e9112c341f43fbca68d3157f03b1e6d796c1bbb550d6d08d251c34f918897009f3a46795ecb
7
- data.tar.gz: 5bdcd7f41ab34656a243be7051beb12bdd67fa8432aed80dbd7d85793a96883877bb5992124ee15469fa2722c1789fae028822f256c070469a219986fc709cb5
6
+ metadata.gz: 1337a3452fba6d10d81c5e7738e020db7e7797e67d94a0403f24a0ab2b6e1900c3bfb1325cb953646d9e0c00c9c852405526ae538f56706250f57080040c8ec1
7
+ data.tar.gz: d1dffa61c7de3df835358fcfb2baf784767d3db8ce865d92dc854a218a30334bedc981bfbbc2f9ed7748d58019244e31a6d84b5d677c2f6fc8903306f203faed
@@ -2,7 +2,7 @@
2
2
  class MMarkdown
3
3
  VERSION_MAJOR = 0
4
4
  VERSION_MINOR = 0
5
- VERSION_REVISION = 3
5
+ VERSION_REVISION = 4
6
6
 
7
7
  VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_REVISION}"
8
8
  end
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: true,
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 = renderer.new(render_extensions)
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
@@ -77,4 +77,3 @@ a.reduce(0, :+)
77
77
  <h3 id="link">Link</h3>
78
78
 
79
79
  <p><a href="http://google.com">google</a></p>
80
-
@@ -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.3
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-01 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet