@ecency/render-helper 2.2.22 → 2.2.23
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/lib/methods/linkify.method.js.map +1 -1
- package/lib/methods/markdown-to-html.method.js +3 -0
- package/lib/methods/markdown-to-html.method.js.map +1 -1
- package/lib/render-helper.js +1 -1
- package/package.json +1 -1
- package/src/methods/linkify.method.ts +4 -4
- package/src/methods/markdown-to-html.method.ts +5 -0
package/package.json
CHANGED
|
@@ -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('/')
|
|
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,
|