Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: breakage in transform blockquotes function removes some html tags #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bayang
Copy link
Contributor

@bayang bayang commented May 6, 2023

Initially when rendering some pages I noticed there was no styling applied, or only partially applied.

By examining the html I noticed some tags from the nunjuck template file were missing.
For example : the main tag had been stripped off but not the content of my note, and since come of the css classes are applied on the main element the page had only partial styling.

The pages looked like the capture on this issue : oleeskild/obsidian-digital-garden#294

Actually after doing some research, I found that the node html parser was silently failing to parse some content and that the resulting html was missing some tags.

To fix the function I needed to replace the parser, so I took the first one from npm that didn't fail on the generated html from my markdown note.
I took cheerio, I don't know if that is suitable for you.

The fix has been pushed on my dev garden : https://github.com/bayang/garden-dev

the node html parser fails to parse some content
and the resulting html is missing some tags
@oleeskild
Copy link
Owner

Thanks for investigating this, and taking the time to create a PR 🙌

The reason the template is using node-html-parser is because it is significantly faster and "lighter" than cheerio. (See https://www.npmjs.com/package/node-html-parser).
That said, slow performance but correct output is better than fast performance and incorrect output.
But maybe we can find a way to fix this without using cheerio. Can you provide me an example of a note that gets broken by pasting it here?

@bayang
Copy link
Contributor Author

bayang commented May 22, 2023

Hmm, I think I used the notes in my dev garden to reproduce

https://github.com/bayang/garden-dev/tree/main/src/site/notes,

but I can't remember if the notes content is still "wrong".
Try with the test.md note at first, I think this one will fail.
To advance on my debugging I first called the valid method of the node parser (visible in the npm link ypu pasted above)
This method call returned false for my notes, so I guess the parser considers the html generated by the markdown renderer to be invalid.

I'll try to find more infos if I have some notes.
If I recall correctly the main tag of the html is swallowed by the parser.
You can inspect this page html to see that the main tag is not present :
https://notes.thatother.dev/physics/standard-model/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants