@ecency/render-helper 2.2.38 → 2.2.39
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/consts/allowed-attributes.const.js +1 -0
- package/lib/consts/allowed-attributes.const.js.map +1 -1
- package/lib/methods/a.method.js +16 -0
- package/lib/methods/a.method.js.map +1 -1
- package/lib/render-helper.js +1 -1
- package/package.json +1 -1
- package/src/consts/allowed-attributes.const.ts +1 -0
- package/src/markdown-2-html.spec.ts +7 -7
- package/src/methods/a.method.ts +20 -0
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ describe('Markdown2Html', () => {
|
|
|
46
46
|
last_update: '2019-05-10T09:15:21',
|
|
47
47
|
body: '<a href=\'/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\'>click here</a>'
|
|
48
48
|
}
|
|
49
|
-
const expected = '<p dir=\"auto\"><a class
|
|
49
|
+
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\" data-is-inline=\"true\" data-tag=\"esteem\" data-author=\"esteemapp\" data-permlink=\"esteem-monthly-guest-curation-program-4\">click here</a></p>'
|
|
50
50
|
|
|
51
51
|
expect(markdown2Html(input)).toBe(expected)
|
|
52
52
|
})
|
|
@@ -58,7 +58,7 @@ describe('Markdown2Html', () => {
|
|
|
58
58
|
last_update: '2019-05-10T09:15:21',
|
|
59
59
|
body: '[click here](/esteem/@esteemapp/esteem-monthly-guest-curation-program-4)'
|
|
60
60
|
}
|
|
61
|
-
const expected = '<p dir=\"auto\"><a class
|
|
61
|
+
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/esteem/@esteemapp/esteem-monthly-guest-curation-program-4\" data-is-inline=\"true\" data-tag=\"esteem\" data-author=\"esteemapp\" data-permlink=\"esteem-monthly-guest-curation-program-4\">click here</a></p>'
|
|
62
62
|
|
|
63
63
|
expect(markdown2Html(input)).toBe(expected)
|
|
64
64
|
})
|
|
@@ -448,7 +448,7 @@ describe('Markdown2Html', () => {
|
|
|
448
448
|
last_update: '2019-05-10T09:15:21',
|
|
449
449
|
body: 'https://peakd.com/@demo/tests'
|
|
450
450
|
}
|
|
451
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a></p>'
|
|
451
|
+
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"https://peakd.com/@demo/tests\" data-is-inline=\"false\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a></p>'
|
|
452
452
|
|
|
453
453
|
expect(markdown2Html(input)).toBe(expected)
|
|
454
454
|
})
|
|
@@ -496,7 +496,7 @@ describe('Markdown2Html', () => {
|
|
|
496
496
|
last_update: '2019-05-10T09:15:21',
|
|
497
497
|
body: 'https://peakd.com/tag/@demo/tests and https://steemit.com/test/@demo/post'
|
|
498
498
|
}
|
|
499
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-tag=\"tag\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a> and <a class=\"markdown-external-link\" data-href=\"https://steemit.com/test/@demo/post\">https://steemit.com/test/@demo/post</a></p>'
|
|
499
|
+
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"https://peakd.com/tag/@demo/tests\" data-is-inline=\"false\" data-tag=\"tag\" data-author=\"demo\" data-permlink=\"tests\">@demo/tests</a> and <a class=\"markdown-external-link\" data-href=\"https://steemit.com/test/@demo/post\">https://steemit.com/test/@demo/post</a></p>'
|
|
500
500
|
|
|
501
501
|
expect(markdown2Html(input)).toBe(expected)
|
|
502
502
|
})
|
|
@@ -664,7 +664,7 @@ describe('Markdown2Html', () => {
|
|
|
664
664
|
last_update: '2019-05-10T09:15:21',
|
|
665
665
|
body: 'this is link https://peakd.com/ccc/jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more'
|
|
666
666
|
}
|
|
667
|
-
const expected = '<p dir=\"auto\">this is link <a class=\"markdown-post-link\" data-tag=\"ccc\" data-author=\"jarvie\" data-permlink=\"one-week-roadtrip-to-all-5-utah-national-parks-and-more\">@jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more</a></p>'
|
|
667
|
+
const expected = '<p dir=\"auto\">this is link <a class=\"markdown-post-link\" data-href=\"https://peakd.com/ccc/jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more\" data-is-inline=\"false\" data-tag=\"ccc\" data-author=\"jarvie\" data-permlink=\"one-week-roadtrip-to-all-5-utah-national-parks-and-more\">@jarvie/one-week-roadtrip-to-all-5-utah-national-parks-and-more</a></p>'
|
|
668
668
|
|
|
669
669
|
expect(markdown2Html(input)).toBe(expected)
|
|
670
670
|
})
|
|
@@ -733,7 +733,7 @@ describe('Markdown2Html', () => {
|
|
|
733
733
|
last_update: '2021-05-10T09:15:49',
|
|
734
734
|
body: '<a href="/@demo/test">test post</a>'
|
|
735
735
|
}
|
|
736
|
-
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"test\">test post</a></p>'
|
|
736
|
+
const expected = '<p dir=\"auto\"><a class=\"markdown-post-link\" data-href=\"/@demo/test\" data-is-inline=\"true\" data-tag=\"post\" data-author=\"demo\" data-permlink=\"test\">test post</a></p>'
|
|
737
737
|
expect(markdown2Html(input)).toBe(expected)
|
|
738
738
|
})
|
|
739
739
|
|
|
@@ -910,7 +910,7 @@ describe('Markdown2Html', () => {
|
|
|
910
910
|
last_update: '2019-05-10T09:15:21',
|
|
911
911
|
body: 'direct link https://ecency.com/@ecency/faq?history'
|
|
912
912
|
}
|
|
913
|
-
const expected = '<p dir=\"auto\">direct link <a class=\"markdown-post-link\" data-tag=\"post\" data-author=\"ecency\" data-permlink=\"faq?history\">@ecency/faq?history</a></p>'
|
|
913
|
+
const expected = '<p dir=\"auto\">direct link <a class=\"markdown-post-link\" data-href=\"https://ecency.com/@ecency/faq?history\" data-is-inline=\"false\" data-tag=\"post\" data-author=\"ecency\" data-permlink=\"faq?history\">@ecency/faq?history</a></p>'
|
|
914
914
|
|
|
915
915
|
expect(markdown2Html(input)).toBe(expected)
|
|
916
916
|
})
|
package/src/methods/a.method.ts
CHANGED
|
@@ -101,15 +101,20 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
|
|
|
101
101
|
const tag = postMatch[2]
|
|
102
102
|
const author = postMatch[3].replace('@', '')
|
|
103
103
|
const permlink = postMatch[4]
|
|
104
|
+
let isInline = true;
|
|
104
105
|
if (el.textContent === href) {
|
|
105
106
|
el.textContent = `@${author}/${permlink}`
|
|
107
|
+
isInline = false;
|
|
106
108
|
}
|
|
107
109
|
if (forApp) {
|
|
108
110
|
el.removeAttribute('href')
|
|
109
111
|
|
|
112
|
+
el.setAttribute('data-href', href)
|
|
113
|
+
el.setAttribute('data-is-inline', '' + isInline)
|
|
110
114
|
el.setAttribute('data-tag', tag)
|
|
111
115
|
el.setAttribute('data-author', author)
|
|
112
116
|
el.setAttribute('data-permlink', permlink)
|
|
117
|
+
|
|
113
118
|
} else {
|
|
114
119
|
const h = `/${tag}/@${author}/${permlink}`
|
|
115
120
|
el.setAttribute('href', h)
|
|
@@ -175,14 +180,20 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
|
|
|
175
180
|
el.setAttribute('class', 'markdown-post-link')
|
|
176
181
|
const author = tpostMatch[2].replace('@', '')
|
|
177
182
|
const permlink = tpostMatch[3]
|
|
183
|
+
let isInline = true;
|
|
178
184
|
if (el.textContent === href) {
|
|
179
185
|
el.textContent = `@${author}/${permlink}`
|
|
186
|
+
isInline = false;
|
|
180
187
|
}
|
|
181
188
|
if (forApp) {
|
|
182
189
|
el.removeAttribute('href')
|
|
190
|
+
|
|
191
|
+
el.setAttribute('data-href', href)
|
|
192
|
+
el.setAttribute('data-is-inline', '' + isInline)
|
|
183
193
|
el.setAttribute('data-tag', tag)
|
|
184
194
|
el.setAttribute('data-author', author)
|
|
185
195
|
el.setAttribute('data-permlink', permlink)
|
|
196
|
+
|
|
186
197
|
} else {
|
|
187
198
|
const h = `/${tag}/@${author}/${permlink}`
|
|
188
199
|
el.setAttribute('href', h)
|
|
@@ -241,11 +252,16 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
|
|
|
241
252
|
|
|
242
253
|
const author = cpostMatch[1].replace('@', '')
|
|
243
254
|
const permlink = cpostMatch[2]
|
|
255
|
+
let isInline = true;
|
|
244
256
|
if (el.textContent === href) {
|
|
245
257
|
el.textContent = `@${author}/${permlink}`
|
|
258
|
+
isInline = false;
|
|
246
259
|
}
|
|
247
260
|
if (forApp) {
|
|
248
261
|
el.removeAttribute('href')
|
|
262
|
+
|
|
263
|
+
el.setAttribute('data-href', href)
|
|
264
|
+
el.setAttribute('data-is-inline', '' + isInline)
|
|
249
265
|
el.setAttribute('data-tag', tag)
|
|
250
266
|
el.setAttribute('data-author', author)
|
|
251
267
|
el.setAttribute('data-permlink', permlink)
|
|
@@ -337,12 +353,16 @@ export function a(el: HTMLElement, forApp: boolean, webp: boolean): void {
|
|
|
337
353
|
const tag = 'ccc'
|
|
338
354
|
const author = cccMatch[2].replace('@', '')
|
|
339
355
|
const permlink = cccMatch[3]
|
|
356
|
+
let isInline = true;
|
|
340
357
|
if (el.textContent === href) {
|
|
341
358
|
el.textContent = `@${author}/${permlink}`
|
|
359
|
+
isInline = false;
|
|
342
360
|
}
|
|
343
361
|
if (forApp) {
|
|
344
362
|
el.removeAttribute('href')
|
|
345
363
|
|
|
364
|
+
el.setAttribute('data-href', href)
|
|
365
|
+
el.setAttribute('data-is-inline', '' + isInline)
|
|
346
366
|
el.setAttribute('data-tag', tag)
|
|
347
367
|
el.setAttribute('data-author', author)
|
|
348
368
|
el.setAttribute('data-permlink', permlink)
|