From 3c7528f3039fe068ce8760a5878e7c0916cfef7c Mon Sep 17 00:00:00 2001
From: bptato ")
+ elif line.startsWith(" "):
+ state.blockType = btSpacePre
+ if state.hasp:
+ state.hasp = false
+ stdout.write("
") + state.blockData = line.substr(4) & "\n" + elif line.startsWith("\t"): + state.blockType = btTabPre + if state.hasp: + state.hasp = false + stdout.write("\n") + stdout.write("") + state.blockData = "" + state.reprocess = true + state.blockType = btNone + else: + while state.numPreLines > 0: + state.blockData &= '\n' + dec state.numPreLines + state.blockData &= line.substr(4) & "\n" + proc parseComment(state: var ParseState, line: string) = let i = line.find("-->") if i != -1: @@ -378,6 +426,8 @@ proc main() = case state.blockType of btNone: state.parseNone(line) of btPre: state.parsePre(line) + of btTabPre: state.parseTabPre(line) + of btSpacePre: state.parseSpacePre(line) of btList: state.parseList(line) of btPar: state.parsePar(line) of btHTML: state.parseHTML(line) -- cgit 1.4.1-2-gfad0") + state.blockData = line.substr(1) & "\n" elif (let (n, len, t) = line.getListDepth(); n != -1): state.blockType = btList state.listDepth = n @@ -361,6 +377,38 @@ proc parseHTMLPre(state: var ParseState, line: string) = else: state.blockData &= line & "\n" +proc parseTabPre(state: var ParseState, line: string) = + if line.len == 0: + inc state.numPreLines + elif line[0] != '\t': + state.numPreLines = 0 + stdout.write(state.blockData) + stdout.write("") + state.blockData = "" + state.reprocess = true + state.blockType = btNone + else: + while state.numPreLines > 0: + state.blockData &= '\n' + dec state.numPreLines + state.blockData &= line.substr(1) & "\n" + +proc parseSpacePre(state: var ParseState, line: string) = + if line.len == 0: + inc state.numPreLines + elif not line.startsWith(" "): + state.numPreLines = 0 + stdout.write(state.blockData) + stdout.write("