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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 241cb8bce5c4963e0bfb4887d9475f82c7fdeb659b54d503b70918eb962d71d9
4
- data.tar.gz: eef7af6534abf40446ac1986598708c84eb386768cc41197ea376ceeea7b7295
3
+ metadata.gz: a3a96777ab347a7fb7b5d93bebd441c889dc6000bc46bff99bce5fd7b7ceaee7
4
+ data.tar.gz: cff24bcc9ad8b5d4eed7a561a9f9006800538f06809f2fd13c932ed960c24aef
5
5
  SHA512:
6
- metadata.gz: 4dcd7c0e8bcaf56fed1f720bb356bb1d964165be5c497505493689af10df40106389f3de97083357dcfaa61343b270aea9740a80dcfe6fbdbf114243cada781b
7
- data.tar.gz: ac93399ee689d413cd10190a265f2bb716c8d0c009896585295915d62c80b8d0b35da9f490648b2798cfec83967fd4a5dd3b5d45869e3895f96b10e5a03dfd7f
6
+ metadata.gz: c11e20a9873bcb194310629f58d692b20006f66bf764900ce933b2013766fea25e3d96beb378d8ac39f52e4d92e9749fa52e490eea0c043f34fa0299479fd36b
7
+ data.tar.gz: f228ac926db0d7a7f04a495f6c35179c3f8788adb41a97b2faa022d6c79368c2bceb3ba05393248a9b3df8526eec45378fd4ca3606b682728bf5842f70b96eee
@@ -10,7 +10,7 @@ module Beardown
10
10
  end
11
11
 
12
12
  def render_head(id, content)
13
- @title << content if id==1
13
+ @title << content if id==1&&@title.empty?
14
14
  end
15
15
 
16
16
  def convert_head(id,content)
@@ -4,7 +4,7 @@ module Beardown
4
4
  class Document
5
5
 
6
6
  def initialize(text)
7
- @text = text
7
+ @text = text.gsub(/(?<!^)>/, "&gt").gsub("<", "&lt")
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 = Array.new
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
- ["", "_full", "_full_nospace"].each do |attr|
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
- sym = case attr
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 "/"
@@ -1,3 +1,3 @@
1
1
  module Beardown
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-03-31 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler