@ecency/render-helper 2.2.22 → 2.2.24

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": "@ecency/render-helper",
3
- "version": "2.2.22",
3
+ "version": "2.2.24",
4
4
  "description": "Markdown+Html Render helper",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -29,7 +29,7 @@ export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3spe
29
29
  export const SPEAK_EMBED_REGEX = /^(https?:)?\/\/3speak.([a-z]+)\/embed\?.*/i
30
30
  export const TWITTER_REGEX = /(?:https?:\/\/(?:(?:twitter\.com\/(.*?)\/status\/(.*))))/gi
31
31
  export const SPOTIFY_REGEX = /^https:\/\/open\.spotify\.com\/playlist\/(.*)?$/gi
32
- export const RUMBLE_REGEX = /^https:\/\/rumble.com\/embed\/([a-zA-Z0-9-]+)\/\?pub=4/
32
+ export const RUMBLE_REGEX = /^https:\/\/rumble.com\/embed\/([a-zA-Z0-9-]+)\/\?pub=\w+/
33
33
  export const BRIGHTEON_REGEX = /^https?:\/\/(www\.)?brighteon\.com\/(?:embed\/)?(.*[0-9].*)/i
34
34
  export const VIMM_EMBED_REGEX = /^https:\/\/www.vimm.tv\/.*/i
35
35
  export const SPOTIFY_EMBED_REGEX = /^https:\/\/open\.spotify\.com\/(embed|embed-podcast)\/(playlist|show|episode|track|album)\/(.*)/i
@@ -976,6 +976,17 @@ describe('Markdown2Html', () => {
976
976
  expect(markdown2Html(input)).toBe(expected)
977
977
  })
978
978
 
979
+ it('Rumble iframes 2', () => {
980
+ let expected = '<iframe class="rumble" src="https://rumble.com/embed/v2mb4d6/?pub=1aoesn" frameborder="0" allowfullscreen="allowfullscreen"></iframe>'
981
+ let input = {
982
+ author: 'foo350xx',
983
+ permlink: 'bar350xx',
984
+ last_update: '2021-05-10T09:15:50',
985
+ body: '<iframe class="rumble" width="640" height="360" src="https://rumble.com/embed/v2mb4d6/?pub=1aoesn" frameborder="0" allowfullscreen></iframe>'
986
+ }
987
+ expect(markdown2Html(input)).toBe(expected)
988
+ })
989
+
979
990
  // The following cannot be done: Convert URLs to the video page like this one
980
991
  // (https://rumble.com/vkhkzl-helping-my-girls-to-cool-down-in-the-heat.html)
981
992
  // to its corresponding embedded URL (https://rumble.com/embed/vhveub/?pub=4).
@@ -20,9 +20,9 @@ export function linkify(content: string, forApp: boolean, webp: boolean): string
20
20
  (match, preceeding1, preceeding2, user) => {
21
21
  const userLower = user.toLowerCase()
22
22
  const preceedings = (preceeding1 || '') + (preceeding2 || '')
23
- if (userLower.indexOf('/')===-1) {
23
+ if (userLower.indexOf('/') === -1) {
24
24
  const attrs = forApp ? `data-author="${userLower}"` : `href="/@${userLower}"`
25
- return `${preceedings}<a class="markdown-author-link" ${attrs}>@${user}</a>`
25
+ return `${preceedings}<a class="markdown-author-link" ${attrs}>@${user}</a>`
26
26
  } else {
27
27
  return match
28
28
  }
@@ -32,14 +32,14 @@ export function linkify(content: string, forApp: boolean, webp: boolean): string
32
32
  // internal links
33
33
  content = content.replace(
34
34
  /((^|\s)(\/|)@[\w.\d-]+)\/(\S+)/gi, (match, u, p1, p2, p3) => {
35
- const uu = u.trim().toLowerCase().replace('/@','').replace('@','');
35
+ const uu = u.trim().toLowerCase().replace('/@', '').replace('@', '');
36
36
  const perm = p3;
37
37
  if (SECTION_LIST.some(v => p3.includes(v))) {
38
38
  const attrs = forApp ? `https://ecency.com/@${uu}/${perm}` : `href="/@${uu}/${perm}"`
39
39
  return ` <a class="markdown-profile-link" ${attrs}>@${uu}/${perm}</a>`
40
40
  } else {
41
41
  const attrs = forApp ? `data-author="${uu}" data-tag="post" data-permlink="${perm}"` : `href="/post/@${uu}/${perm}"`
42
- return ` <a class="markdown-post-link" ${attrs}>@${uu}/${perm}</a>`
42
+ return ` <a class="markdown-post-link" ${attrs}>@${uu}/${perm}</a>`
43
43
  }
44
44
  }
45
45
  )
@@ -9,6 +9,11 @@ const { linkify } = require('remarkable/linkify')
9
9
 
10
10
 
11
11
  export function markdownToHTML(input: string, forApp: boolean, webp: boolean): string {
12
+ // Internalize leofinance.io links
13
+ input = input.replace("https://leofinance.io/threads/view/", "/@");
14
+ input = input.replace("https://leofinance.io/posts/", "/@");
15
+
16
+
12
17
  const md = new Remarkable({
13
18
  html: true,
14
19
  breaks: true,