Open Flashwalker opened 1 year ago
Can we have filter or remove rules to filter/remove via regexp or wildcard???
E.g.:
Zero width space and/or Non-breaking space: <a href="https://bla-bla-bla">​​</a>text-text-text produce:
<a href="https://bla-bla-bla">​​</a>text-text-text
[](https://bla-bla-bla)text-text-text
Is there any way to filter out (remove) html with zero visual content? Something like:
turndownService.addRule('al_spaces', { regexFilter: '<[^<>]+?>[[:space:]]<\/[^<>]+?>', replacement: function (content) { return '' } })
Line break which breaks markdown's markup: <strong>bla-bla-bla<br></strong> <br>text-text-text produce:
<strong>bla-bla-bla<br></strong> <br>text-text-text
**bla-bla-bla ** text-text-text
Is there any way to filter out (remove) all line breaks that precedes the closing tag? Something like:
turndownService.removeAllBefore('<br>', '</*>')
Remove the anchor with zero-width spaces (you can't see them until you paste it in dev console):
selectedHTML='<i>bla</i><b><a href="https://bla-bla-bla"></a>text-text-text</b><i>bla</i>' selectedHTML.replace(/<[^<>]+?>[\u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000\uFEFF\u0020\uFFFC]+<\/[^<>]+?>/gm, '')
Remove the line break that precedes closing tag:
selectedHTML='<i>bla</i><strong>bla-bla-bla<br></strong> <br>text-text-text<i>bla</i>' selectedHTML.replace(/(<br ?\/?>)+(<\/[^<>]+?>)/gi, '$2')
Swap the line break that precedes closing tag and the closing tag with:
selectedHTML='<i>bla</i><strong>bla-bla-bla<br></strong> <br>text-text-text<i>bla</i>' selectedHTML.replace(/((<br ?\/?>)+)(<\/[^<>]+?>)/gi, '$3$1')
It would be nice if regex filter will skip the content of code and pre tags.
code
pre
P.S. And also:
// Drop anchor html tags which contains only dots, commas selectedHTML = '<a href="#">,</a>' selectedHTML.replace(/<a [^<>]+?>[.,]+<\/a>/gim, '')
And
// Drop emoji images, keep emoji unicode (from alt attr) selectedHTML = '<img src="img-apple-64/1f914.png" class="emoji" alt="🤔">' selectedHTML.replace(/<img [^<>]+?alt=['"]([\p{Emoji}\u200d]+)['"][^<>]*?\/?>/gimu, '$1')
Can we have filter or remove rules to filter/remove via regexp or wildcard???
E.g.:
1.
Zero width space and/or Non-breaking space:
<a href="https://bla-bla-bla">​​</a>text-text-text
produce:Is there any way to filter out (remove) html with zero visual content? Something like:
2.
Line break which breaks markdown's markup:
<strong>bla-bla-bla<br></strong> <br>text-text-text
produce:Is there any way to filter out (remove) all line breaks that precedes the closing tag? Something like:
Here is regex examples:
Remove the anchor with zero-width spaces (you can't see them until you paste it in dev console):
Remove the line break that precedes closing tag:
Swap the line break that precedes closing tag and the closing tag with:
It would be nice if regex filter will skip the content of
code
andpre
tags.P.S.
And also:
And