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

feat(#11): include input checkbox for task lists #12

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

KyleKing
Copy link

@KyleKing KyleKing commented Dec 21, 2024

This is the first go project I've actually worked on, so any guidance would be appreciated! I've been running make test lint locally, but the Emoji test (35) fails and I think my changes are generally the right direction, but I'm not sure what to do to finish the change

Fixes #11

@sivukhin
Copy link
Owner

sivukhin commented Dec 21, 2024

Hi @KyleKing!

Yes, emoji test were broken in the master as tests download fresh HTML from djot syntax spec page (https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html) which recently changed symbols example. I fixed them - so if you will update your fork - this test must be good for now.

Regarding the approach - what do you think if input checkbox will be supported only in the rendering layer? I see drawback in the current approach as new AST for checkboxed-list can make maintenance harder because on one hand - this is new AST node but on the other hand - it must behave just as regular list and the only difference is in the presentation layer.

I would suggest to add this feature only in the rendering layer by extending logic of DefaultConversionRegistry for ListItemNode. But internally all lists will be presented as ListItemNode.

The development flow is simple and you did everything right: make lint test is enough and I didn't setup any more automatic checks. One useful thing can be to run FuzzDjotE2E / FuzzDjotTokenizer tests in fuzzing mode (pass -fuzz argument to the go test command) if you touch parser internals - because its proven (by myself) that mistakes are easy to made in this code :) But for "front-end" rendering part it's not that useful as conversions in this part of the code is pretty straightforward.

@KyleKing KyleKing marked this pull request as ready for review January 2, 2025 20:56
Copy link
Author

@KyleKing KyleKing left a comment

Choose a reason for hiding this comment

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

Ready for review again! Feel free to make changes directly if easier than providing feedback

I also ran fuzz testing locally (go test -fuzz FuzzDjotTokenizer -fuzz FuzzDjotE2E github.com/sivukhin/godjot/djot_parser). I'm not sure how long to let it run, but it ran for two minutes after this fix without finding any new issues.

fuzz: elapsed: 0s, gathering baseline coverage: 0/699 completed
fuzz: elapsed: 0s, gathering baseline coverage: 699/699 completed, now fuzzing with 10 workers
fuzz: elapsed: 3s, execs: 165661 (55208/sec), new interesting: 13 (total: 712)
fuzz: elapsed: 6s, execs: 338017 (57444/sec), new interesting: 26 (total: 725)
...
fuzz: elapsed: 2m6s, execs: 5540830 (33608/sec), new interesting: 191 (total: 890)
^Cfuzz: elapsed: 2m7s, execs: 5553930 (23612/sec), new interesting: 191 (total: 890)
PASS
ok      github.com/sivukhin/godjot/djot_parser  127.064s

Comment on lines 98 to 105
s.Writer.WriteString("\n")
s.Writer.WriteString("<input disabled=\"\" type=\"checkbox\"")
if class == CheckedTaskItemClass {
s.Writer.WriteString(" checked=\"\"")
}
s.Writer.WriteString("/>").WriteString("\n")
n(s.Node.Children[:1])
s.Writer.WriteString("\n")
Copy link
Author

@KyleKing KyleKing Jan 2, 2025

Choose a reason for hiding this comment

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

I finally had a window of time this afternoon and got the tests passing locally!

While this works, I'm not sure if the logic should be generalized (maybe not if this is the only self-closing tag) or for some way to pop Entries (e.g. removing the class from the AST for methods like the BlockNodeConverter). I'll defer to whatever you think is best

`go test -run=FuzzDjotE2E/326270ac6d2da709
github.com/sivukhin/godjot/djot_parser`
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.

Output HTML Checkbox
2 participants