File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66// 08 Oct 2024 Matthew Giannini Creation
77//
88
9+ using util
10+
911**
1012** A block node.
1113**
@@ -38,10 +40,10 @@ final class Document : Block
3840 new make() { }
3941
4042 ** Get the file this document was generated from, or null if not known
41- File ? file { private set }
43+ internal FileLoc ? locRef { private set }
4244
4345 ** Set the file that was used to generate this document
44- This withFile(File file ) { this .file = file ; return this }
46+ This withFileLoc(FileLoc ? loc ) { this .locRef = loc ; return this }
4547}
4648
4749**************************************************************************
Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ abstract class Node
5757 ** Get the file location for this node from the original parsed source.
5858 ** If the location is not known or source spans were not enabled during
5959 ** parsing, then return `util::FileLoc.unknown`.
60- FileLoc loc()
60+ virtual FileLoc loc()
6161 {
6262 if (sourceSpans.isEmpty) return FileLoc.unknown
63- file := doc?. file ?. name ?: "inputs"
63+ file := doc?. locRef ?. file ?: "inputs"
6464 span := sourceSpans.first
6565 // I think if the best way to report the location is using the first source span
6666 return FileLoc(file, span.lineIndex+ 1 , span.columnIndex+ 1 )
Original file line number Diff line number Diff line change 66// 01 Nov 2024 Matthew Giannini Creation
77//
88
9+ using util
10+
911**
1012** Xetodoc is a curated set of features and extensions to the CommonMark syntax.
1113**
6668 }
6769
6870 ** Convenience to render the given Xetodoc to HTML
69- static Str toHtml(Str source, LinkResolver? linkResolver := null )
71+ static Str toHtml(Str source, LinkResolver? linkResolver := null , FileLoc ? loc := null )
7072 {
71- htmlRenderer.render(parser(linkResolver).parse(source))
73+ htmlRenderer.render(parser(linkResolver).parse(source).withFileLoc(loc) )
7274 }
7375
7476 ** Convenience to render the given node to HTML
Original file line number Diff line number Diff line change 66// 08 Oct 2024 Matthew Giannini Creation
77//
88
9+ using util
10+
911**
1012** Parse input text into a tree of nodes.
1113**
@@ -64,7 +66,7 @@ const class Parser
6466
6567 ** Convenience to parse a file into a `Document`. If source span parsing
6668 ** is enabled the nodes will have access to the file location using `Node.loc`.
67- Document parseFile(File file) { parseStream(file.in).withFile( file) }
69+ Document parseFile(File file) { parseStream(file.in).withFileLoc(FileLoc( file.pathStr) ) }
6870
6971 ** Convenience for 'parseStream(text.in)'
7072 Document parse(Str text) { parseStream(text.in) }
Original file line number Diff line number Diff line change 129129
130130 override Void visitHtmlBlock(HtmlBlock block)
131131 {
132- if (cx.disableHtml) return
132+ if (cx.disableHtml)
133+ {
134+ echo("WARN: ignore block html ${block.loc} " )
135+ return
136+ }
133137
134138 html.line
135139 if (cx.escapeHtml)
228232
229233 override Void visitHtmlInline(HtmlInline inline)
230234 {
231- if (cx.disableHtml) return
235+ if (cx.disableHtml)
236+ {
237+ echo("WARN: ignore inline html ${inline.loc} : ${inline.literal} " )
238+ return
239+ }
232240
233241 if (cx.escapeHtml)
234242 html.text(inline.literal)
You can’t perform that action at this time.
0 commit comments