Feature #41294 » 0008-Modified-to-simpler-implementation-and-improved-code-comments.patch
| app/assets/javascripts/quote_reply.js | ||
|---|---|---|
|
// Remove all unnecessary anchor elements
|
||
|
fragment.querySelectorAll('a.wiki-anchor').forEach(e => e.remove());
|
||
|
// Adjust line breaks when output as text
|
||
|
const html = this.adjustLineBreaks(fragment.innerHTML);
|
||
|
const result = document.createElement('div');
|
||
| ... | ... | |
|
}
|
||
|
});
|
||
|
// Table elements are not formatted, and the within the table is output as is.
|
||
|
// Table does not maintain its original format,
|
||
|
// and the text within the table is displayed as it is
|
||
|
//
|
||
|
// | A | B | C |
|
||
|
// |---|---|---|
|
||
| ... | ... | |
|
// A B C
|
||
|
// 1 2 3
|
||
|
turndownService.addRule('table', {
|
||
|
filter: (node, options) => {
|
||
|
return node.nodeName === 'TD' || node.nodeName === 'TH';
|
||
|
},
|
||
|
filter: ['td', 'th'],
|
||
|
replacement: (content, node) => {
|
||
|
const separator = node.parentElement.lastElementChild === node ? '' : ' ';
|
||
|
return content + separator;
|
||
| ... | ... | |
|
// <h1>Title1<a href="#Title" class="wiki-anchor">¶</a></h1> => <h1>Title1</h1>
|
||
|
htmlFragment.querySelectorAll('a.wiki-anchor').forEach(e => e.remove());
|
||
|
// Convert code highlight blocks to CommonMark code blocks.
|
||
|
// Convert code highlight blocks to CommonMark format code blocks.
|
||
|
// <code class="ruby" data-language="ruby"> => <code class="language-ruby" data-language="ruby">
|
||
|
htmlFragment.querySelectorAll('code[data-language]').forEach(e => {
|
||
|
e.classList.replace(e.dataset['language'], 'language-' + e.dataset['language'])
|
||