Skip to content

Commit

Permalink
ignore code-block children of type ul with class pre-numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
wljince007 committed Mar 21, 2024
1 parent 031c040 commit 68b0963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/app-cli/tests/html_to_md/code_multiline_2.md
Expand Up @@ -18,5 +18,4 @@ public class User {
}
}
```
9 changes: 5 additions & 4 deletions packages/turndown/src/commonmark-rules.js
Expand Up @@ -159,7 +159,11 @@ rules.list = {

replacement: function (content, node) {
var parent = node.parentNode
if (parent.nodeName === 'LI' && parent.lastElementChild === node) {
if (parent && isCodeBlock(parent) && node.classList && node.classList.contains('pre-numbering')){
// ignore code-block children of type ul with class pre-numbering
// https://github.com/laurent22/joplin/pull/10126#discussion_r1532204251
return '';
}else if (parent.nodeName === 'LI' && parent.lastElementChild === node) {
return '\n' + content
} else {
return '\n\n' + content + '\n\n'
Expand Down Expand Up @@ -266,9 +270,6 @@ rules.fencedCodeBlock = {

var fence = repeat(fenceChar, fenceSize)

// delete code number lines
code = code.replace(/(^-\s+\d+\s*$\r?\n)+/gm, '');

return (
'\n\n' + fence + language + '\n' +
code.replace(/\n$/, '') +
Expand Down

0 comments on commit 68b0963

Please sign in to comment.