redcarpet-abbreviations 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4882809ef4ce82e8cad61c1089ff79d9b31b321
4
- data.tar.gz: 535244a1de7a5dde8c6ec838c794270e30e6d164
3
+ metadata.gz: 43216faec85094cfa38a56fe5d7cedb45afe74dc
4
+ data.tar.gz: b17879213e5039b2ba9d345d5976f12b47aafe2d
5
5
  SHA512:
6
- metadata.gz: 90dc5b65b3d4304df9e257077738659ce607fde6dce5e0de294e4d03accb3ea3209915d5d87104313a709c7559a0a01c12152ef5fd5162df0b3e812bf79f10f2
7
- data.tar.gz: 4a97381b9f53c8a2f1d8f6fa5e2e8fc81fceb3725ca7a0b2dd1bbe79a301957fda9ecaa10c64a98ea45f4d5b4dcba18e55d5bb7a820215675f543d723ebf6775
6
+ metadata.gz: 087e65a44ec1b8439278e499cb3c4672d9d1aa6599fced44daa0f646095cb0247155b9d7d9a65b5a9cf6191408b8c95e801af0b8308dba0f4134dbe1d838aafd
7
+ data.tar.gz: 9bde13e55e7a568e2870441eedac8d71fd5d7e1e566979b48985ac06e2ef2479305aaeda0a8747862de2b76783ec06fe27786117e598136368c2c0359cded373
@@ -1,5 +1,5 @@
1
1
  module Redcarpet
2
2
  module Abbreviations
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -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(/^\*\[([A-Z]+)\]: (.+)$/)
8
+ abbreviations = document.scan(REGEXP)
7
9
  abbreviations = Hash[*abbreviations.flatten]
8
10
 
9
11
  if abbreviations.any?
10
- document.gsub!(/^\*\[([A-Z]+)\]: (.+)$/, "")
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=\"You Only Live Once\">YOLO</abbr>
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.1
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-01-08 00:00:00.000000000 Z
11
+ date: 2015-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler