Add support for #+HTML

This commit is contained in:
Niklas Fasching 2018-12-11 20:45:37 +01:00
parent 0a905ca172
commit ffe06b50f2
4 changed files with 31 additions and 3 deletions

View file

@ -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 *** TODO [[https://github.com/chaseadamsio/goorgeous/issues/46][#46]]: Support for symbols like ndash and mdash
- see org-entities replacement: see org-entities-help - 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/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 *** TODO [[https://github.com/chaseadamsio/goorgeous/issues/31][#31]]: Support #+INCLUDE
- see https://orgmode.org/manual/Include-files.html - 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 * later
- hugo frontmatter - see https://gohugo.io/content-management/front-matter/ -> actually seems to be handled by hugo itself - hugo frontmatter - see https://gohugo.io/content-management/front-matter/ -> actually seems to be handled by hugo itself
- handle #+RESULTS: raw and stuff - handle #+RESULTS: raw and stuff

View file

@ -63,7 +63,9 @@ func (w *HTMLWriter) after(d *Document) {
func (w *HTMLWriter) writeNodes(ns ...Node) { func (w *HTMLWriter) writeNodes(ns ...Node) {
for _, n := range ns { for _, n := range ns {
switch n := n.(type) { switch n := n.(type) {
case Keyword, Comment: case Keyword:
w.writeKeyword(n)
case Comment:
continue continue
case NodeWithMeta: case NodeWithMeta:
w.writeNodeWithMeta(n) 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) { func (w *HTMLWriter) writeFootnoteDefinition(f FootnoteDefinition) {
n := f.Name n := f.Name
w.WriteString(`<div class="footnote-definition">` + "\n") w.WriteString(`<div class="footnote-definition">` + "\n")

View file

@ -1,4 +1,6 @@
<h2>issues from goorgeous (free test cases, yay!)</h2> <h2>issues from goorgeous (free test cases, yay!)</h2>
<h3><a href="https://github.com/chaseadamsio/goorgeous/issues/19">#19</a>: Support #+HTML</h3>
<p style="border: 1px dotted grey">neato!</p>
<h3><a href="https://github.com/chaseadamsio/goorgeous/issues/29">#29:</a> Support verse block</h3> <h3><a href="https://github.com/chaseadamsio/goorgeous/issues/29">#29:</a> Support verse block</h3>
<div class="verse-block"> <div class="verse-block">
<p> <p>
@ -13,6 +15,19 @@ or even a <strong>totally</strong> <em>custom</em> kind of block
crazy ain&#39;t it? crazy ain&#39;t it?
</p> </p>
</div> </div>
<h3><a href="https://github.com/chaseadamsio/goorgeous/issues/33">#33</a>: Wrong output when mixing html with org-mode</h3>
<div class="outline-2" id="meta" style="color: green;">
<table>
<tbody>
<tr>
<td><strong>foo</strong></td><td>foo</td>
</tr>
<tr>
<td><strong>bar</strong></td><td>bar</td>
</tr>
</tbody>
</table>
</div>
<h3><a href="https://github.com/chaseadamsio/goorgeous/issues/47">#47:</a> Consecutive <code>code</code> wrapped text gets joined</h3> <h3><a href="https://github.com/chaseadamsio/goorgeous/issues/47">#47:</a> Consecutive <code>code</code> wrapped text gets joined</h3>
<p> <p>
either <code>this</code> or <code>that</code> foo. either <code>this</code> or <code>that</code> foo.

View file

@ -1,4 +1,6 @@
** issues from goorgeous (free test cases, yay!) ** issues from goorgeous (free test cases, yay!)
*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML
#+HTML: <p style="border: 1px dotted grey">neato!</p>
*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/29][#29:]] Support verse block *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/29][#29:]] Support verse block
#+BEGIN_VERSE #+BEGIN_VERSE
This This
@ -10,6 +12,11 @@ verse
or even a *totally* /custom/ kind of block or even a *totally* /custom/ kind of block
crazy ain't it? crazy ain't it?
#+END_CUSTOM #+END_CUSTOM
*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/33][#33]]: Wrong output when mixing html with org-mode
#+HTML: <div class="outline-2" id="meta" style="color: green;">
| *foo* | foo |
| *bar* | bar |
#+HTML: </div>
*** DONE [[https://github.com/chaseadamsio/goorgeous/issues/47][#47:]] Consecutive ~code~ wrapped text gets joined *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/47][#47:]] Consecutive ~code~ wrapped text gets joined
either ~this~ or ~that~ foo. either ~this~ or ~that~ foo.
either ~this~ either ~this~