diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | adapter/format/gmi2html.nim | 4 | ||||
-rw-r--r-- | adapter/format/md2html.nim | 34 | ||||
-rw-r--r-- | todo | 1 |
4 files changed, 30 insertions, 13 deletions
diff --git a/README.md b/README.md index d53f6bac..00ae2085 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,8 @@ Here's some: * The default image decoder (PNG, JPEG, GIF, BMP) uses the [stb_image](https://github.com/nothings/stb) library, and WebP images are decoded using the [JebP](https://github.com/matanui159/jebp) library. Image - codecs are handled as protocols, so users will be able to add their own codecs - (once I document how it works...) + codecs are handled as protocols, so users can add their own codecs (with + urimethodmap). For further details, please refer to the [architecture](doc/architecture.md) document. diff --git a/adapter/format/gmi2html.nim b/adapter/format/gmi2html.nim index ee3c06bd..9dde28f1 100644 --- a/adapter/format/gmi2html.nim +++ b/adapter/format/gmi2html.nim @@ -23,7 +23,7 @@ a, pre, ul, blockquote, li, h1, h2, h3 { margin-top: 0; margin-bottom: 0 } while not stdin.endOfFile: let line = stdin.readLine() if inpre and not line.startsWith("```"): - stdout.write(line.htmlEscape() & "\n") + stdout.write(line.htmlEscape() & '\n') continue if inul and not line.startsWith("* "): stdout.write("</ul>") @@ -64,6 +64,6 @@ a, pre, ul, blockquote, li, h1, h2, h3 { margin-top: 0; margin-bottom: 0 } stdout.write(line.substr(1).htmlEscape()) stdout.write("</blockquote>") else: - stdout.write(line.htmlEscape() & "\n") + stdout.write(line.htmlEscape() & '\n') main() diff --git a/adapter/format/md2html.nim b/adapter/format/md2html.nim index 5d06acc5..3428d34c 100644 --- a/adapter/format/md2html.nim +++ b/adapter/format/md2html.nim @@ -275,8 +275,8 @@ proc matchHTMLPreEnd(line: string): bool = type BlockType = enum - btNone, btPar, btList, btPre, btTabPre, btSpacePre, btHTML, btHTMLPre, - btComment + btNone, btPar, btList, btPre, btTabPre, btSpacePre, btBlockquote, btHTML, + btHTMLPre, btComment ParseState = object blockType: BlockType @@ -312,26 +312,33 @@ proc parseNone(state: var ParseState; line: string) = elif line.startsWith("```"): state.blockType = btPre stdout.write("<PRE>") + elif line[0] == '\t': + state.blockType = btTabPre + if state.hasp: + state.hasp = false + stdout.write("</P>\n") + stdout.write("<PRE>") + state.blockData = line.substr(1) & '\n' elif line.startsWith(" "): state.blockType = btSpacePre if state.hasp: state.hasp = false stdout.write("</P>\n") stdout.write("<PRE>") - state.blockData = line.substr(4) & "\n" - elif line.startsWith("\t"): - state.blockType = btTabPre + state.blockData = line.substr(4) & '\n' + elif line[0] == '>': + state.blockType = btBlockquote if state.hasp: state.hasp = false stdout.write("</P>\n") - stdout.write("<PRE>") - state.blockData = line.substr(1) & "\n" + state.blockData = line.substr(1) & "<BR>" + stdout.write("<BLOCKQUOTE>") elif (let (n, len, t) = line.getListDepth(); n != -1): state.blockType = btList state.listDepth = n state.hasp = false state.pushList(t) - state.blockData = line.substr(len + 1) & "\n" + state.blockData = line.substr(len + 1) & '\n' else: state.blockType = btPar state.hasp = true @@ -444,6 +451,16 @@ proc parseSpacePre(state: var ParseState; line: string) = dec state.numPreLines state.blockData &= line.substr(4) & "\n" +proc parseBlockquote(state: var ParseState; line: string) = + if line.len == 0 or line[0] != '>': + stdout.write(state.blockData) + stdout.write("</BLOCKQUOTE>") + state.blockData = "" + state.reprocess = true + state.blockType = btNone + else: + state.blockData &= line.substr(1) & "<BR>" + proc parseComment(state: var ParseState; line: string) = let i = line.find("-->") if i != -1: @@ -463,6 +480,7 @@ proc main() = of btPre: state.parsePre(line) of btTabPre: state.parseTabPre(line) of btSpacePre: state.parseSpacePre(line) + of btBlockquote: state.parseBlockquote(line) of btList: state.parseList(line) of btPar: state.parsePar(line) of btHTML: state.parseHTML(line) diff --git a/todo b/todo index 538b58de..c08b289a 100644 --- a/todo +++ b/todo @@ -71,7 +71,6 @@ layout engine: - iframe - writing-mode, grid, ruby, ... (i.e. cool new stuff) images: -- sixel dithering - z order, proper image blending - incremental decoding, interlaced images, animation man: |