Remove regex from comment processing
This commit is contained in:
parent
ffd6b9b5eb
commit
a0ecf4d216
1 changed files with 8 additions and 4 deletions
|
|
@ -1,7 +1,5 @@
|
|||
import sets, strformat, strutils
|
||||
|
||||
import regex
|
||||
|
||||
import "."/[getters, globals]
|
||||
import "."/treesitter/[api, c, cpp]
|
||||
|
||||
|
|
@ -273,8 +271,14 @@ proc getCommentsStr*(gState: State, commentNodes: seq[TSNode]): string =
|
|||
for commentNode in commentNodes:
|
||||
result &= "\n " & gState.getNodeVal(commentNode).strip()
|
||||
|
||||
result = result.replace(re" *(//|/\*\*|\*\*/|/\*|\*/|\*)", "")
|
||||
result = result.multiReplace([("\n", "\n "), ("`", "")]).strip()
|
||||
result = result.multiReplace(
|
||||
{
|
||||
"/**": "", "**/": "", "/*": "",
|
||||
"*/": "", "/*": "", "//": "",
|
||||
"\n": "\n ", "`": ""
|
||||
}
|
||||
# need to replace this last otherwise it supercedes other replacements
|
||||
).replace(" *", "").strip()
|
||||
|
||||
proc getCommentNodes*(gState: State, node: TSNode, maxSearch=1): seq[TSNode] =
|
||||
## Get a set of comment nodes in order of priority. Will search up to ``maxSearch``
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue