rst: remove roSkipPounds option (#18175)
This commit is contained in:
parent
295429f425
commit
9c0666e0bb
1 changed files with 4 additions and 24 deletions
|
|
@ -201,8 +201,6 @@ from highlite import SourceLanguage, getSourceLanguage
|
||||||
|
|
||||||
type
|
type
|
||||||
RstParseOption* = enum ## options for the RST parser
|
RstParseOption* = enum ## options for the RST parser
|
||||||
roSkipPounds, ## skip ``#`` at line beginning (documentation
|
|
||||||
## embedded in Nim comments)
|
|
||||||
roSupportSmilies, ## make the RST parser support smilies like ``:)``
|
roSupportSmilies, ## make the RST parser support smilies like ``:)``
|
||||||
roSupportRawDirective, ## support the ``raw`` directive (don't support
|
roSupportRawDirective, ## support the ``raw`` directive (don't support
|
||||||
## it for sandboxing)
|
## it for sandboxing)
|
||||||
|
|
@ -307,7 +305,6 @@ type
|
||||||
buf*: cstring
|
buf*: cstring
|
||||||
bufpos*: int
|
bufpos*: int
|
||||||
line*, col*, baseIndent*: int
|
line*, col*, baseIndent*: int
|
||||||
skipPounds*: bool
|
|
||||||
adornmentLine*: bool
|
adornmentLine*: bool
|
||||||
escapeNext*: bool
|
escapeNext*: bool
|
||||||
|
|
||||||
|
|
@ -380,9 +377,6 @@ proc getIndentAux(L: var Lexer, start: int): int =
|
||||||
else: inc pos
|
else: inc pos
|
||||||
elif L.buf[pos] == '\n':
|
elif L.buf[pos] == '\n':
|
||||||
inc pos
|
inc pos
|
||||||
if L.skipPounds:
|
|
||||||
if L.buf[pos] == '#': inc pos
|
|
||||||
if L.buf[pos] == '#': inc pos
|
|
||||||
while true:
|
while true:
|
||||||
case L.buf[pos]
|
case L.buf[pos]
|
||||||
of ' ', '\v', '\f':
|
of ' ', '\v', '\f':
|
||||||
|
|
@ -447,26 +441,13 @@ proc rawGetTok(L: var Lexer, tok: var Token) =
|
||||||
inc L.col
|
inc L.col
|
||||||
tok.col = max(tok.col - L.baseIndent, 0)
|
tok.col = max(tok.col - L.baseIndent, 0)
|
||||||
|
|
||||||
proc getTokens(buffer: string, skipPounds: bool, tokens: var TokenSeq): int =
|
proc getTokens(buffer: string, tokens: var TokenSeq): int =
|
||||||
var L: Lexer
|
var L: Lexer
|
||||||
var length = tokens.len
|
var length = tokens.len
|
||||||
L.buf = cstring(buffer)
|
L.buf = cstring(buffer)
|
||||||
L.line = 0 # skip UTF-8 BOM
|
L.line = 0 # skip UTF-8 BOM
|
||||||
if L.buf[0] == '\xEF' and L.buf[1] == '\xBB' and L.buf[2] == '\xBF':
|
if L.buf[0] == '\xEF' and L.buf[1] == '\xBB' and L.buf[2] == '\xBF':
|
||||||
inc L.bufpos, 3
|
inc L.bufpos, 3
|
||||||
L.skipPounds = skipPounds
|
|
||||||
if skipPounds:
|
|
||||||
if L.buf[L.bufpos] == '#':
|
|
||||||
inc L.bufpos
|
|
||||||
inc result
|
|
||||||
if L.buf[L.bufpos] == '#':
|
|
||||||
inc L.bufpos
|
|
||||||
inc result
|
|
||||||
L.baseIndent = 0
|
|
||||||
while L.buf[L.bufpos] == ' ':
|
|
||||||
inc L.bufpos
|
|
||||||
inc L.baseIndent
|
|
||||||
inc result
|
|
||||||
while true:
|
while true:
|
||||||
inc length
|
inc length
|
||||||
setLen(tokens, length)
|
setLen(tokens, length)
|
||||||
|
|
@ -2123,7 +2104,7 @@ proc parseSimpleTable(p: var RstParser): PRstNode =
|
||||||
q.col = cols[j]
|
q.col = cols[j]
|
||||||
q.line = line - 1
|
q.line = line - 1
|
||||||
q.filename = p.filename
|
q.filename = p.filename
|
||||||
q.col += getTokens(row[j], false, q.tok)
|
q.col += getTokens(row[j], q.tok)
|
||||||
b = newRstNode(rnTableDataCell)
|
b = newRstNode(rnTableDataCell)
|
||||||
b.add(parseDoc(q))
|
b.add(parseDoc(q))
|
||||||
a.add(b)
|
a.add(b)
|
||||||
|
|
@ -2176,7 +2157,7 @@ proc parseMarkdownTable(p: var RstParser): PRstNode =
|
||||||
q.col = p.col
|
q.col = p.col
|
||||||
q.line = currentTok(p).line - 1
|
q.line = currentTok(p).line - 1
|
||||||
q.filename = p.filename
|
q.filename = p.filename
|
||||||
q.col += getTokens(getColContents(p, row[j]), false, q.tok)
|
q.col += getTokens(getColContents(p, row[j]), q.tok)
|
||||||
b.add(parseDoc(q))
|
b.add(parseDoc(q))
|
||||||
a.add(b)
|
a.add(b)
|
||||||
result.add(a)
|
result.add(a)
|
||||||
|
|
@ -2584,7 +2565,6 @@ proc dirInclude(p: var RstParser): PRstNode =
|
||||||
q.filename = path
|
q.filename = path
|
||||||
q.col += getTokens(
|
q.col += getTokens(
|
||||||
inputString[startPosition..endPosition].strip(),
|
inputString[startPosition..endPosition].strip(),
|
||||||
false,
|
|
||||||
q.tok)
|
q.tok)
|
||||||
# workaround a GCC bug; more like the interior pointer bug?
|
# workaround a GCC bug; more like the interior pointer bug?
|
||||||
#if find(q.tok[high(q.tok)].symbol, "\0\x01\x02") > 0:
|
#if find(q.tok[high(q.tok)].symbol, "\0\x01\x02") > 0:
|
||||||
|
|
@ -2948,7 +2928,7 @@ proc rstParse*(text, filename: string,
|
||||||
initParser(p, newSharedState(options, findFile, msgHandler))
|
initParser(p, newSharedState(options, findFile, msgHandler))
|
||||||
p.filename = filename
|
p.filename = filename
|
||||||
p.line = line
|
p.line = line
|
||||||
p.col = column + getTokens(text, roSkipPounds in options, p.tok)
|
p.col = column + getTokens(text, p.tok)
|
||||||
let unresolved = parseDoc(p)
|
let unresolved = parseDoc(p)
|
||||||
countTitles(p, unresolved)
|
countTitles(p, unresolved)
|
||||||
orderFootnotes(p)
|
orderFootnotes(p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue