slack_markdown 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/.rubocop.yml +32 -0
- data/.rubocop_todo.yml +38 -0
- data/.travis.yml +13 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +2 -0
- data/Rakefile +4 -1
- data/lib/slack_markdown.rb +0 -0
- data/lib/slack_markdown/filters/bold_filter.rb +1 -1
- data/lib/slack_markdown/filters/code_filter.rb +1 -1
- data/lib/slack_markdown/filters/convert_filter.rb +7 -7
- data/lib/slack_markdown/filters/emoji_filter.rb +0 -1
- data/lib/slack_markdown/filters/ignorable_ancestor_tags.rb +0 -0
- data/lib/slack_markdown/filters/italic_filter.rb +1 -1
- data/lib/slack_markdown/filters/line_break_filter.rb +1 -1
- data/lib/slack_markdown/filters/multiple_code_filter.rb +1 -1
- data/lib/slack_markdown/filters/multiple_quote_filter.rb +1 -1
- data/lib/slack_markdown/filters/quote_filter.rb +11 -1
- data/lib/slack_markdown/processor.rb +1 -1
- data/lib/slack_markdown/version.rb +1 -1
- data/slack_markdown.gemspec +7 -6
- metadata +39 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 016d968b230dd5f9dacc5eed9861e709c05d6828dc3c2a8319e2e6ed3565ebe0
|
4
|
+
data.tar.gz: 4514bd3743a64de9358fca7184bd8230bd524fd5838cb83cf94074171007b7f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ba0c318dd04fbf67e3df50fe0d842f28cb14632c974cdff050a645fec11a1606a5b35c7afb3d6ccdc5ef7e43b15e6e0f8a65c81cceb8f00e0f994292e5551fc
|
7
|
+
data.tar.gz: 85f5dd26de3cd1f3d78f83886d1c9f769fe4c58bc56f338e1df951b0c200812686145776642c4f9c999de355262d7617e114e5ce70819f733ca10462fa46d02a
|
data/.gitignore
CHANGED
File without changes
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- tmp/**/*
|
4
|
+
- vendor/**/*
|
5
|
+
|
6
|
+
SpecialGlobalVars:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
AsciiComments:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
ClassLength:
|
13
|
+
Max: 200
|
14
|
+
|
15
|
+
Documentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
LineLength:
|
19
|
+
Max: 137
|
20
|
+
Exclude:
|
21
|
+
- spec/**/*
|
22
|
+
|
23
|
+
MethodLength:
|
24
|
+
Max: 39
|
25
|
+
|
26
|
+
PerlBackrefs:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
TrailingCommaInLiteral:
|
30
|
+
EnforcedStyleForMultiline: comma
|
31
|
+
|
32
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-05-29 14:43:54 +0900 using RuboCop version 0.40.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 38
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
Metrics/CyclomaticComplexity:
|
15
|
+
Max: 16
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
19
|
+
# URISchemes: http, https
|
20
|
+
Metrics/LineLength:
|
21
|
+
Max: 137
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Configuration parameters: CountComments.
|
25
|
+
Metrics/MethodLength:
|
26
|
+
Max: 39
|
27
|
+
|
28
|
+
# Offense count: 1
|
29
|
+
Metrics/PerceivedComplexity:
|
30
|
+
Max: 19
|
31
|
+
|
32
|
+
# Offense count: 1
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
35
|
+
# SupportedStyles: final_newline, final_blank_line
|
36
|
+
Style/TrailingBlankLines:
|
37
|
+
Exclude:
|
38
|
+
- 'spec/spec_helper.rb'
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/slack_markdown.rb
CHANGED
File without changes
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?('*')
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?('`')
|
@@ -8,7 +8,7 @@ module SlackMarkdown
|
|
8
8
|
# https://api.slack.com/docs/formatting
|
9
9
|
class ConvertFilter < ::HTML::Pipeline::TextFilter
|
10
10
|
def call
|
11
|
-
html = @text.gsub(/<([^>\|]+)(?:\|([^>]+))?>/) do |
|
11
|
+
html = @text.gsub(/<([^>\|]+)(?:\|([^>]+))?>/) do |_match|
|
12
12
|
link_data = $1
|
13
13
|
link_text = $2
|
14
14
|
create_link(link_data, link_text)
|
@@ -22,21 +22,21 @@ module SlackMarkdown
|
|
22
22
|
klass, link, text =
|
23
23
|
case data
|
24
24
|
when /\A#(C.+)\z/ # channel
|
25
|
-
channel =
|
25
|
+
channel = context.include?(:on_slack_channel_id) ? context[:on_slack_channel_id].call($1) : nil
|
26
26
|
if channel
|
27
27
|
['channel', channel[:url], "##{channel[:text]}"]
|
28
28
|
else
|
29
29
|
['channel', data, data]
|
30
30
|
end
|
31
31
|
when /\A@((?:U|B).+)/ # user or bot
|
32
|
-
user =
|
32
|
+
user = context.include?(:on_slack_user_id) ? context[:on_slack_user_id].call($1) : nil
|
33
33
|
if user
|
34
34
|
['mention', user[:url], "@#{user[:text]}"]
|
35
35
|
else
|
36
36
|
['mention', nil, data]
|
37
37
|
end
|
38
38
|
when /\A@(.+)/ # user name
|
39
|
-
user =
|
39
|
+
user = context.include?(:on_slack_user_name) ? context[:on_slack_user_name].call($1) : nil
|
40
40
|
if user
|
41
41
|
['mention', user[:url], "@#{user[:text]}"]
|
42
42
|
else
|
@@ -50,10 +50,10 @@ module SlackMarkdown
|
|
50
50
|
|
51
51
|
if link
|
52
52
|
escaped_link =
|
53
|
-
if
|
54
|
-
"#{EscapeUtils.escape_html
|
53
|
+
if context[:cushion_link] && link.match(%r{\A([A-Za-z0-9]+:)?//})
|
54
|
+
"#{EscapeUtils.escape_html context[:cushion_link]}#{EscapeUtils.escape_url link}"
|
55
55
|
else
|
56
|
-
|
56
|
+
EscapeUtils.escape_html(link).to_s
|
57
57
|
end
|
58
58
|
"<a href=\"#{escaped_link}\" class=\"#{EscapeUtils.escape_html(klass)}\">#{EscapeUtils.escape_html(override_text || text)}</a>"
|
59
59
|
else
|
File without changes
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?('_')
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?("\n")
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?('`')
|
@@ -9,7 +9,7 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
doc.search(
|
12
|
+
doc.search('.//text()').each do |node|
|
13
13
|
content = node.to_html
|
14
14
|
next if has_ancestor?(node, ignored_ancestor_tags)
|
15
15
|
next unless content.include?('>>>')
|
@@ -9,9 +9,19 @@ module SlackMarkdown
|
|
9
9
|
include IgnorableAncestorTags
|
10
10
|
|
11
11
|
def call
|
12
|
-
html = doc.to_s
|
12
|
+
html = replace_quote_line(doc.to_s)
|
13
|
+
collect_blockquote(html)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def replace_quote_line(str)
|
19
|
+
str.gsub(/^>\s*(.+)(?:\n|$)/) do
|
13
20
|
"<blockquote>#{$1}\n</blockquote>"
|
14
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def collect_blockquote(html)
|
15
25
|
doc = Nokogiri::HTML.fragment(html)
|
16
26
|
doc.search('blockquote + blockquote').each do |node|
|
17
27
|
next unless node.previous.name == 'blockquote'
|
@@ -33,7 +33,7 @@ module SlackMarkdown
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def call(src_text, context = {}, result = nil)
|
36
|
-
HTML::Pipeline.new(
|
36
|
+
HTML::Pipeline.new(filters, self.context).call(src_text, context, result)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/slack_markdown.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Ru/MuckRu']
|
10
10
|
spec.email = ['ru_shalm@hazimu.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
12
|
+
spec.summary = 'Convert Slack message markdown to HTML.'
|
13
|
+
spec.description = 'Convert Slack message markdown to HTML.'
|
14
14
|
spec.homepage = 'https://github.com/rutan/slack_markdown'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
@@ -20,11 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'html-pipeline', '~> 2.0'
|
23
|
-
spec.add_dependency 'escape_utils'
|
24
|
-
spec.add_dependency 'gemoji'
|
23
|
+
spec.add_dependency 'escape_utils'
|
24
|
+
spec.add_dependency 'gemoji'
|
25
25
|
|
26
|
-
spec.add_development_dependency 'bundler'
|
27
|
-
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
29
29
|
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.40.0'
|
30
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ru/MuckRu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -28,58 +28,58 @@ dependencies:
|
|
28
28
|
name: escape_utils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gemoji
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.40.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.40.0
|
111
125
|
description: Convert Slack message markdown to HTML.
|
112
126
|
email:
|
113
127
|
- ru_shalm@hazimu.com
|
@@ -116,6 +130,9 @@ extensions: []
|
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
132
|
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- ".rubocop_todo.yml"
|
135
|
+
- ".travis.yml"
|
119
136
|
- Gemfile
|
120
137
|
- LICENSE.txt
|
121
138
|
- README.md
|
@@ -138,7 +155,7 @@ homepage: https://github.com/rutan/slack_markdown
|
|
138
155
|
licenses:
|
139
156
|
- MIT
|
140
157
|
metadata: {}
|
141
|
-
post_install_message:
|
158
|
+
post_install_message:
|
142
159
|
rdoc_options: []
|
143
160
|
require_paths:
|
144
161
|
- lib
|
@@ -153,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
170
|
- !ruby/object:Gem::Version
|
154
171
|
version: '0'
|
155
172
|
requirements: []
|
156
|
-
|
157
|
-
|
158
|
-
signing_key:
|
173
|
+
rubygems_version: 3.2.3
|
174
|
+
signing_key:
|
159
175
|
specification_version: 4
|
160
176
|
summary: Convert Slack message markdown to HTML.
|
161
177
|
test_files: []
|