feat(apps/html2markdown): katex support
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-20 19:14:15 +08:00
parent 3c3ec65551
commit 22655baad8
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -93,6 +93,33 @@
}
});
turndownService.addRule('katexInline', {
filter: function(node) {
return node.nodeName === 'SPAN' && node.getAttribute('class') === 'katex';
},
escapeContent: function() {
return false;
},
replacement: function(content, node, options) {
return '$' + $('.katex-mathml annotation[encoding="application/x-tex"]', node).html() + '$';
}
});
turndownService.addRule('katexInline', {
filter: function(node) {
return node.nodeName === 'SPAN' && node.getAttribute('class') === 'katex-display';
},
escapeContent: function() {
return false;
},
replacement: function(content, node, options) {
return '$$\n' + $('.katex-mathml annotation[encoding="application/x-tex"]', node).html() + '\n$$';
}
});
$(document).ready(function() {
$('#html').on('input', function() {
$('#markdown').val(turndownService.turndown($('#html').val()));