redcarpet-abbreviations 0.0.1 → 0.1.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43216faec85094cfa38a56fe5d7cedb45afe74dc
|
4
|
+
data.tar.gz: b17879213e5039b2ba9d345d5976f12b47aafe2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 087e65a44ec1b8439278e499cb3c4672d9d1aa6599fced44daa0f646095cb0247155b9d7d9a65b5a9cf6191408b8c95e801af0b8308dba0f4134dbe1d838aafd
|
7
|
+
data.tar.gz: 9bde13e55e7a568e2870441eedac8d71fd5d7e1e566979b48985ac06e2ef2479305aaeda0a8747862de2b76783ec06fe27786117e598136368c2c0359cded373
|
@@ -2,12 +2,14 @@ module Redcarpet
|
|
2
2
|
module Render
|
3
3
|
module HTMLAbbreviations
|
4
4
|
|
5
|
+
REGEXP = /^\*\[([-A-Z]+)\]: (.+)$/
|
6
|
+
|
5
7
|
def preprocess(document)
|
6
|
-
abbreviations = document.scan(
|
8
|
+
abbreviations = document.scan(REGEXP)
|
7
9
|
abbreviations = Hash[*abbreviations.flatten]
|
8
10
|
|
9
11
|
if abbreviations.any?
|
10
|
-
document.gsub!(
|
12
|
+
document.gsub!(REGEXP, "")
|
11
13
|
document.rstrip!
|
12
14
|
|
13
15
|
abbreviations.each do |key, value|
|
@@ -18,7 +18,19 @@ describe Redcarpet::Render::HTMLAbbreviations do
|
|
18
18
|
EOS
|
19
19
|
|
20
20
|
@renderer.new.preprocess(markdown).must_equal <<-EOS.strip_heredoc.chomp
|
21
|
-
<abbr title
|
21
|
+
<abbr title="You Only Live Once">YOLO</abbr>
|
22
|
+
EOS
|
23
|
+
end
|
24
|
+
|
25
|
+
it "converts hyphenated abbrevations to HTML" do
|
26
|
+
markdown = <<-EOS.strip_heredoc
|
27
|
+
JSON-P
|
28
|
+
|
29
|
+
*[JSON-P]: JSON with Padding
|
30
|
+
EOS
|
31
|
+
|
32
|
+
@renderer.new.preprocess(markdown).must_equal <<-EOS.strip_heredoc.chomp
|
33
|
+
<abbr title="JSON with Padding">JSON-P</abbr>
|
22
34
|
EOS
|
23
35
|
end
|
24
36
|
|
@@ -38,9 +50,14 @@ describe Redcarpet::Render::HTMLAbbreviations do
|
|
38
50
|
".FOO.".must_match @renderer.new.acronym_regexp("FOO")
|
39
51
|
end
|
40
52
|
|
53
|
+
it "matches an acronym with hyphens" do
|
54
|
+
"JSON-P".must_match @renderer.new.acronym_regexp("JSON-P")
|
55
|
+
end
|
56
|
+
|
41
57
|
it "doesn't match an acronym in the middle of a word" do
|
42
58
|
"YOLOFOOYOLO".wont_match @renderer.new.acronym_regexp("FOO")
|
43
59
|
end
|
60
|
+
|
44
61
|
end
|
45
62
|
|
46
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet-abbreviations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Weiss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|