Regex Chunking #895
Labels
Area: Meta
Pertaining to build system, test system, infrastructure, code health, and the project itself.
Issue: Task
Not a bug. Even not a new feature. But we really need to do something.
Proposal
There is a significant amount if regex throughout the code base. It would seem sensible the move all these to a common file / object from where they can be called. The benefit of this would be easier testing of the regex expressions and consistency in expression handling (such as with whitespace).
This requires 3 main things:
/[ ]/
/( )/
linkLabel
regex is defined then it should be used in:That's a fairly significant effort, but less than a full syntax parser.
Personally my focus is on the completion code but this should be applicable globally.
regex vs string.raw
Using regex gives clearer code as its syntax highlighted
But regex is hard to work with for concatenation. My main thought here is handling incomplete regex, For example say we define
reg.whiteSpace
and we want to check for up to 3 of then,\{0,3}\
is not valid regex. So it would need to get wrapped in a quantifier functionregQuant(reg.whiteSpace, 0, 3)
before concatenation with other regex chunks. I think this will end up being less readable than the string.raw equivalent. But possibly not.References
vscode-markdown/src/tableFormatter.ts
Lines 54 to 69 in 51ed4fb
The text was updated successfully, but these errors were encountered: