Repository: speee/jsx-slack (ts)

Issue:
Escaped underscores within Korean emoji shorthand have broken
[Slack is now available in Korean](https://slack.com/blog/collaboration/slack-is-now-available-in-korean) and Slack users can use Hangul as the name of custom emoji and emoji alias. Well, the Korean emoji shorthand brings #98 again:

```jsx
<Blocks>
  <Section>
	<p><Escape>_:white_check_mark:_</Escape></p>
	<p><Escape>_:체크표시_초록:_</Escape></p>
  </Section>
</Blocks>
```

![](https://user-images.githubusercontent.com/3993388/95442035-d730aa80-0995-11eb-8c8e-bddde46b1898.png)

It appears that the escaped underscore inside emoji shorthand also has broken rendering.

We have to fix and recover emoji rendering by preventing escape for underscore within Korean emoji shorthand. Additional Unicode blocks Slack accepts as emoji shorthand are following:

- Hangul Jamo (`U+1100` - `U+11FF`)
- Hangul Compatibility Jamo (`U+3130` - `U+318F`)
- Hangul Jamo Extended-A (`U+A960` - `U+A97F`)
- Hangul Syllables (`U+AC00` - `U+D7AF`)
- Hangul Jamo Extended-B (`U+D7B0` - `U+D7FF`)



Pull request:
Prevent over-escaping in Korean emoji shorthand
It's just like #101 but I've updated regex for valid emoji shorthand to add Hangul unicode characters, for preventing over-escaping.

Closes #203.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 974aa09..a7f3fb3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@
 
 - [Configurable `dispatchAction` prop](https://github.com/speee/jsx-slack/blob/master/docs/block-elements.md#input) for `<Input type="text">` and `<Textarea>` (equivalent to [`dispatch_action_config` for the plain-text input](https://api.slack.com/reference/block-kit/block-elements#input)) ([#204](https://github.com/speee/jsx-slack/issues/204), [#205](https://github.com/speee/jsx-slack/pull/205))
 
+### Fixed
+
+- Escaped underscores within Korean emoji shorthand have broken ([#203](https://github.com/speee/jsx-slack/issues/203), [#206](https://github.com/speee/jsx-slack/pull/206))
+
 ## v2.5.1 - 2020-10-08
 
 ### Added
diff --git a/src/mrkdwn/escape.ts b/src/mrkdwn/escape.ts
index 4f22d16..03b0035 100644
--- a/src/mrkdwn/escape.ts
+++ b/src/mrkdwn/escape.ts
@@ -1,5 +1,5 @@
 // An internal HTML tag and emoji shorthand should not escape
-const preventEscapeRegex = /(<.*?>|:[-a-z0-9ÀÁÂÃÄÇÈÉÊËÍÎÏÑÓÔÕÖŒœÙÚÛÜŸßàáâãäçèéêëíîïñóôõöùúûüÿ_＿+＋'\u2e80-\u2fd5\u3005\u3041-\u3096\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcb\uff10-\uff19\uff41-\uff5a\uff61-\uff9f]+:)/
+const preventEscapeRegex = /(<.*?>|:[-a-z0-9ÀÁÂÃÄÇÈÉÊËÍÎÏÑÓÔÕÖŒœÙÚÛÜŸßàáâãäçèéêëíîïñóôõöùúûüÿ_＿+＋'\u1100-\u11ff\u2e80-\u2fd5\u3005\u3041-\u3096\u30a0-\u30ff\u3130-\u318f\u3400-\u4db5\u4e00-\u9fcb\ua960-\ua97f\uac00-\ud7ff\uff10-\uff19\uff41-\uff5a\uff61-\uff9f]+:)/
 
 const generateReplacerForEscape = (fallback: string) => (matched: string) =>
   `<span data-escape="${fallback.repeat(matched.length)}">${matched}</span>`


Test patch:
diff --git a/test/block-kit/builtin-components.tsx b/test/block-kit/builtin-components.tsx
index 2a98884..b376368 100644
--- a/test/block-kit/builtin-components.tsx
+++ b/test/block-kit/builtin-components.tsx
@@ -50,7 +50,10 @@ describe('Built-in components', () => {
         JSXSlack(
           <Blocks>
             <Section>
-              <Escape>_:arrow_down: :custom_emoji: :カスタム＿絵文字:_</Escape>
+              <Escape>
+                _:arrow_down: :custom_emoji: :カスタム＿絵文字:
+                :커스텀_이모티콘:_
+              </Escape>
             </Section>
           </Blocks>
         )
@@ -58,7 +61,7 @@ describe('Built-in components', () => {
         expect.objectContaining({
           text: expect.objectContaining({
             text:
-              '<!date^00000000^{_}|_>:arrow_down: :custom_emoji: :カスタム＿絵文字:<!date^00000000^{_}|_>',
+              '<!date^00000000^{_}|_>:arrow_down: :custom_emoji: :カスタム＿絵文字: :커스텀_이모티콘:<!date^00000000^{_}|_>',
           }),
         }),
       ]))