html: Allow inline html export in #+TITLE

This commit is contained in:
Niklas Fasching 2020-04-16 15:18:33 +02:00
parent 4b56810a65
commit cbf1b8c38c
5 changed files with 11 additions and 5 deletions

View file

@ -93,6 +93,10 @@ func (w *HTMLWriter) Before(d *Document) {
w.document = d w.document = d
w.log = d.Log w.log = d.Log
if title := d.Get("TITLE"); title != "" { if title := d.Get("TITLE"); title != "" {
titleDocument := d.Parse(strings.NewReader(title), d.Path)
if titleDocument.Error == nil {
title = w.WriteNodesAsString(titleDocument.Nodes...)
}
w.WriteString(fmt.Sprintf(`<h1 class="title">%s</h1>`+"\n", title)) w.WriteString(fmt.Sprintf(`<h1 class="title">%s</h1>`+"\n", title))
} }
w.WriteOutline(d) w.WriteOutline(d)
@ -140,7 +144,7 @@ func (w *HTMLWriter) WriteInlineBlock(b InlineBlock) {
w.WriteString(fmt.Sprintf("<div class=\"src src-inline src-%s\">\n%s\n</div>", lang, content)) w.WriteString(fmt.Sprintf("<div class=\"src src-inline src-%s\">\n%s\n</div>", lang, content))
case "export": case "export":
if strings.ToLower(b.Parameters[0]) == "html" { if strings.ToLower(b.Parameters[0]) == "html" {
w.WriteString(content + "\n") w.WriteString(content)
} }
} }
} }

View file

@ -51,7 +51,6 @@ inline source blocks like <div class="src src-inline src-html">
<li> <li>
<p> <p>
inline export blocks <h1>hello</h1> inline export blocks <h1>hello</h1>
</p> </p>
</li> </li>
<li> <li>

View file

@ -1,4 +1,7 @@
<h1 class="title">Misc</h1> <h1 class="title"><p>
Misc title <b>with an inline html export</b>
</p>
</h1>
<nav> <nav>
<ul> <ul>
<li><a href="#headline-1">issues from goorgeous (free test cases, yay!)</a> <li><a href="#headline-1">issues from goorgeous (free test cases, yay!)</a>

View file

@ -1,4 +1,4 @@
#+TITLE: Misc #+TITLE: Misc title @@html:<b>with an inline html export</b>@@
** 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 *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML
#+HTML: <p style="border: 1px dotted grey">neato!</p> #+HTML: <p style="border: 1px dotted grey">neato!</p>

View file

@ -1,4 +1,4 @@
#+TITLE: Misc #+TITLE: Misc title @@html:<b>with an inline html export</b>@@
** 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 *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML
#+HTML: <p style="border: 1px dotted grey">neato!</p> #+HTML: <p style="border: 1px dotted grey">neato!</p>