You are browsing as a guest. Sign up (or log in) to start making projects!

1h 31m 58s logged

revamp!

i revamped the parse-input.js file! now, it has two functions:

  1. 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 fields type, tag,
    nesting, content, and children. as for this children field, 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 :yayayayayay:
    )

  2. 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 MarkdownIt constructor (? 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 the markdown-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!

Changelog

0
15

Comments 0

No comments yet. Be the first!