unmarkdown 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.markdown +7 -1
- data/lib/unmarkdown/parser.rb +2 -2
- data/lib/unmarkdown/version.rb +1 -1
- 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: e7f0219af3b996010a94e56ffa4e2a04c76b9ee8
|
4
|
+
data.tar.gz: 40427768c3886271fc1f9a04a626c5bb3495a55f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3153b363d7b3368a46a1da6c24882144200a3ddef1faf51519947736885a27fb732501bc627f75edfb87212be99b00901734d7c43ea78c91796095ab77e785f3
|
7
|
+
data.tar.gz: 32f0b4ed7937efb8151de4ab595ed348f449197256b379143713b403bd41bc6d094eff7d0a74fa826151b64b68d2957e601d327ef6bc430a8e5a38c7bf84051d
|
data/Readme.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Convert HTML to Markdown with Ruby.
|
4
4
|
|
5
|
+
There are several libraries that solve this, but Unmarkdown is simple. It's only [150 lines](lib/unmarkdown/parser.rb) and handles everything I threw at it with no problem. The other libraries I tried either didn't do recursion correctly or were missing some Markdown extensions I needed. Both were hard to change, so I just whipped this up in a few hours.
|
6
|
+
|
7
|
+
Enjoy!
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -24,7 +28,7 @@ Or install it yourself as:
|
|
24
28
|
markdown = Unmarkdown.parse('Some <strong>HTML</strong>')
|
25
29
|
#=> Some **HTML**
|
26
30
|
|
27
|
-
markdown = Unmarkdown.parse('My website is http://soff.es', autolink: true
|
31
|
+
markdown = Unmarkdown.parse('My website is http://soff.es', autolink: true)
|
28
32
|
#=> My website is <a href="http://soff.es">http://soff.es</a>
|
29
33
|
```
|
30
34
|
|
@@ -49,6 +53,8 @@ For tags that aren't supported, their content will be added to the output. Basic
|
|
49
53
|
|
50
54
|
### Options
|
51
55
|
|
56
|
+
All of the options default to `false`. If you'd like to turn additional things on, pass a hash with symbols as the second argument to `Unmarkdown.parse` (see example above).
|
57
|
+
|
52
58
|
* `fenced_code_blocks` — Uses three backticks before and after instead of four spaces before each line
|
53
59
|
* `allow_scripts` — By default, script tags are removed. If you set this option to `true` their original HTML will be included in the output
|
54
60
|
* `underline_headers` — By default number signs are added before headers. If you turn this option on, it will use equal signs for h1's or hypens for h2's and the reset will remain number signs.
|
data/lib/unmarkdown/parser.rb
CHANGED
@@ -93,7 +93,7 @@ module Unmarkdown
|
|
93
93
|
when 'hr'
|
94
94
|
output << "---\n\n"
|
95
95
|
when 'a'
|
96
|
-
output << "[#{parse_content(node)}](#{node['href']
|
96
|
+
output << "[#{parse_content(node)}](#{node['href']}#{build_title(node)})"
|
97
97
|
when 'i', 'em'
|
98
98
|
output << "*#{parse_content(node)}*"
|
99
99
|
when 'b', 'strong'
|
@@ -105,7 +105,7 @@ module Unmarkdown
|
|
105
105
|
when 'code'
|
106
106
|
output << "`#{parse_content(node)}`"
|
107
107
|
when 'img'
|
108
|
-
output << "![#{node['alt']}](#{node['src']
|
108
|
+
output << "![#{node['alt']}](#{node['src']}#{build_title(node)})"
|
109
109
|
when 'text'
|
110
110
|
content = parse_content(node)
|
111
111
|
|
data/lib/unmarkdown/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unmarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Soffes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|