-
Notifications
You must be signed in to change notification settings - Fork 109
Better whitespace handling, parse and keep where allowed #2720
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
Conversation
Adjusted test cases to test whitespace characters are not touched. Signed-off-by: Ferdinand Thiessen <[email protected]>
Switch to @hedgedoc/markdown-it-task-lists to fix parsing of task lists, namely allowing any whitespace inside the brackets, as by the github markdown specs. Doing this as markdown-it-task-lists seems orphaned, while hedgedoc is maintained and the bug is fixed there. This required adjusting the task-list testcase as the output is slightly different. Signed-off-by: Ferdinand Thiessen <[email protected]>
|
/compile amend |
Signed-off-by: Ferdinand Thiessen <[email protected]> Signed-off-by: nextcloud-command <[email protected]>
c9b439d to
75cc0b8
Compare
juliusknorr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks for the effort on this 👍
| * @param {string} cls Class name to query | ||
| */ | ||
| function includesClass(token, cls) { | ||
| return token.attrGet('class')?.split(' ').includes(cls) || false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid .split(' ')
https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/String/includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not realy as that would match if the queried class name is part of another class, consider this:
token = {
class: "foo-bar left"
}
includesClass(token, "bar")without the split this would return true even if bar is not a class of that token.
|
I've left just one small comment. |
Summary
Ensure whitespaces in markdown files are preserved where possible,
as mentioned in the issues it is quite annoying to have
textto remove all formatting like new lines and additional spaces.Even if CommonMark allows them they are currently removed as TipTap collapses them (by default) like HTML does it.
So TipTap is now configured to preserve whitespaces where possible.
Also this includes task lists, as the github markdown guides explictily allow any whitespace inside the brackets,
but the current
markdown-itextension did not.So switch to
@hedgedoc/markdown-it-task-liststo fix this parsing of task lists, namely allowing any whitespaceinside the brackets, as by the github markdown specs.
Doing this as markdown-it-task-lists seems orphaned, while hedgedoc is maintained and the bug is fixed there.
This required adjusting the task-list testcase as the output is slightly different.