markdown improvements
This commit is contained in:
parent
338b3cc683
commit
2f17c264f4
3 changed files with 10 additions and 9 deletions
|
|
@ -287,15 +287,15 @@ proc whichMsgClass*(k: TMsgKind): TMsgClass =
|
||||||
of 'h', 'H': result = mcHint
|
of 'h', 'H': result = mcHint
|
||||||
else: assert false, "msgkind does not fit naming scheme"
|
else: assert false, "msgkind does not fit naming scheme"
|
||||||
|
|
||||||
proc defaultMsgHandler(filename: string, line, col: int, msgkind: TMsgKind,
|
proc defaultMsgHandler*(filename: string, line, col: int, msgkind: TMsgKind,
|
||||||
arg: string) =
|
arg: string) {.procvar.} =
|
||||||
let mc = msgKind.whichMsgClass
|
let mc = msgKind.whichMsgClass
|
||||||
let a = messages[msgKind] % arg
|
let a = messages[msgKind] % arg
|
||||||
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
||||||
if mc == mcError: raise newException(EParseError, message)
|
if mc == mcError: raise newException(EParseError, message)
|
||||||
else: Writeln(stdout, message)
|
else: Writeln(stdout, message)
|
||||||
|
|
||||||
proc defaultFindFile(filename: string): string =
|
proc defaultFindFile*(filename: string): string {.procvar.} =
|
||||||
if existsFile(filename): result = filename
|
if existsFile(filename): result = filename
|
||||||
else: result = ""
|
else: result = ""
|
||||||
|
|
||||||
|
|
@ -386,7 +386,7 @@ proc findSub(p: var TRstParser, n: PRstNode): int =
|
||||||
for i in countup(0, high(p.s.subs)):
|
for i in countup(0, high(p.s.subs)):
|
||||||
if cmpIgnoreStyle(key, p.s.subs[i].key) == 0:
|
if cmpIgnoreStyle(key, p.s.subs[i].key) == 0:
|
||||||
return i
|
return i
|
||||||
result = - 1
|
result = -1
|
||||||
|
|
||||||
proc setSub(p: var TRstParser, key: string, value: PRstNode) =
|
proc setSub(p: var TRstParser, key: string, value: PRstNode) =
|
||||||
var length = len(p.s.subs)
|
var length = len(p.s.subs)
|
||||||
|
|
@ -550,7 +550,7 @@ proc parsePostfix(p: var TRstParser, n: PRstNode): PRstNode =
|
||||||
result = n
|
result = n
|
||||||
if isInlineMarkupEnd(p, "_"):
|
if isInlineMarkupEnd(p, "_"):
|
||||||
inc(p.idx)
|
inc(p.idx)
|
||||||
if (p.tok[p.idx - 2].symbol == "`") and (p.tok[p.idx - 3].symbol == ">"):
|
if p.tok[p.idx-2].symbol == "`" and p.tok[p.idx-3].symbol == ">":
|
||||||
var a = newRstNode(rnInner)
|
var a = newRstNode(rnInner)
|
||||||
var b = newRstNode(rnInner)
|
var b = newRstNode(rnInner)
|
||||||
fixupEmbeddedRef(n, a, b)
|
fixupEmbeddedRef(n, a, b)
|
||||||
|
|
@ -711,7 +711,7 @@ proc parseMarkdownCodeblock(p: var TRstParser): PRstNode =
|
||||||
rstMessage(p, meExpected, "```")
|
rstMessage(p, meExpected, "```")
|
||||||
break
|
break
|
||||||
of tkPunct:
|
of tkPunct:
|
||||||
if isInlineMarkupEnd(p, "```"):
|
if p.tok[p.idx].symbol == "```":
|
||||||
inc(p.idx)
|
inc(p.idx)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
@ -745,7 +745,7 @@ proc parseInline(p: var TRstParser, father: PRstNode) =
|
||||||
var n = newRstNode(rnEmphasis)
|
var n = newRstNode(rnEmphasis)
|
||||||
parseUntil(p, n, "*", true)
|
parseUntil(p, n, "*", true)
|
||||||
add(father, n)
|
add(father, n)
|
||||||
elif roSupportMarkdown in p.s.options and isInlineMarkupStart(p, "```"):
|
elif roSupportMarkdown in p.s.options and p.tok[p.idx].symbol == "```":
|
||||||
inc(p.idx)
|
inc(p.idx)
|
||||||
add(father, parseMarkdownCodeblock(p))
|
add(father, parseMarkdownCodeblock(p))
|
||||||
elif isInlineMarkupStart(p, "``"):
|
elif isInlineMarkupStart(p, "``"):
|
||||||
|
|
|
||||||
|
|
@ -685,7 +685,8 @@ proc rstToHtml*(s: string, options: TRstParseOptions,
|
||||||
|
|
||||||
const filen = "input"
|
const filen = "input"
|
||||||
var d: TRstGenerator
|
var d: TRstGenerator
|
||||||
initRstGenerator(d, outHtml, config, filen, options, myFindFile, nil)
|
initRstGenerator(d, outHtml, config, filen, options, myFindFile,
|
||||||
|
rst.defaultMsgHandler)
|
||||||
var dummyHasToc = false
|
var dummyHasToc = false
|
||||||
var rst = rstParse(s, filen, 0, 1, dummyHasToc, options)
|
var rst = rstParse(s, filen, 0, 1, dummyHasToc, options)
|
||||||
result = ""
|
result = ""
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -1,7 +1,6 @@
|
||||||
version 0.9.0
|
version 0.9.0
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- docgen: markdown support
|
|
||||||
- make templates hygienic by default
|
- make templates hygienic by default
|
||||||
- ``bind`` for overloaded symbols does not work apparently
|
- ``bind`` for overloaded symbols does not work apparently
|
||||||
- ``=`` should be overloadable; requires specialization for ``=``
|
- ``=`` should be overloadable; requires specialization for ``=``
|
||||||
|
|
@ -24,6 +23,7 @@ version 0.9.0
|
||||||
- we need to support iteration of 2 different data structures in parallel
|
- we need to support iteration of 2 different data structures in parallel
|
||||||
- make exceptions compatible with C++ exceptions
|
- make exceptions compatible with C++ exceptions
|
||||||
- change how comments are part of the AST
|
- change how comments are part of the AST
|
||||||
|
- extract nimdoc properly and document it finally
|
||||||
- rethink the syntax: distinction between expr and stmt is unfortunate;
|
- rethink the syntax: distinction between expr and stmt is unfortunate;
|
||||||
indentation handling is quite complex too; problem with exception handling
|
indentation handling is quite complex too; problem with exception handling
|
||||||
is that often the scope of ``try`` is wrong and apart from that ``try`` is
|
is that often the scope of ``try`` is wrong and apart from that ``try`` is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue