WIP WORK // INCOMPLETE //
this was a lot of work, and i’m still not done with html in the stylizer! here’s a list of changes with explanations:
- add more aliases to the
aliasesarray in the html parsing section: this makes it so that html tokens and markdown tokens have the same types - convert the array of allowed html tags into a
set: sets have a.has()function that lets us find an element in O(1) time complexity which is much faster compared toArray.prototype.includes()which has an O(n) time complexity - properly implement disallowed tags: these tags show as plain text because they are disallowed and shouldn’t be processed in markdown
- put non-block tokens as children of an inline token: non-block tokens only got parsed in the part where inline tokens were processed
- set attributes: the objects returned by the stylize function now have a
propertieskey - better error handling: now, where it used to just throw an error about being
undefinedor whatever, it will catch it, and throw a more useful error with better debug info - [BUGFIX] make sure that arrays don’t get nested: this was a bug where arrays would get nested for some reason
- [BUGFIX] set
token.levelandtoken.nestingproperly when processing html: this is necessary because the while loop depends on the nesting to know when to stop accumulating tokens and process them - [WIP] html handling:
- any tokens having the substring
_openin their.typeproperty
are handled all together, with a handlers object made up of functions.
this handling is recursive - token with types that don’t match the substring
_openget handled
through other branches of the if statement (else if(...) {..})
- any tokens having the substring
- [WIP] bullet list handling: i did not realize that there were more markdown-it tokens that i had not added handling for in the stylize function. i also need to do this for some more token types too
- [WIP] revamp image handling: instead of just a complicated function, i added a class called
Imagethat has a function to render the image. its nearly complete but it has some errors that i committed because i need to commit often lmao
chatpgt usage
now here i used chatgpt a lot for debugging. here’s exactly what i used it for:
- why tokens weren’t being processed: this is the problem the array nesting bugfix fixed
- fixing infinite recursion: i accidentally did that lmfao
- replacing top-level non-block tokens with an inline token that contains those top-level non-block tokens as children
- figuring how to set the
levelproperty of the tokens - questions about syntax and mutation of global vars
Changelog
- (5e931f7) Revamp image function (WIP)
- (0ce066f) Improve error handling and fix
token.levelassignment - (0f28b75) Process details element in stylizer
- (0e154f3) Start improving stylizer (WIP)
why such long devlogs?
you may have noticed i’ve been going more and more time without devlogging. that’s because i like devlogging when there’s a big new thing, not for every small little thing. my plan for this devlog was to announce that i was done with processing html in the stylize function, but that hasn’t happened yet because well, there were a latta bugs here and there, and i had to fix those too. as for the length of the devlog text, i like writing about my progress here because its the only place where it makes sense to talk about it in-depth
Comments 3
please try to include a picture of the code working not the picture of the code iteselfd
@Rupnil bro that’s the code NOT working
lmfao
Sign in to join the conversation.