@nectary/components 4.7.4 → 4.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "4.7.4",
3
+ "version": "4.7.5",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -12,6 +12,15 @@ export const createParseVisitor = doc => {
12
12
  let $li = null;
13
13
  const $lists = [];
14
14
  return {
15
+ escaped(char) {
16
+ const $text = doc.createTextNode(char);
17
+ if ($p != null) {
18
+ $p.appendChild($text);
19
+ } else {
20
+ this.paragraph();
21
+ $p.appendChild($text);
22
+ }
23
+ },
15
24
  emoji(emojiChar) {
16
25
  const $emoji = doc.createElement('sinch-emoji');
17
26
  setEmojiBaseUrl($emoji, emojiBaseUrl);
@@ -1636,6 +1636,15 @@ export const createParseVisitor = doc => {
1636
1636
  const listsStack = [];
1637
1637
  let isFirstListItem = false;
1638
1638
  return {
1639
+ escaped(char) {
1640
+ const $text = doc.createTextNode(char);
1641
+ if ($currentBlock != null) {
1642
+ $currentBlock.appendChild($text);
1643
+ } else {
1644
+ this.paragraph();
1645
+ $currentBlock.appendChild($text);
1646
+ }
1647
+ },
1639
1648
  emoji(emojiChar) {
1640
1649
  const $emoji = createEmoji(emojiChar, emojiBaseUrl, doc);
1641
1650
  $currentBlock.appendChild($emoji);
@@ -4,6 +4,7 @@ export type TMarkdownInlineParams = {
4
4
  isStrikethrough?: boolean;
5
5
  };
6
6
  export type TMarkdownParseVisitor = {
7
+ escaped(char: string): void;
7
8
  link(text: string, href: string, attributes?: string[]): void;
8
9
  emoji(emojiChar: string): void;
9
10
  codetag(text: string): void;
package/utils/markdown.js CHANGED
@@ -1,18 +1,19 @@
1
1
  const regLinebreak = /(?:<br>\n|<br>|\n)/;
2
2
  const regParagraph = /\n{2,}/;
3
- const regEm3Star = /\*\*\*(?<em3>.+?)\*\*\*/;
4
- const regEm2Star = /\*\*(?<em2>.+?)\*\*/;
5
- const regEm1Star = /\*(?<em1>.+?)\*/;
6
- const regEm3Underscore = /___(?<em3>.+?)___/;
7
- const regEm2Underscore = /__(?<em2>.+?)__/;
8
- const regEm1Underscore = /_(?<em1>.+?)_/;
9
- const regCodeTag = /`(?<code>.+?)`/;
10
- const regStrikethrough = /~~(?<strike>.+?)~~/;
11
- const regLink = /!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\)(\{(?<linkattrs>[^)]+?)\})?/;
3
+ const regEm3Star = /(?<!\\)\*\*\*(?<em3>.+?)(?<!\\)\*\*\*/;
4
+ const regEm2Star = /(?<!\\)\*\*(?<em2>.+?)(?<!\\)\*\*/;
5
+ const regEm1Star = /(?<!\\)\*(?<em1>.+?)(?<!\\)\*/;
6
+ const regEm3Underscore = /(?<!\\)___(?<em3>.+?)(?<!\\)___/;
7
+ const regEm2Underscore = /(?<!\\)__(?<em2>.+?)(?<!\\)__/;
8
+ const regEm1Underscore = /(?<!\\)_(?<em1>.+?)(?<!\\)_/;
9
+ const regCodeTag = /(?<!\\)`(?<code>.+?)(?<!\\)`/;
10
+ const regStrikethrough = /(?<!\\)~~(?<strike>.+?)(?<!\\)~~/;
11
+ const regLink = /(?<!\\)!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\)(\{(?<linkattrs>[^)]+?)\})?/;
12
12
  const regEmoji = /(?<emoji>(?![0-9*#])\p{Emoji})/u;
13
13
  const regUList = /^(?<indent>[\t ]*?)[*+-][\t ]+(?<ultext>.*?)[\t ]*?$/;
14
14
  const regOList = /^(?<indent>[\t ]*?)\d+\.[\t ]+(?<oltext>.*?)[\t ]*?$/;
15
- const allRegs = [regCodeTag, regLink, regEm3Star, regEm2Star, regEm1Star, regEm3Underscore, regEm2Underscore, regEm1Underscore, regStrikethrough, regEmoji];
15
+ const regEscapedChars = /\\(?<escaped>[\\\*_\[\]`~])/;
16
+ const allRegs = [regEscapedChars, regCodeTag, regLink, regEm3Star, regEm2Star, regEm1Star, regEm3Underscore, regEm2Underscore, regEm1Underscore, regStrikethrough, regEmoji];
16
17
  export const isEmojiString = data => regEmoji.test(data);
17
18
  const excludeRegs = function (regs) {
18
19
  for (var _len = arguments.length, excluding = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -47,6 +48,10 @@ const createLineParser = visitor => function parseLine(regs, md) {
47
48
  visitor.inline(line.substring(0, match.index), context);
48
49
  }
49
50
  line = line.substring(match.index + matchedStr.length);
51
+ if (groups?.escaped != null) {
52
+ visitor.escaped(groups.escaped);
53
+ continue;
54
+ }
50
55
  if (groups?.linkhref != null) {
51
56
  visitor.link(groups.linktext, groups.linkhref, groups.linkattrs?.split(' '));
52
57
  }