revamp!
i revamped the parse-input.js file! now, it has two functions:
-
giveFields(obj)
this is a function called by the second function. since markdown-it
(the parser im using now!) has a lot of fields that i don’t need. so
this function returns a mapped array with the fieldstype,tag,
nesting,content, andchildren. as for thischildrenfield, the
children field is an array of objects, where the objects are just like
the parent object, with lots of unnecessary fields. for those, i used
recursion! (it’s my first time using recursion
) -
parse(input):
this is the function that i’ll be using to get the tokens i need to
style! what it does is pretty simple:
- initialize a new instance of the
MarkdownItconstructor (? i’m not
too sure if it’s a constructor) - get
markdown-it’s tokens using their parsing function - make a constant whose content is an array of objects returned by the
first function (giveFields()if your memory is that terrible). again
its a mapped array that gives only select fields from themarkdown-it
tokens - return that constant
in other news, i wrote 2 more test markdown files. one tests the
behaviour of headings and the other tests the behaviour of inline stuff like bold and italic text!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.