updated the compiler to use the new symbol names
This commit is contained in:
parent
c68c42a237
commit
5946747970
30 changed files with 307 additions and 114 deletions
|
|
@ -66,8 +66,8 @@ proc getArgument*(n: PRstNode): string
|
|||
# ----------------------------- scanner part --------------------------------
|
||||
|
||||
const
|
||||
SymChars: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'}
|
||||
SmileyStartChars: TCharSet = {':', ';', '8'}
|
||||
SymChars: set[char] = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'}
|
||||
SmileyStartChars: set[char] = {':', ';', '8'}
|
||||
Smilies = {
|
||||
":D": "icon_e_biggrin",
|
||||
":-D": "icon_e_biggrin",
|
||||
|
|
@ -111,7 +111,7 @@ const
|
|||
type
|
||||
TTokType = enum
|
||||
tkEof, tkIndent, tkWhite, tkWord, tkAdornment, tkPunct, tkOther
|
||||
TToken{.final.} = object # a RST token
|
||||
TToken = object # a RST token
|
||||
kind*: TTokType # the type of the token
|
||||
ival*: int # the indentation or parsed integer value
|
||||
symbol*: string # the parsed symbol as string
|
||||
|
|
@ -125,7 +125,7 @@ type
|
|||
skipPounds*: bool
|
||||
|
||||
|
||||
proc getThing(L: var TLexer, tok: var TToken, s: TCharSet) =
|
||||
proc getThing(L: var TLexer, tok: var TToken, s: set[char]) =
|
||||
tok.kind = tkWord
|
||||
tok.line = L.line
|
||||
tok.col = L.col
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ proc renderRstToRst*(n: PRstNode, result: var string) =
|
|||
var d: TRenderContext
|
||||
renderRstToRst(d, n, result)
|
||||
|
||||
proc renderRstToJsonNode(node: PRstNode): PJsonNode =
|
||||
proc renderRstToJsonNode(node: PRstNode): JsonNode =
|
||||
result =
|
||||
%[
|
||||
(key: "kind", val: %($node.kind)),
|
||||
|
|
@ -295,7 +295,7 @@ proc renderRstToJsonNode(node: PRstNode): PJsonNode =
|
|||
if node.text != nil:
|
||||
result.add("text", %node.text)
|
||||
if node.sons != nil and len(node.sons) > 0:
|
||||
var accm = newSeq[PJsonNode](len(node.sons))
|
||||
var accm = newSeq[JsonNode](len(node.sons))
|
||||
for i, son in node.sons:
|
||||
accm[i] = renderRstToJsonNode(son)
|
||||
result.add("sons", %accm)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ type
|
|||
outHtml, # output is HTML
|
||||
outLatex # output is Latex
|
||||
|
||||
TTocEntry{.final.} = object
|
||||
TTocEntry = object
|
||||
n*: PRstNode
|
||||
refname*, header*: string
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ type
|
|||
|
||||
TRstGenerator* = object of RootObj
|
||||
target*: TOutputTarget
|
||||
config*: PStringTable
|
||||
config*: StringTableRef
|
||||
splitAfter*: int # split too long entries in the TOC
|
||||
tocPart*: seq[TTocEntry]
|
||||
hasToc*: bool
|
||||
|
|
@ -57,21 +57,21 @@ type
|
|||
currentSection: string ## \
|
||||
## Stores the empty string or the last headline/overline found in the rst
|
||||
## document, so it can be used as a prettier name for term index generation.
|
||||
seenIndexTerms: TTable[string, int] ## \
|
||||
seenIndexTerms: Table[string, int] ## \
|
||||
## Keeps count of same text index terms to generate different identifiers
|
||||
## for hyperlinks. See renderIndexTerm proc for details.
|
||||
|
||||
PDoc = var TRstGenerator ## Alias to type less.
|
||||
|
||||
proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
|
||||
config: PStringTable, filename: string,
|
||||
config: StringTableRef, filename: string,
|
||||
options: TRstParseOptions,
|
||||
findFile: TFindFileHandler,
|
||||
msgHandler: TMsgHandler) =
|
||||
## Initializes a ``TRstGenerator``.
|
||||
##
|
||||
## You need to call this before using a ``TRstGenerator`` with any other
|
||||
## procs in this module. Pass a non ``nil`` ``PStringTable`` value as
|
||||
## procs in this module. Pass a non ``nil`` ``StringTableRef`` value as
|
||||
## `config` with parameters used by the HTML output generator. If you don't
|
||||
## know what to use, pass the results of the `defaultConfig()
|
||||
## <#defaultConfig>_` proc.
|
||||
|
|
@ -341,13 +341,13 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
|
|||
[id, term])
|
||||
|
||||
type
|
||||
TIndexEntry {.pure, final.} = object
|
||||
TIndexEntry = object
|
||||
keyword: string
|
||||
link: string
|
||||
linkTitle: string ## If not nil, contains a prettier text for the href
|
||||
linkDesc: string ## If not nil, the title attribute of the final href
|
||||
|
||||
TIndexedDocs {.pure, final.} = TTable[TIndexEntry, seq[TIndexEntry]] ## \
|
||||
TIndexedDocs = Table[TIndexEntry, seq[TIndexEntry]] ## \
|
||||
## Contains the index sequences for doc types.
|
||||
##
|
||||
## The key is a *fake* TIndexEntry which will contain the title of the
|
||||
|
|
@ -1048,10 +1048,10 @@ proc formatNamedVars*(frmt: string, varnames: openArray[string],
|
|||
if i-1 >= start: add(result, substr(frmt, start, i - 1))
|
||||
|
||||
|
||||
proc defaultConfig*(): PStringTable =
|
||||
proc defaultConfig*(): StringTableRef =
|
||||
## Returns a default configuration for embedded HTML generation.
|
||||
##
|
||||
## The returned ``PStringTable`` contains the paramters used by the HTML
|
||||
## The returned ``StringTableRef`` contains the paramters used by the HTML
|
||||
## engine to build the final output. For information on what these parameters
|
||||
## are and their purpose, please look up the file ``config/nimdoc.cfg``
|
||||
## bundled with the compiler.
|
||||
|
|
@ -1113,7 +1113,7 @@ $content
|
|||
# ---------- forum ---------------------------------------------------------
|
||||
|
||||
proc rstToHtml*(s: string, options: TRstParseOptions,
|
||||
config: PStringTable): string =
|
||||
config: StringTableRef): string =
|
||||
## Converts an input rst string into embeddable HTML.
|
||||
##
|
||||
## This convenience proc parses any input string using rst markup (it doesn't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue