From 6ed46ba95d8048c65dbcfde04ae8bea4b360f99b Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Tue, 31 Mar 2020 16:28:56 +0200 Subject: [PATCH] html: Do not render non-html export blocks --- org/html_writer.go | 6 ++++-- org/testdata/blocks.org | 5 +++++ org/testdata/blocks.pretty_org | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/org/html_writer.go b/org/html_writer.go index 731f7db..8a35e17 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -124,8 +124,10 @@ func (w *HTMLWriter) WriteBlock(b Block) { w.WriteString(fmt.Sprintf("
\n%s\n
\n", lang, content)) case name == "EXAMPLE": w.WriteString(`
` + "\n" + html.EscapeString(content) + "\n
\n") - case name == "EXPORT" && len(b.Parameters) >= 1 && strings.ToLower(b.Parameters[0]) == "html": - w.WriteString(content + "\n") + case name == "EXPORT": + if len(b.Parameters) >= 1 && strings.ToLower(b.Parameters[0]) == "html" { + w.WriteString(content + "\n") + } case name == "QUOTE": w.WriteString("
\n" + content + "
\n") case name == "CENTER": diff --git a/org/testdata/blocks.org b/org/testdata/blocks.org index 3990008..b789401 100644 --- a/org/testdata/blocks.org +++ b/org/testdata/blocks.org @@ -57,6 +57,11 @@ console.log("Hello World!") #+END_EXPORT +#+BEGIN_EXPORT something-other-than-html +I won't be rendered as html +#+END_EXPORT + + - list item 1 blocks can contain unindented lines that would normally end a list item #+BEGIN_EXAMPLE diff --git a/org/testdata/blocks.pretty_org b/org/testdata/blocks.pretty_org index 355ed29..40cbec8 100644 --- a/org/testdata/blocks.pretty_org +++ b/org/testdata/blocks.pretty_org @@ -57,6 +57,11 @@ console.log("Hello World!") #+END_EXPORT +#+BEGIN_EXPORT something-other-than-html +I won't be rendered as html +#+END_EXPORT + + - list item 1 blocks can contain unindented lines that would normally end a list item #+BEGIN_EXAMPLE