WIP md parser
This commit is contained in:
21
notes/4-markdown-parser-part-2/note.md
Normal file
21
notes/4-markdown-parser-part-2/note.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Markdown parser part 2
|
||||
|
||||
The markdown parser is kind of going according to plan. I realised that with the appoach I decided to take I'm going to need a couple of more steps than just going line by line and deciding what type of element each should be.
|
||||
|
||||
Let's take an example:
|
||||
|
||||
```
|
||||
Some **bold** text and then some _cursive_ text
|
||||
```
|
||||
|
||||
This is not only a text line but it has both bold and cursive text.
|
||||
|
||||
So in addition to parsing the markdown files line by line (stage 1), I implemented stage 2 processing with the purpose of expanding the identified elements into child elements. So when a text row element containing the text in the example above is requested to peform its stage 2 processing it will take its text and run it once more through the stage 1 processing to divide it into new symbols. It then calls stage 2 processing of all its new children to make sure every element has been processed.
|
||||
|
||||
In the end we should have gone from `TextLine` to `PlainText, Bold, PlainText , Italic, Plaintext`.
|
||||
|
||||
Here's the result.
|
||||
|
||||
Some **bold** text and then some _cursive_ text
|
||||
|
||||
Next up is stage 3 processing which will affect elements depending on their position in the list of elements.
|
||||
Reference in New Issue
Block a user