@ecency/render-helper 2.2.16 → 2.2.17

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.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,6DAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,6DAA0C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecency/render-helper",
3
- "version": "2.2.16",
3
+ "version": "2.2.17",
4
4
  "description": "Markdown+Html Render helper",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,4 +39,5 @@ export const BRAND_NEW_TUBE_REGEX = /^https:\/\/brandnewtube\.com\/embed\/[a-z0-
39
39
  export const LOOM_REGEX = /^(https?:)?\/\/www.loom.com\/share\/(.*)/i
40
40
  export const LOOM_EMBED_REGEX = /^(https?:)?\/\/www.loom.com\/embed\/(.*)/i
41
41
  export const AUREAL_EMBED_REGEX = /^(https?:\/\/)?(www\.)?(?:aureal-embed)\.web\.app\/([0-9]+)/i
42
- export const ENTITY_REGEX = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/ig;
42
+ export const ENTITY_REGEX = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/ig
43
+ export const SECTION_REGEX = /\B(\#[\da-zA-Z-_]+\b)(?!;)/i
@@ -937,6 +937,18 @@ describe('Markdown2Html', () => {
937
937
 
938
938
  expect(markdown2Html(input)).toBe(expected)
939
939
  })
940
+
941
+ it('68 - Should handle section links', () => {
942
+ const input = {
943
+ author: 'foo368',
944
+ permlink: 'bar368',
945
+ last_update: '2019-05-10T09:15:21',
946
+ body: 'this is link [What is HIVE](#WhatHive) and locatino ## 1 <a data-id="WhatHive"></a>What is HIVE?'
947
+ }
948
+ const expected = '<p>this is link <a href=\"#WhatHive\" class=\"markdown-internal-link\">What is HIVE</a> and locatino ## 1 <a data-id=\"WhatHive\"></a>What is HIVE?</p>'
949
+
950
+ expect(markdown2Html(input, false)).toBe(expected)
951
+ })
940
952
  })
941
953
 
942
954
  describe("Rumble support", () => {
@@ -24,6 +24,7 @@ import {
24
24
  BRIGHTEON_REGEX,
25
25
  DOMParser,
26
26
  LOOM_REGEX,
27
+ SECTION_REGEX,
27
28
  SECTION_LIST
28
29
  } from '../consts'
29
30
  import { getSerializedInnerHTML } from './get-inner-html.method'
@@ -706,12 +707,12 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
706
707
  }
707
708
  el.removeAttribute('href')
708
709
  } else {
709
- const externalRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
710
- if(externalRegex.test(href)) {
710
+ const matchS = href.match(SECTION_REGEX)
711
+ if(matchS) {
712
+ el.setAttribute('class', 'markdown-internal-link');
713
+ } else {
711
714
  el.setAttribute('target', '_blank');
712
715
  el.setAttribute('rel', 'noopener');
713
- } else {
714
- el.setAttribute('class', 'markdown-internal-link')
715
716
  }
716
717
  }
717
718
  }