laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.52k stars 4.95k forks source link

bug(turndown-plugin-gfm): incompatible with original turndown #10328

Open flaviut opened 5 months ago

flaviut commented 5 months ago

Operating system

macOS

Joplin version

n/a

Desktop version info

n/a

Current behaviour

This commit https://github.com/laurent22/joplin/commit/832e9454c77a285828b7ebb36784716696231879 adds a new function to turndown - https://github.com/laurent22/joplin/commit/832e9454c77a285828b7ebb36784716696231879#diff-582d99eae9ac2e71f31737a47dcffa472aa1932ce7a04a78608f11c368406bbbR150 then references the function here: https://github.com/laurent22/joplin/commit/832e9454c77a285828b7ebb36784716696231879#diff-0d19da1f333aad24ea14096ec7f96319837830a1b9398112215a9ec9d40d9b81R226 and finally here: https://github.com/laurent22/joplin/commit/832e9454c77a285828b7ebb36784716696231879#diff-0d19da1f333aad24ea14096ec7f96319837830a1b9398112215a9ec9d40d9b81R164

But, that function is not available if using @joplin/turndown-plugin-gfm, resulting in the following exception:

readerMode.bundle.js:50248 TypeError: isCodeBlock_ is not a function
    at nodeContains (readerMode.bundle.js:218:29)
    at tableShouldBeHtml (readerMode.bundle.js:247:10)
    at Object.filter (readerMode.bundle.js:127:42)
    at filterValue (readerMode.bundle.js:88022:16)
    at findRule (readerMode.bundle.js:88010:9)
    at Rules.forNode (readerMode.bundle.js:87995:17)
    at TurndownService.replacementForNode (readerMode.bundle.js:88528:25)
    at readerMode.bundle.js:88493:40
    at NodeList.reduce (<anonymous>)
    at TurndownService.process (readerMode.bundle.js:88486:17)

Expected behaviour

Proposed solutions:

  1. Document clearly that @joplin/turndown-plugin-gfm is not compatible with the original turndown and that @joplin/turndown should be used instead
  2. Maintain compatibility with turndown. In this case it is quite simple - replace the function call with conditional function call isCodeBlock_?.(child). Thougho there cases (if there are any) might not be as simple

Logs

No response

flaviut commented 5 months ago

Dupe of https://github.com/laurent22/joplin/issues/9881

laurent22 commented 5 months ago

A pull request for this would be welcome, especially if you've already identified where the problem is in the code

github-actions[bot] commented 4 months ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.