mmarkdown 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +1 -1
- data/Readme.md +38 -0
- data/bin/mmarkdown +51 -2
- data/lib/mmarkdown/version.rb +1 -1
- data/test/test.html +63 -1
- data/test/test.md +36 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f378dd22e8df8783e44b2c4bb1a8684633803a68
|
4
|
+
data.tar.gz: cfcc3fbe7e81ccd0caba7faa3331fceb44a76816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6be939fb9b4107b94999da64d2c25e7928b2c185a4b536a2e7b89e9112c341f43fbca68d3157f03b1e6d796c1bbb550d6d08d251c34f918897009f3a46795ecb
|
7
|
+
data.tar.gz: 5bdcd7f41ab34656a243be7051beb12bdd67fa8432aed80dbd7d85793a96883877bb5992124ee15469fa2722c1789fae028822f256c070469a219986fc709cb5
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ begin
|
|
21
21
|
gem.version = MMarkdown::VERSION
|
22
22
|
gem.files = `git ls-files`.split("\n")
|
23
23
|
gem.test_files = `git ls-files -- test/*`.split("\n")
|
24
|
-
gem.licenses = ["
|
24
|
+
gem.licenses = ["MIT License"]
|
25
25
|
gem.homepage = "http://github.com/tanahiro/mmarkdown"
|
26
26
|
gem.add_dependency("redcarpet", "~> 3.0")
|
27
27
|
gem.add_dependency("math_ml", "~> 0.14")
|
data/Readme.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# MMarkdown
|
2
|
+
Markdown with math equations
|
3
|
+
|
4
|
+
## Install
|
5
|
+
gem install mmarkdown
|
6
|
+
|
7
|
+
## How to use
|
8
|
+
mmarkdown <file.md>
|
9
|
+
|
10
|
+
----
|
11
|
+
## Author
|
12
|
+
Hiroyuki Tanaka
|
13
|
+
|
14
|
+
## License
|
15
|
+
**The MIT License (MIT)**
|
16
|
+
|
17
|
+
<http://opensource.org/licenses/MIT>
|
18
|
+
|
19
|
+
Copyright (c) 2014 Hiroyuki Tanaka
|
20
|
+
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
22
|
+
copy of this software and associated documentation files (the "Software"),
|
23
|
+
to deal in the Software without restriction, including without limitation
|
24
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
25
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
26
|
+
Software is furnished to do so, subject to the following conditions:
|
27
|
+
|
28
|
+
The above copyright notice and this permission notice shall be included in
|
29
|
+
all copies or substantial portions of the Software.
|
30
|
+
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
34
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
35
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
36
|
+
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
37
|
+
SOFTWARE.
|
38
|
+
|
data/bin/mmarkdown
CHANGED
@@ -2,19 +2,68 @@
|
|
2
2
|
#
|
3
3
|
#
|
4
4
|
|
5
|
+
require 'optparse'
|
6
|
+
|
5
7
|
root = "#{__dir__}/.."
|
6
8
|
require "#{root}/lib/mmarkdown"
|
7
9
|
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
option_parser = OptionParser.new {|opts|
|
13
|
+
Version = MMarkdown::VERSION
|
14
|
+
|
15
|
+
opts.banner = "Markdown with MathML\n"
|
16
|
+
opts.banner += " Usage: #{File.basename(__FILE__)} <file.md>"
|
17
|
+
|
18
|
+
opts.on("-o", "--output FILENAME", String, "Output file name") {|f|
|
19
|
+
options[:out_filename] = f
|
20
|
+
}
|
21
|
+
|
22
|
+
opts.on("--stdout", "Output to STDOUT") {
|
23
|
+
options[:stdout] = true
|
24
|
+
}
|
25
|
+
|
26
|
+
opts.on("-h", "--help", "Shows this message") {
|
27
|
+
puts opts
|
28
|
+
exit
|
29
|
+
}
|
30
|
+
}
|
31
|
+
option_parser.parse!
|
32
|
+
|
33
|
+
Help_message = option_parser.to_s
|
34
|
+
|
8
35
|
def usage
|
9
|
-
puts
|
36
|
+
puts Help_message
|
10
37
|
end
|
11
38
|
|
12
39
|
if ARGV.size != 1
|
13
40
|
usage
|
14
41
|
exit 0
|
42
|
+
else
|
43
|
+
in_filename = ARGV[0]
|
15
44
|
end
|
16
45
|
|
17
46
|
md_string = File.open(ARGV[0]).read
|
18
47
|
|
19
|
-
|
48
|
+
html_string = MMarkdown.new(md_string).to_str
|
49
|
+
|
50
|
+
unless options[:stdout]
|
51
|
+
if options[:out_filename]
|
52
|
+
out_filename = options[:out_filename]
|
53
|
+
else
|
54
|
+
if in_filename =~ /\.md$/
|
55
|
+
out_filename = in_filename.gsub(/\.md$/, ".html")
|
56
|
+
elsif in_filename =~ /\.mmd$/
|
57
|
+
out_filename = in_filename.gsub(/\.mmd$/, ".html")
|
58
|
+
elsif in_filename =~ /\.markdown$/
|
59
|
+
out_filename = in_filename.gsub(/\.markdown$/, ".html")
|
60
|
+
else
|
61
|
+
out_filename = in_filename + ".html"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
File.open(out_filename, "w").write(html_string)
|
66
|
+
else
|
67
|
+
puts html_string
|
68
|
+
end
|
20
69
|
|
data/lib/mmarkdown/version.rb
CHANGED
data/test/test.html
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
<h1 id="
|
1
|
+
<h1 id="test">Test</h1>
|
2
2
|
|
3
3
|
<p>This is a test data</p>
|
4
4
|
|
5
|
+
<h2 id="equation">Equation</h2>
|
6
|
+
|
5
7
|
<p>This is an equation, <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><msup><mi>x</mi><mn>2</mn></msup><mo stretchy='false'>+</mo><msup><mi>y</mi><mn>2</mn></msup><mo stretchy='false'>=</mo><msup><mi>r</mi><mn>2</mn></msup></math></p>
|
6
8
|
|
7
9
|
<p>And this is the second
|
@@ -16,3 +18,63 @@
|
|
16
18
|
|
17
19
|
<p>vector:
|
18
20
|
<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mover><mrow><mi>x</mi></mrow><mo>→</mo></mover><mo stretchy='false'>+</mo><mover><mrow><mi>y</mi></mrow><mo>→</mo></mover><mo stretchy='false'>=</mo><mover><mrow><mi>p</mi></mrow><mo>→</mo></mover></math></p>
|
21
|
+
|
22
|
+
<h2 id="markdown">Markdown</h2>
|
23
|
+
|
24
|
+
<p><em>italic</em></p>
|
25
|
+
|
26
|
+
<p><u>underline</u></p>
|
27
|
+
|
28
|
+
<p><strong>bold</strong></p>
|
29
|
+
|
30
|
+
<p><strong><em>bold italic</em></strong></p>
|
31
|
+
|
32
|
+
<h3 id="list">List</h3>
|
33
|
+
|
34
|
+
<ul>
|
35
|
+
<li>item1</li>
|
36
|
+
<li>item2
|
37
|
+
|
38
|
+
<ul>
|
39
|
+
<li>nested item2-1</li>
|
40
|
+
<li>nested item2-2</li>
|
41
|
+
</ul></li>
|
42
|
+
</ul>
|
43
|
+
|
44
|
+
<ol>
|
45
|
+
<li>item3</li>
|
46
|
+
<li>item4</li>
|
47
|
+
</ol>
|
48
|
+
|
49
|
+
<h3 id="quote">Quote</h3>
|
50
|
+
|
51
|
+
<blockquote>
|
52
|
+
<p>quote</p>
|
53
|
+
</blockquote>
|
54
|
+
|
55
|
+
<h3 id="table">Table</h3>
|
56
|
+
|
57
|
+
<table><thead>
|
58
|
+
<tr>
|
59
|
+
<th style="text-align: left">head1</th>
|
60
|
+
<th style="text-align: center">head2</th>
|
61
|
+
<th style="text-align: right">head3</th>
|
62
|
+
</tr>
|
63
|
+
</thead><tbody>
|
64
|
+
<tr>
|
65
|
+
<td style="text-align: left">item</td>
|
66
|
+
<td style="text-align: center">item</td>
|
67
|
+
<td style="text-align: right">item</td>
|
68
|
+
</tr>
|
69
|
+
</tbody></table>
|
70
|
+
|
71
|
+
<h3 id="syntax-highlight">Syntax highlight</h3>
|
72
|
+
|
73
|
+
<pre><code class="ruby">a = [1, 2, 3]
|
74
|
+
a.reduce(0, :+)
|
75
|
+
</code></pre>
|
76
|
+
|
77
|
+
<h3 id="link">Link</h3>
|
78
|
+
|
79
|
+
<p><a href="http://google.com">google</a></p>
|
80
|
+
|
data/test/test.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
This is a test data
|
4
4
|
|
5
|
+
## Equation
|
5
6
|
This is an equation, \( x^2 + y^2 = r^2 \)
|
6
7
|
|
7
8
|
And this is the second
|
@@ -17,3 +18,38 @@ Same equation again \( \sin^2 \theta + \cos^2 \theta = 1 \).
|
|
17
18
|
vector:
|
18
19
|
\( \vec{x} + \vec{y} = \vec{p} \)
|
19
20
|
|
21
|
+
## Markdown
|
22
|
+
*italic*
|
23
|
+
|
24
|
+
_underline_
|
25
|
+
|
26
|
+
**bold**
|
27
|
+
|
28
|
+
***bold italic***
|
29
|
+
|
30
|
+
### List
|
31
|
+
* item1
|
32
|
+
* item2
|
33
|
+
* nested item2-1
|
34
|
+
* nested item2-2
|
35
|
+
|
36
|
+
1. item3
|
37
|
+
2. item4
|
38
|
+
|
39
|
+
### Quote
|
40
|
+
> quote
|
41
|
+
|
42
|
+
### Table
|
43
|
+
|head1 | head2 | head3 |
|
44
|
+
|:-----|:-----:|------:|
|
45
|
+
|item | item | item |
|
46
|
+
|
47
|
+
### Syntax highlight
|
48
|
+
``` ruby
|
49
|
+
a = [1, 2, 3]
|
50
|
+
a.reduce(0, :+)
|
51
|
+
```
|
52
|
+
|
53
|
+
### Link
|
54
|
+
[google](http://google.com)
|
55
|
+
|
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.3
|
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-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- Rakefile
|
79
|
+
- Readme.md
|
79
80
|
- bin/mmarkdown
|
80
81
|
- lib/mmarkdown.rb
|
81
82
|
- lib/mmarkdown/version.rb
|
@@ -84,7 +85,7 @@ files:
|
|
84
85
|
- test/test_mmarkdown.rb
|
85
86
|
homepage: http://github.com/tanahiro/mmarkdown
|
86
87
|
licenses:
|
87
|
-
-
|
88
|
+
- MIT License
|
88
89
|
metadata: {}
|
89
90
|
post_install_message:
|
90
91
|
rdoc_options: []
|