Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Add custom rules to avoid escaping characters
Browse files Browse the repository at this point in the history
This commit adds custom rules to prevent the escaping
within italics, bold, and <p> tags.
It should leave intact any <font> and <span> tags
  • Loading branch information
argenos committed Mar 28, 2021
1 parent daf4029 commit 61b44f0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/markdown-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,42 @@ function getConverter(){
emDelimiter: Zotero.Prefs.get('extensions.mdnotes.html2md.default.em', true)
})

converter.addRule('p', {
filter: 'p',
replacement: function (content) {
return '\n\n' + content + '\n\n'
},
escapeContent: function() {
return false;
},
})

converter.addRule('emphasis', {
filter: ['em', 'i'],

replacement: function (content, node, options) {
if (!content.trim()) return ''
return options.emDelimiter + content + options.emDelimiter
},
escapeContent: function() {
return false;
},
})

converter.addRule('strong', {
filter: ['strong', 'b'],

replacement: function (content, node, options) {
if (!content.trim()) return ''
return options.strongDelimiter + content + options.strongDelimiter
},
escapeContent: function() {
return false;
},
})

converter.keep(['span', 'font'])

converter.addRule('strikethrough', {
// filter: ['del', 's', 'strike'],
filter: function (node) {
Expand Down

0 comments on commit 61b44f0

Please sign in to comment.