markitdown 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -0
- data/lib/markitdown.rb +20 -8
- data/lib/markitdown/version.rb +1 -1
- data/spec/asmartbear.markdown +1 -1
- data/spec/doc.markdown +2 -2
- data/spec/table.markdown +2 -2
- data/spec/table2.markdown +2 -2
- data/spec/tag_spec.rb +47 -6
- metadata +4 -4
data/README.md
CHANGED
@@ -11,6 +11,10 @@ Markitdown is a Ruby library that converts HTML to Markdown. It's powered by Nok
|
|
11
11
|
* Code (inline and blocks)
|
12
12
|
* Definition lists
|
13
13
|
* Tables
|
14
|
+
* Underlines
|
15
|
+
* Strikethroughs (strike tag)
|
16
|
+
* Highlights (mark tag)
|
17
|
+
* Superscripts (sup tag)
|
14
18
|
|
15
19
|
As well as other tags.
|
16
20
|
|
data/lib/markitdown.rb
CHANGED
@@ -72,17 +72,29 @@ module Markitdown
|
|
72
72
|
when "br"
|
73
73
|
results << self.newline(pre, nil, 2)
|
74
74
|
when "em"
|
75
|
-
results << "
|
76
|
-
after = "END_TAG(
|
75
|
+
results << " *"
|
76
|
+
after = "END_TAG(*) "
|
77
77
|
when "i"
|
78
|
-
results << "
|
79
|
-
after = "END_TAG(
|
78
|
+
results << " *"
|
79
|
+
after = "END_TAG(*) "
|
80
80
|
when "strong"
|
81
|
-
results << "
|
82
|
-
after = "END_TAG(
|
81
|
+
results << " __"
|
82
|
+
after = "END_TAG(__) "
|
83
83
|
when "b"
|
84
|
-
results << "
|
85
|
-
after = "END_TAG(
|
84
|
+
results << " __"
|
85
|
+
after = "END_TAG(__) "
|
86
|
+
when "u"
|
87
|
+
results << " _"
|
88
|
+
after = "END_TAG(_) "
|
89
|
+
when "strike"
|
90
|
+
results << " ~~"
|
91
|
+
after = "END_TAG(~~) "
|
92
|
+
when "mark"
|
93
|
+
results << " =="
|
94
|
+
after = "END_TAG(==) "
|
95
|
+
when "sup"
|
96
|
+
results << "^("
|
97
|
+
after = "END_TAG(\)) "
|
86
98
|
when "blockquote"
|
87
99
|
results << "\n\n"
|
88
100
|
results << pre
|
data/lib/markitdown/version.rb
CHANGED
data/spec/asmartbear.markdown
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
>
|
4
4
|
>
|
5
|
-
> Try to avoid using vague words like "one" or "it" to describe an issue. For example:
|
5
|
+
> Try to avoid using vague words like "one" or "it" to describe an issue. For example: *"When I opened the document, the content was askew. When I tried to print the document, the printer jammed up. __It__ cannot blow up like that!"* In the last sentence of this example, are you complaining about the document or the printer? It's not really clear. So I would repeat myself even at the risk of sounding redundant. It's better to be redundant and clear than to leave the other person wondering.
|
6
6
|
>
|
7
7
|
>
|
8
8
|
>
|
data/spec/doc.markdown
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Main Header
|
4
4
|
|
5
|
-
This
|
5
|
+
This *is* a __test__. It includes a [link](http://www.google.com) as well as an image 
|
6
6
|
|
7
7
|
* bullet 1
|
8
8
|
* bullet 2
|
@@ -38,5 +38,5 @@ simple
|
|
38
38
|
: This is a simple term and a simple definition
|
39
39
|
complicated term
|
40
40
|
: This is a complicated term with a multi-line definition
|
41
|
-
: The
|
41
|
+
: The __second definition__ has a some __bold__ terms
|
42
42
|
|
data/spec/table.markdown
CHANGED
@@ -12,8 +12,8 @@ This [announcement](http://www.google.com) would be followed by instructions.
|
|
12
12
|
|---|---|---|---|
|
13
13
|
|This|is|a|
|
14
14
|
|This|is|a|[announcement](http://www.google.com)|
|
15
|
-
|This|is|a
|
16
|
-
|This|is|a
|
15
|
+
|This|is|a|*table*|
|
16
|
+
|This|is|a|__table__|
|
17
17
|
|This|is|a|table|
|
18
18
|
|This|is|a|table|
|
19
19
|
|
data/spec/table2.markdown
CHANGED
@@ -12,8 +12,8 @@ This [announcement](http://www.google.com) would be followed by instructions.
|
|
12
12
|
|---|---|---|---|
|
13
13
|
|This|is|a|
|
14
14
|
|This|is|a|[announcement](http://www.google.com)|
|
15
|
-
|This|is|a
|
16
|
-
|This|is|a
|
15
|
+
|This|is|a|*table*|
|
16
|
+
|This|is|a|__table__|
|
17
17
|
|This|is|a|table|
|
18
18
|
|This|is|a|table|
|
19
19
|
|
data/spec/tag_spec.rb
CHANGED
@@ -77,7 +77,7 @@ describe Markitdown do
|
|
77
77
|
let(:html) { "<em>emphasis added</em>" }
|
78
78
|
|
79
79
|
it "should return valid markdown" do
|
80
|
-
Markitdown.from_html(html).should == "
|
80
|
+
Markitdown.from_html(html).should == " *emphasis added* "
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -85,7 +85,7 @@ describe Markitdown do
|
|
85
85
|
let(:html) { "<i>italics added</i>" }
|
86
86
|
|
87
87
|
it "should return valid markdown" do
|
88
|
-
Markitdown.from_html(html).should == "
|
88
|
+
Markitdown.from_html(html).should == " *italics added* "
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -93,7 +93,7 @@ describe Markitdown do
|
|
93
93
|
let(:html) { "<strong>strong added</strong>" }
|
94
94
|
|
95
95
|
it "should return valid markdown" do
|
96
|
-
Markitdown.from_html(html).should == "
|
96
|
+
Markitdown.from_html(html).should == " __strong added__ "
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -101,7 +101,7 @@ describe Markitdown do
|
|
101
101
|
let(:html) { "<b>bold added</b>" }
|
102
102
|
|
103
103
|
it "should return valid markdown" do
|
104
|
-
Markitdown.from_html(html).should == "
|
104
|
+
Markitdown.from_html(html).should == " __bold added__ "
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -109,7 +109,7 @@ describe Markitdown do
|
|
109
109
|
let(:html) { "<html><b>bold added</b>.</html>" }
|
110
110
|
|
111
111
|
it "should return valid markdown without a space" do
|
112
|
-
Markitdown.from_html(html).should == "
|
112
|
+
Markitdown.from_html(html).should == " __bold added__."
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -117,7 +117,48 @@ describe Markitdown do
|
|
117
117
|
let(:html) { "<html><em>emphasis added</em>?</html>" }
|
118
118
|
|
119
119
|
it "should return valid markdown without a space" do
|
120
|
-
Markitdown.from_html(html).should == "
|
120
|
+
Markitdown.from_html(html).should == " *emphasis added*?"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "When parsing an underlined element that's followed by a punctuation" do
|
125
|
+
let(:html) { "<html><u>underline added</u>.</html>" }
|
126
|
+
|
127
|
+
it "should return valid markdown without a space" do
|
128
|
+
Markitdown.from_html(html).should == " _underline added_."
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "When parsing an strikethrough element that's followed by a punctuation" do
|
133
|
+
let(:html) { "<html><strike>strikethrough added</strike>.</html>" }
|
134
|
+
|
135
|
+
it "should return valid markdown without a space" do
|
136
|
+
Markitdown.from_html(html).should == " ~~strikethrough added~~."
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "When parsing an highlight element that's followed by a punctuation" do
|
141
|
+
let(:html) { "<html><mark>highlight added</mark>.</html>" }
|
142
|
+
|
143
|
+
it "should return valid markdown without a space" do
|
144
|
+
Markitdown.from_html(html).should == " ==highlight added==."
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "When parsing a superscript element with no spaces" do
|
149
|
+
let(:html) { "<html>2<sup>nd</sup>.</html>" }
|
150
|
+
|
151
|
+
it "should return valid markdown without spaces" do
|
152
|
+
Markitdown.from_html(html).should == "2^(nd)."
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "When parsing a superscript element with spaces" do
|
157
|
+
let(:html) { "<html>This <sup>is a</sup> test</html>" }
|
158
|
+
|
159
|
+
it "should return valid markdown with spaces" do
|
160
|
+
pending "Still need to figure out leading spaces for <sup> elements"
|
161
|
+
Markitdown.from_html(html).should == "This ^(is a) test"
|
121
162
|
end
|
122
163
|
end
|
123
164
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markitdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash:
|
106
|
+
hash: 4208653128680196527
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash:
|
115
|
+
hash: 4208653128680196527
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
118
|
rubygems_version: 1.8.23
|