mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 23:41:29 +00:00
markdown improvements
This commit is contained in:
@@ -287,15 +287,15 @@ proc whichMsgClass*(k: TMsgKind): TMsgClass =
|
||||
of 'h', 'H': result = mcHint
|
||||
else: assert false, "msgkind does not fit naming scheme"
|
||||
|
||||
proc defaultMsgHandler(filename: string, line, col: int, msgkind: TMsgKind,
|
||||
arg: string) =
|
||||
proc defaultMsgHandler*(filename: string, line, col: int, msgkind: TMsgKind,
|
||||
arg: string) {.procvar.} =
|
||||
let mc = msgKind.whichMsgClass
|
||||
let a = messages[msgKind] % arg
|
||||
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
||||
if mc == mcError: raise newException(EParseError, message)
|
||||
else: Writeln(stdout, message)
|
||||
|
||||
proc defaultFindFile(filename: string): string =
|
||||
proc defaultFindFile*(filename: string): string {.procvar.} =
|
||||
if existsFile(filename): result = filename
|
||||
else: result = ""
|
||||
|
||||
@@ -386,7 +386,7 @@ proc findSub(p: var TRstParser, n: PRstNode): int =
|
||||
for i in countup(0, high(p.s.subs)):
|
||||
if cmpIgnoreStyle(key, p.s.subs[i].key) == 0:
|
||||
return i
|
||||
result = - 1
|
||||
result = -1
|
||||
|
||||
proc setSub(p: var TRstParser, key: string, value: PRstNode) =
|
||||
var length = len(p.s.subs)
|
||||
@@ -550,7 +550,7 @@ proc parsePostfix(p: var TRstParser, n: PRstNode): PRstNode =
|
||||
result = n
|
||||
if isInlineMarkupEnd(p, "_"):
|
||||
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 b = newRstNode(rnInner)
|
||||
fixupEmbeddedRef(n, a, b)
|
||||
@@ -711,7 +711,7 @@ proc parseMarkdownCodeblock(p: var TRstParser): PRstNode =
|
||||
rstMessage(p, meExpected, "```")
|
||||
break
|
||||
of tkPunct:
|
||||
if isInlineMarkupEnd(p, "```"):
|
||||
if p.tok[p.idx].symbol == "```":
|
||||
inc(p.idx)
|
||||
break
|
||||
else:
|
||||
@@ -745,7 +745,7 @@ proc parseInline(p: var TRstParser, father: PRstNode) =
|
||||
var n = newRstNode(rnEmphasis)
|
||||
parseUntil(p, n, "*", true)
|
||||
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)
|
||||
add(father, parseMarkdownCodeblock(p))
|
||||
elif isInlineMarkupStart(p, "``"):
|
||||
|
||||
@@ -685,7 +685,8 @@ proc rstToHtml*(s: string, options: TRstParseOptions,
|
||||
|
||||
const filen = "input"
|
||||
var d: TRstGenerator
|
||||
initRstGenerator(d, outHtml, config, filen, options, myFindFile, nil)
|
||||
initRstGenerator(d, outHtml, config, filen, options, myFindFile,
|
||||
rst.defaultMsgHandler)
|
||||
var dummyHasToc = false
|
||||
var rst = rstParse(s, filen, 0, 1, dummyHasToc, options)
|
||||
result = ""
|
||||
|
||||
2
todo.txt
2
todo.txt
@@ -1,7 +1,6 @@
|
||||
version 0.9.0
|
||||
=============
|
||||
|
||||
- docgen: markdown support
|
||||
- make templates hygienic by default
|
||||
- ``bind`` for overloaded symbols does not work apparently
|
||||
- ``=`` 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
|
||||
- make exceptions compatible with C++ exceptions
|
||||
- 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;
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user