quick let's make a somewhat markdowny thing that isn't good!
I don't know! It's an example of something. And it's not incredibly large. Like I guess I kind of want to have a smallish example that touches on some of the things I usually run into with these kinds of things...
Anyway we're going translate from our thing to the Hypertext Markup Language. So:
We can test it:
Okay.
A ton of functionality:
Two levels of headings, # and ##.
Preformatted text. Lines that start with two spaces.
Lists. List items are lines that start with *.
Empty lines!!!
Regular text paragraphs.
In some kind of order:
Test:
Looks probably good.
We're only doing "document structure" stuff here, so that's almost it. (We can pretend that we're doing something more sophisticated with the bits of text, like maybe we're having special text formatting syntax and maybe support for links. Won't bother actually doing any of that. But we can pretend.)
Opening and closing things and switching between our states:
Let's try:
Mlep.
The code is Lua code btw.
actually let's do formatting and links too
More finicky and less interesting. But, for "completeness" I guess.
We'll have links:
And code (`) and emphasis (_).
This is the finicky bit. It's probably not done very well. But the idea is to loop through str by looking for the next interesting character in the string (str:find("[_`\\^]", startpos)) and handle:
Escaping characters with \.
Switching between the different formatting modes, and handing strings over to the different functions in that table.
Collecting the results in one table, res, that can be concated at the end.
Oh well. We'll try with and without using the new function: