Escape specific html tags in P elements when quoting to markdown (#23)
This commit is contained in:
Родитель
e53342ad33
Коммит
e205f028bc
|
@ -76,6 +76,12 @@ const filters: Filters = {
|
|||
}
|
||||
return `\`${text}\``
|
||||
},
|
||||
P(el) {
|
||||
const pElement = document.createElement('p')
|
||||
const text = el.textContent || ''
|
||||
pElement.textContent = text.replace(/<(\/?)(pre|strong|weak|em)>/g, '\\<$1$2\\>')
|
||||
return pElement
|
||||
},
|
||||
STRONG(el) {
|
||||
return `**${el.textContent || ''}**`
|
||||
},
|
||||
|
|
|
@ -102,6 +102,8 @@ describe('quote-selection', function () {
|
|||
<p>This should not appear as part of the quote.</p>
|
||||
<div class="comment-body">
|
||||
<p>This is <strong>beautifully</strong> formatted <em>text</em> that even has some <code>inline code</code>.</p>
|
||||
<p>This is a simple p line</p>
|
||||
<p>some escaped html tags to ignore <pre> <strong> <weak> <em> </pre> </strong> </weak> </em></p>
|
||||
<pre><code>foo(true)</code></pre>
|
||||
<p><a href="http://example.com">Links</a> and <img alt=":emoji:" class="emoji" src="image.png"> are preserved.</p>
|
||||
<blockquote><p>Music changes, and I'm gonna change right along with it.<br>--Aretha Franklin</p></blockquote>
|
||||
|
@ -131,6 +133,10 @@ describe('quote-selection', function () {
|
|||
textarea.value.replace(/ +\n/g, '\n'),
|
||||
`> This is **beautifully** formatted _text_ that even has some \`inline code\`.
|
||||
>
|
||||
> This is a simple p line
|
||||
>
|
||||
> some escaped html tags to ignore \\<pre\\> \\<strong\\> \\<weak\\> \\<em\\> \\</pre\\> \\</strong\\> \\</weak\\> \\</em\\>
|
||||
>
|
||||
> \`\`\`
|
||||
> foo(true)
|
||||
> \`\`\`
|
||||
|
|
Загрузка…
Ссылка в новой задаче