Skip to content

Commit

Permalink
fix: web clipper has trouble with code blocks on Joplin's website, re…
Browse files Browse the repository at this point in the history
…factoring
  • Loading branch information
wljince007 committed Mar 24, 2024
1 parent 60b14ea commit a52a6ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/turndown/src/commonmark-rules.js
Expand Up @@ -493,7 +493,7 @@ rules.code = {

// Fix: Web clipper has trouble with code blocks on Joplin's website.
// See https://github.com/laurent22/joplin/pull/10126#issuecomment-2016523281 .
// Web clipper clippering result is all in oneline, The format features are: <pre ...><code ...><span class="token-line" ...
// Web clipper clippering result is all in oneline. The format features are: <pre ...><code ...><span class="token-line". Span with class of "token-line" represent one line.
// Test case: packages/app-cli/tests/html_to_md/code_multiline_3.html
rules.joplinOrgTokenLineSpan = {
filter: function (node) {
Expand All @@ -503,7 +503,7 @@ rules.joplinOrgTokenLineSpan = {

replacement: function (content, node, options) {
content = content.replace(/\r?\n|\r/g, '');
// If content replaced '\r\n' is empty line, it indicates that the line is empty line; if not, keep the leading before and after the line.
// If content replaced '\r\n' is empty, it indicates that the line is empty line; if not, keep the leading before and after content.
return content === '' ? '\n\n' : node.flankingWhitespace.leading + content + node.flankingWhitespace.trailing + '\n';
}
}
Expand Down

0 comments on commit a52a6ab

Please sign in to comment.