Open freezernick opened 4 years ago
Hmm.... Yeah, the array thing looks like the most doable thing. Indeed, the system must be sure the same closure is used as for opening (which is what Lua, Python, JavaScript and so on require as well). Not sure if a struct is needed for that, but it could be an idea...
An alternative to a struct would be comparing the indexes of the string start and string end arrays. But I think with a struct there is more flexibility and it can also be used for #5
Yeah, when it comes to multi-line strings we gotta deal with that not all languages have the same approach for that. In python that is 3x" (also used for multi-line comments) and Lua uses [[ and ]] (and when prefixing [[ with -- you get a multi-line comment), and C# uses @" for the opening and just a " for the closing.... With that taken in mind a struct could be an idea... I gotta admit the current string detector is very primitive...
It seems to work =)
I'll only have to add the structs to the missing languages and do some testing with other languages. Then I'll adapt this a bit for #5 probably
For Python try 3x " and not 3x' I do not know if ''' is accepted but """ is... Now my Python is a bit rusty... :) The single line strings look cool ;)
Closes #7 and closes #5
I consider changing converting
to something like an string array or list
This would be more in line with how I will probably handle the markdown parsing. It would also increase the maintainability of the code, since nobody would have to add another case to the parser if there would be the need for a third string start / end.
EDIT: Just thinking about it, I realized that this is not possible since there is no way to know which start matches which end. Maybe a list of structs
stringDelimiterPair
? 😋EDIT2: I will implement #5 with this PR too
I will mark the PR as draft until this is done