beardown 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/beardown/blocks/head.rb +1 -1
- data/lib/beardown/document.rb +2 -2
- data/lib/beardown/spans/hashtag.rb +26 -6
- data/lib/beardown/version.rb +1 -1
- 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: a3a96777ab347a7fb7b5d93bebd441c889dc6000bc46bff99bce5fd7b7ceaee7
|
4
|
+
data.tar.gz: cff24bcc9ad8b5d4eed7a561a9f9006800538f06809f2fd13c932ed960c24aef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c11e20a9873bcb194310629f58d692b20006f66bf764900ce933b2013766fea25e3d96beb378d8ac39f52e4d92e9749fa52e490eea0c043f34fa0299479fd36b
|
7
|
+
data.tar.gz: f228ac926db0d7a7f04a495f6c35179c3f8788adb41a97b2faa022d6c79368c2bceb3ba05393248a9b3df8526eec45378fd4ca3606b682728bf5842f70b96eee
|
data/lib/beardown/blocks/head.rb
CHANGED
data/lib/beardown/document.rb
CHANGED
@@ -4,7 +4,7 @@ module Beardown
|
|
4
4
|
class Document
|
5
5
|
|
6
6
|
def initialize(text)
|
7
|
-
@text = text
|
7
|
+
@text = text.gsub(/(?<!^)>/, ">").gsub("<", "<")
|
8
8
|
|
9
9
|
# These orders are important
|
10
10
|
@blocks = [:head, :line_separator, :list_unordered, :list_ordered,
|
@@ -12,7 +12,7 @@ module Beardown
|
|
12
12
|
@spans = [:codespan, :hashtag_full, :hashtag_full_nospace, :hashtag, :linkpost, :linkurl,
|
13
13
|
:bold, :italic, :underline, :strike, :mark_nospace, :mark]
|
14
14
|
|
15
|
-
@extensions =
|
15
|
+
@extensions = []
|
16
16
|
@title = String.new
|
17
17
|
@tags = Array.new
|
18
18
|
|
@@ -6,7 +6,7 @@ module Beardown
|
|
6
6
|
REGEXP_HASHTAG_FULL_NOSPACE = /#([^#^\s]+)#/
|
7
7
|
REGEXP_HASHTAG = /#([^#\s\,]+)/
|
8
8
|
|
9
|
-
["
|
9
|
+
["_full", "_full_nospace"].each do |attr|
|
10
10
|
define_method :"scan_hashtag#{attr}" do |s|
|
11
11
|
tag = s[1]
|
12
12
|
send "convert_hashtag#{attr}", tag
|
@@ -15,14 +15,34 @@ module Beardown
|
|
15
15
|
define_method :"convert_hashtag#{attr}" do |tag|
|
16
16
|
tag = tag.downcase
|
17
17
|
render_hashtag tag
|
18
|
-
|
19
|
-
when "" then ""
|
20
|
-
else "#"
|
21
|
-
end
|
22
|
-
%(<a href="../tag/#{tag}/" class="hashtag">##{tag+sym}</a>)
|
18
|
+
%(<a href="../tag/#{tag}/" class="hashtag">##{tag}#</a>)
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
22
|
+
def scan_hashtag(s)
|
23
|
+
tag = s[1]
|
24
|
+
if check_color(tag)
|
25
|
+
convert_hashcolor tag
|
26
|
+
else
|
27
|
+
convert_hashtag tag
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def convert_hashtag(tag)
|
32
|
+
tag = tag.downcase
|
33
|
+
render_hashtag tag
|
34
|
+
%(<a href="../tag/#{tag}/" class="hashtag">##{tag}</a>)
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_color(tag)
|
38
|
+
return false if(tag.length!=6)
|
39
|
+
return tag.match? /[0-9a-fA-F]{6}/
|
40
|
+
end
|
41
|
+
|
42
|
+
def convert_hashcolor(hex)
|
43
|
+
%(<span class='color-preview' style='background-color:##{hex}'></span><span class='color-code'><span class='color-hash'>#</span>#{hex}</span></span>)
|
44
|
+
end
|
45
|
+
|
26
46
|
def render_hashtag(tag)
|
27
47
|
tag = tag.downcase
|
28
48
|
tags = tag.split "/"
|
data/lib/beardown/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beardown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wuusn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|