html-pipeline-mrkdwn 0.2.0 → 0.2.1

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: 9547e478a23018b8b15dce6d5c1546172c1fc1c69dd42935e40c32d528c5cf4a
4
- data.tar.gz: 4e8d92217071e0c78c2426ca887f7f6522e4c25f72afeb0c5689fbc340f28ae8
3
+ metadata.gz: 865e7c4e26f60927fe0ee325097aead119cffa7ae67bb8c607ec515516a81484
4
+ data.tar.gz: 899c386db5debf2898fe4e7a42aebe1332a09456bb6dde00a9b64f15fa659dbc
5
5
  SHA512:
6
- metadata.gz: 286afc3419b578befe9da101d992acc0f63b32b3e7169f7a3ba687a6a28cba4e39adf7650e692c696238f95d457d36e7a20f224a4dfcd69066fcd9b355b00574
7
- data.tar.gz: bcd82b1de9518d162aa088ecbf8f89266d2ef3124ebe98d14a8de4c85a759549ca2fc864f6df11c2c4675d9123afa9e0cd26dd2c1b7cafe68a595ece70e535c1
6
+ metadata.gz: 72a042625fb8173c6b645ad0d1620b18a928ef36849f7e62593a52a1ce728ae033d137c89c4858da6d69da8acdb208966163385d463222d481b602c373d71ebc
7
+ data.tar.gz: 1c00cc52f3bfed425c2aecc6363ccdeb94e7bbf4062382f7b940fa16e20b48deb91543f82451da2c0ef57d16798cc5c1f82e5919bf3dd90c3be907f319d47dc6
@@ -14,6 +14,10 @@ module HTML
14
14
  class Mrkdwn < Filter
15
15
  attr_reader :large_emoji
16
16
 
17
+ EMOJI_AND_WHITESPACE_PATTERN = /(?::[\w+-_]+?:|\s)+/.freeze
18
+
19
+ NON_CAPTURING_EMOJI_PATTERN = /:[\w+-_]+?:/.freeze
20
+
17
21
  MULTILINE_CODE_PATTERN = /```(.+?)```/m.freeze
18
22
 
19
23
  CODE_PATTERN = /`(?=\S)(.+?)(?<=\S)`/.freeze
@@ -37,10 +41,6 @@ module HTML
37
41
 
38
42
  EMOJI_PATTERN = /:([\w+-_]+?):/.freeze
39
43
 
40
- EMOJI_AND_WHITESPACE_PATTERN = /(?::[\w+-_]+?:|\s)+/.freeze
41
-
42
- NON_CAPTURING_EMOJI_PATTERN = /:[\w+-_]+?:/.freeze
43
-
44
44
  STYLE_PATTERN = /
45
45
  ([`*_~])
46
46
  (?=\S)(.+?)(?<=\S)
@@ -57,7 +57,8 @@ module HTML
57
57
  link: %w[&lt;],
58
58
  line_break: %W[\n \r\n],
59
59
  emoji: %w[:],
60
- style: %w[* _ ~]
60
+ style: %w[* _ ~],
61
+ unescape: %w[&amp;lowbar;]
61
62
  }.freeze
62
63
 
63
64
  def initialize(doc, context = nil, result = nil)
@@ -201,18 +202,16 @@ module HTML
201
202
  content.gsub(EMOJI_PATTERN) do |match|
202
203
  emoji = Emoji.find_by_alias(Regexp.last_match[1])
203
204
 
204
- if emoji
205
- if emoji.custom?
206
- if @large_emoji
207
- @large_emoji_image_tag.call(emoji)
208
- else
209
- @emoji_image_tag.call(emoji)
210
- end
205
+ if emoji&.custom?
206
+ if @large_emoji
207
+ @large_emoji_image_tag.call(emoji)
211
208
  else
212
- emoji.raw
209
+ @emoji_image_tag.call(emoji)
213
210
  end
211
+ elsif emoji
212
+ emoji.raw
214
213
  else
215
- match
214
+ match.gsub(/_/, "&lowbar;")
216
215
  end
217
216
  end
218
217
  end
@@ -239,6 +238,10 @@ module HTML
239
238
  end
240
239
  end
241
240
 
241
+ def unescape_filter(content)
242
+ content.gsub("&amp;lowbar;", "_")
243
+ end
244
+
242
245
  private
243
246
 
244
247
  def only_emoji_and_whitespace?(string)
@@ -5,7 +5,7 @@ require "html/pipeline"
5
5
  module HTML
6
6
  class Pipeline
7
7
  class Mrkdwn < Filter
8
- VERSION = "0.2.0"
8
+ VERSION = "0.2.1"
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-mrkdwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Gorst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-30 00:00:00.000000000 Z
11
+ date: 2024-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils