From ffe06b50f2e4290e96216d31d1907fc75d157b95 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Tue, 11 Dec 2018 20:45:37 +0100 Subject: [PATCH] Add support for #+HTML --- README.org | 2 -- org/html.go | 10 +++++++++- org/testdata/misc.html | 15 +++++++++++++++ org/testdata/misc.org | 7 +++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 1736d2c..8d24ee4 100644 --- a/README.org +++ b/README.org @@ -7,10 +7,8 @@ A basic org-mode parser in go *** TODO [[https://github.com/chaseadamsio/goorgeous/issues/46][#46]]: Support for symbols like ndash and mdash - see org-entities replacement: see org-entities-help *** TODO [[https://github.com/chaseadamsio/goorgeous/issues/10][#10]]: Support noexport -*** TODO [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML *** TODO [[https://github.com/chaseadamsio/goorgeous/issues/31][#31]]: Support #+INCLUDE - see https://orgmode.org/manual/Include-files.html -*** TODO [[https://github.com/chaseadamsio/goorgeous/issues/33][#33]]: Wrong output when mixing html with org-mode * later - hugo frontmatter - see https://gohugo.io/content-management/front-matter/ -> actually seems to be handled by hugo itself - handle #+RESULTS: raw and stuff diff --git a/org/html.go b/org/html.go index 86e043a..8b212ca 100644 --- a/org/html.go +++ b/org/html.go @@ -63,7 +63,9 @@ func (w *HTMLWriter) after(d *Document) { func (w *HTMLWriter) writeNodes(ns ...Node) { for _, n := range ns { switch n := n.(type) { - case Keyword, Comment: + case Keyword: + w.writeKeyword(n) + case Comment: continue case NodeWithMeta: w.writeNodeWithMeta(n) @@ -142,6 +144,12 @@ func (w *HTMLWriter) writeBlock(b Block) { } } +func (w *HTMLWriter) writeKeyword(k Keyword) { + if k.Key == "HTML" { + w.WriteString(k.Value + "\n") + } +} + func (w *HTMLWriter) writeFootnoteDefinition(f FootnoteDefinition) { n := f.Name w.WriteString(`
` + "\n") diff --git a/org/testdata/misc.html b/org/testdata/misc.html index 92b3379..f707a61 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -1,4 +1,6 @@

issues from goorgeous (free test cases, yay!)

+

#19: Support #+HTML

+

neato!

#29: Support verse block

@@ -13,6 +15,19 @@ or even a totally custom kind of block crazy ain't it?

+

#33: Wrong output when mixing html with org-mode

+
+ + + + + + + + + +
foofoo
barbar
+

#47: Consecutive code wrapped text gets joined

either this or that foo. diff --git a/org/testdata/misc.org b/org/testdata/misc.org index 8629bf2..95a248a 100644 --- a/org/testdata/misc.org +++ b/org/testdata/misc.org @@ -1,4 +1,6 @@ ** issues from goorgeous (free test cases, yay!) +*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML +#+HTML:

neato!

*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/29][#29:]] Support verse block #+BEGIN_VERSE This @@ -10,6 +12,11 @@ verse or even a *totally* /custom/ kind of block crazy ain't it? #+END_CUSTOM +*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/33][#33]]: Wrong output when mixing html with org-mode +#+HTML:
+| *foo* | foo | +| *bar* | bar | +#+HTML:
*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/47][#47:]] Consecutive ~code~ wrapped text gets joined either ~this~ or ~that~ foo. either ~this~