Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Jul 15, 2022

Summary

Ensure whitespaces in markdown files are preserved where possible,
as mentioned in the issues it is quite annoying to have text to 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-it extension did not.
So switch to @hedgedoc/markdown-it-task-lists to fix this 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.

susnux added 2 commits July 15, 2022 12:34
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]>
@susnux susnux force-pushed the keep-whitespaces branch from 4a1f81b to c9b439d Compare July 15, 2022 10:34
@susnux
Copy link
Contributor Author

susnux commented Jul 15, 2022

/compile amend

Signed-off-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
Copy link
Member

@juliusknorr juliusknorr left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

@vinicius73
Copy link
Member

I've left just one small comment.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants