markdown_parser 0.1.0.alpha1 → 0.1.0.alpha2
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.
- checksums.yaml +4 -4
- data/lib/markdown_parser/inline_style.rb +4 -4
- data/lib/markdown_parser.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6df1ca8cb87ff8d3a97c3d660f6e996eaf0140c8c91e3bea3bce9b2a1e2593e5
|
4
|
+
data.tar.gz: 96bf9ddac5b3e5b40a72b87f73a2f9012f2f95014a72f2dc3d6536ead2617da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7389c8df6850c428df77ccfac7967345dfdaaf3119bf6af787def8cccee1024482a057e3a36cee77b243e2c20b56bf86bd8c8150c1586375c8ff20963ff42ff6
|
7
|
+
data.tar.gz: d62a260ee4bc0a4ca5ee7d82d722d93111817e54ce8a4c07ed3501e14fafa0c66974196d8ac5e366fec6adac8066eb3057681505fad7bf2408790efe22cce0ee
|
@@ -5,7 +5,7 @@ module MarkdownParser
|
|
5
5
|
apply_italics(line)
|
6
6
|
apply_code(line)
|
7
7
|
apply_link(line)
|
8
|
-
|
8
|
+
apply_image(line)
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.apply_bold(line)
|
@@ -23,14 +23,14 @@ module MarkdownParser
|
|
23
23
|
line.gsub!(/`(?<word>[^`]*)`/, "<code>\\k<word></code>")
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.
|
26
|
+
def self.apply_image(line)
|
27
27
|
# [alt message](image_url)
|
28
28
|
line.gsub!(/!\[(?<alt>[^\]]*)\]\((?<link>[^\)]*)\)/, "<img src='\\k<link>' alt='\\k<alt>' />")
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.
|
31
|
+
def self.apply_link(line)
|
32
32
|
# [text](limk)
|
33
|
-
line.gsub!(/\[(?<text>[^\]]*)\]\((?<link>[^\)]*)\)/, "<a href='\\k<link>'>\\k<text></a>")
|
33
|
+
line.gsub!(/\[(?<text>[^\]]*)\]\((?<link>[^\)]*)\)/, "<a href='\\k<link>' target='_blank'>\\k<text></a>")
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
data/lib/markdown_parser.rb
CHANGED
@@ -7,14 +7,14 @@ module MarkdownParser
|
|
7
7
|
|
8
8
|
def self.parse(plain_text)
|
9
9
|
text = EscapeUtils.escape_html(plain_text)
|
10
|
-
"<div class='markdown-parser'
|
10
|
+
"<div class='markdown-parser'>" + markdown_to_html(text) + "</div>"
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.markdown_to_html(text)
|
14
14
|
lines = text.split("\n")
|
15
15
|
lines << ''
|
16
16
|
lines.map do |line|
|
17
|
-
apply_rules(line)
|
17
|
+
apply_rules(EscapeUtils.escape_html line)
|
18
18
|
end.join
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Villagrana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem that parses your markdown to html
|
14
14
|
email: 'ricardovillagranal@gmail.com '
|