diff options
Diffstat (limited to 'src/html/parser.nim')
-rw-r--r-- | src/html/parser.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/html/parser.nim b/src/html/parser.nim index 105c5d0d..cbc7daa7 100644 --- a/src/html/parser.nim +++ b/src/html/parser.nim @@ -471,7 +471,7 @@ proc processDocumentPart(state: var HTMLParseState, buf: string) = process_char(buf[at]) inc at -proc parseHtml*(inputStream: Stream): Document = +proc parseHtml(inputStream: Stream, savesource: bool, source: var string): Document = let document = newDocument() insertNode(document, document.root) insertNode(document.root, document.head) @@ -487,6 +487,8 @@ proc parseHtml*(inputStream: Stream): Document = var lineBuf: string while not inputStream.atEnd(): lineBuf = inputStream.readLine() & '\n' + if savesource: + source &= lineBuf buf &= lineBuf var at = 0 @@ -507,3 +509,10 @@ proc parseHtml*(inputStream: Stream): Document = inputStream.close() return document + +proc parseHtml*(inputStream: Stream, source: var string): Document = + return parseHtml(inputStream, true, source) + +proc parseHtml*(inputStream: Stream): Document = + var placeholder = "" + return parseHtml(inputStream, false, placeholder) |