diff options
author | Miran <narimiran@disroot.org> | 2019-04-10 15:55:57 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-04-10 15:55:57 +0200 |
commit | 1494d88fa27a31b46884799b2ff9712c73937551 (patch) | |
tree | 10560d1d805f2be98f69850efcd8538d115825a8 /lib/packages | |
parent | 2608bc369e5df6535528eb1987eb33b85e532141 (diff) | |
download | Nim-1494d88fa27a31b46884799b2ff9712c73937551.tar.gz |
rst: parse brackets individually, fixes #10475 (#10997)
Diffstat (limited to 'lib/packages')
-rw-r--r-- | lib/packages/docutils/rst.nim | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index 6e4e3f5dd..26222d951 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -115,8 +115,8 @@ const type TokType = enum tkEof, tkIndent, tkWhite, tkWord, tkAdornment, tkPunct, tkOther - Token = object # a RST token - kind*: TokType # the type of the token + Token = object # a RST token + kind*: TokType # the type of the token ival*: int # the indentation or parsed integer value symbol*: string # the parsed symbol as string line*, col*: int # line and column of the token @@ -153,6 +153,14 @@ proc getAdornment(L: var Lexer, tok: var Token) = inc(L.col, pos - L.bufpos) L.bufpos = pos +proc getBracket(L: var Lexer, tok: var Token) = + tok.kind = tkPunct + tok.line = L.line + tok.col = L.col + add(tok.symbol, L.buf[L.bufpos]) + inc L.col + inc L.bufpos + proc getIndentAux(L: var Lexer, start: int): int = var pos = start # skip the newline (but include it in the token!) @@ -205,11 +213,13 @@ proc rawGetTok(L: var Lexer, tok: var Token) = rawGetTok(L, tok) # ignore spaces before \n of '\x0D', '\x0A': getIndent(L, tok) - of '!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', - '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', - '|', '}', '~': + of '!', '\"', '#', '$', '%', '&', '\'', '*', '+', ',', '-', '.', + '/', ':', ';', '<', '=', '>', '?', '@', '\\', '^', '_', '`', + '|', '~': getAdornment(L, tok) if len(tok.symbol) <= 3: tok.kind = tkPunct + of '(', ')', '[', ']', '{', '}': + getBracket(L, tok) else: tok.line = L.line tok.col = L.col @@ -837,7 +847,8 @@ proc parseInline(p: var RstParser, father: PRstNode) = var n = newRstNode(rnSubstitutionReferences) parseUntil(p, n, "|", false) add(father, n) - elif roSupportMarkdown in p.s.options and p.tok[p.idx].symbol == "[" and + elif roSupportMarkdown in p.s.options and + p.tok[p.idx].symbol == "[" and p.tok[p.idx+1].symbol != "[" and parseMarkdownLink(p, father): discard "parseMarkdownLink already processed it" else: |