From 614307a8f511b1f7076958922d7e2f887b7c088c Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sun, 22 Dec 2019 13:58:19 +0100 Subject: [PATCH] HTML export: Export #+TITLE as h1 and offset other headlines accordingly emacs exports #+TITLE as

and all other headlines accordingly as `lvl + 1` - we'll go with that. --- org/html_writer.go | 7 +- org/testdata/footnotes.html | 8 +- org/testdata/footnotes_in_headline.html | 4 +- org/testdata/headlines.html | 24 ++--- org/testdata/misc.html | 125 ++++++++++++------------ org/testdata/misc.org | 1 + org/testdata/misc.pretty_org | 1 + org/testdata/options.html | 4 +- 8 files changed, 90 insertions(+), 84 deletions(-) diff --git a/org/html_writer.go b/org/html_writer.go index 916618c..d630db5 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -88,6 +88,9 @@ func (w *HTMLWriter) WriterWithExtensions() Writer { func (w *HTMLWriter) Before(d *Document) { w.document = d w.log = d.Log + if title := d.Get("TITLE"); title != "" { + w.WriteString(fmt.Sprintf(`

%s

`+"\n", title)) + } w.WriteOutline(d) } @@ -214,7 +217,7 @@ func (w *HTMLWriter) WriteHeadline(h Headline) { } } - w.WriteString(fmt.Sprintf(``, h.Lvl, h.ID()) + "\n") + w.WriteString(fmt.Sprintf(``, h.Lvl+1, h.ID()) + "\n") if w.document.GetOption("todo") && h.Status != "" { w.WriteString(fmt.Sprintf(`%s`, h.Status) + "\n") } @@ -231,7 +234,7 @@ func (w *HTMLWriter) WriteHeadline(h Headline) { w.WriteString("   ") w.WriteString(fmt.Sprintf(`%s`, strings.Join(tags, " "))) } - w.WriteString(fmt.Sprintf("\n\n", h.Lvl)) + w.WriteString(fmt.Sprintf("\n\n", h.Lvl+1)) WriteNodes(w, h.Children...) } diff --git a/org/testdata/footnotes.html b/org/testdata/footnotes.html index e74da17..cdd67c4 100644 --- a/org/testdata/footnotes.html +++ b/org/testdata/footnotes.html @@ -6,9 +6,9 @@ -

+

Using some footnotes -

+ -

+

Footnotes -

+

Please note that the footnotes section is not automatically excluded from the export like in emacs. 8

diff --git a/org/testdata/footnotes_in_headline.html b/org/testdata/footnotes_in_headline.html index 489169a..3b617ec 100644 --- a/org/testdata/footnotes_in_headline.html +++ b/org/testdata/footnotes_in_headline.html @@ -4,9 +4,9 @@ -

+

Title 1 -

+

diff --git a/org/testdata/headlines.html b/org/testdata/headlines.html index 310bdfb..8c2f1c2 100644 --- a/org/testdata/headlines.html +++ b/org/testdata/headlines.html @@ -16,9 +16,9 @@ -

+

Simple Headline [1/2] -

+
  • @@ -38,22 +38,22 @@ not just where they are actually meant to be - even here > +

    TODO [B] Headline with todo status & priority -

    -

    +

    +

    DONE Headline with TODO status -

    +

    we can link to headlines that define a custom_id: #this-will-be-the-id-of-the-headline

    -

    +

    [A] Headline with tags & priority   foo bar -

    +

    Still outside the drawer

    @@ -63,10 +63,10 @@ This is inside the drawer

    Still outside the drawer

    -

    +

    CUSTOM headline with custom status -

    +

    it's possible to use #+SETUPFILE - in this case the setup file contains the following

    @@ -78,9 +78,9 @@ it's possible to use #+SETUPFILE - in this cas
-

+

malformed property drawer -

+

:PROPERTIES: not a property diff --git a/org/testdata/misc.html b/org/testdata/misc.html index c209ccd..b56dbb1 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -1,3 +1,4 @@ +

Misc

-

+

issues from goorgeous (free test cases, yay!) -

-

+

+

DONE #19: Support #+HTML -

+

neato!

-

+

DONE #29: Support verse block -

+

This @@ -101,17 +102,17 @@ or even a totally custom kind of block crazy ain't it?

-

+

DONE #30: Support #+SETUPFILE -

+

see ./headlines.org

-

+

DONE #31: Support #+INCLUDE -

+

Note that only src/example/export block inclusion is supported for now. There's quite a lot more to include (see the org manual for include files) but I @@ -207,10 +208,10 @@ deploy: -

+

DONE #33: Wrong output when mixing html with Org mode -

+
@@ -225,14 +226,14 @@ deploy:
-

+

DONE #41: Support Table Of Contents -

-

+

+

DONE #46: Support for symbols like ndash and mdash -

+ -

+

DONE #47: Consecutive code wrapped text gets joined -

+

either this or that foo. either this or that foo.

-

+

DONE #50: LineBreaks in lists are preserved -

+ -

+

DONE #77: Recognize code— as code plus dash -

-

+

+

DONE #78: Emphasis at beginning of line -

+

italics

@@ -351,36 +352,36 @@ sub bullet Text italics

-

+

DONE #82: Crash on empty headline -

-

-

+
+ +

just a space as title…

-

+

DONE #84: Paragraphs that are not followed by an empty line are not parsed correctly -

-

-Foo

+
+Foo +

Foo paragraph.

-

+

Bar -
+

Bar paragraph

-

+

DONE #86: Multiple hyphens not converted to dashes -

+

just like #46

@@ -425,17 +426,17 @@ src/example/export blocks should not be converted! -

+

DONE #87: Markup in footnotes is rendered literally -

+

footnotes can contain markup - and other elements and stuff 1 2

-

+

DONE #92: src blocks only render in caps -

+

The behaviour of Org mode <s TAB changed and it now inserts lowercased src blocks (go-org already handled this one)

@@ -465,21 +466,21 @@ uname -a -

+

issues (wrongly) filed with hugo -

-

-#3874 exporting images in org mode

+

+#3874 exporting images in org mode +

Hello, I'm writing hugo blogs using org-mode.

When inserting an image link like /home/amos/Pictures/Screenshots/img-2017-09-11-165647.png, hugo doesn't export the image.

-

+

#4006 source code blocks in org not rendered correctly -

+
@@ -492,24 +493,24 @@ When inserting an image link like 
+

misc fuzz / regression / edge case -

-

+

+

index out of range in headline priority parsing -

-

-[#B

-

+

+[#B +
+

index out of range in explicit line break parsing -

+

0\\

-

+

Footnotes -

+

diff --git a/org/testdata/misc.org b/org/testdata/misc.org index 78d5dbc..4c67c1d 100644 --- a/org/testdata/misc.org +++ b/org/testdata/misc.org @@ -1,3 +1,4 @@ +#+TITLE: Misc ** issues from goorgeous (free test cases, yay!) *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML #+HTML:

neato!

diff --git a/org/testdata/misc.pretty_org b/org/testdata/misc.pretty_org index ff61450..7c5419a 100644 --- a/org/testdata/misc.pretty_org +++ b/org/testdata/misc.pretty_org @@ -1,3 +1,4 @@ +#+TITLE: Misc ** issues from goorgeous (free test cases, yay!) *** DONE [[https://github.com/chaseadamsio/goorgeous/issues/19][#19]]: Support #+HTML #+HTML:

neato!

diff --git a/org/testdata/options.html b/org/testdata/options.html index 0902d83..496b2a6 100644 --- a/org/testdata/options.html +++ b/org/testdata/options.html @@ -1,8 +1,8 @@ -

+

DONE [A] #+OPTIONS: toggles supported by go-org   tag1 tag2 -

+

go-org supports multiple export toggles as described in the export settings section of the Org mode manual. By default (most of?) those toggles are enabled. This file starts with #+OPTIONS: toc:nil f:nil e:nil and thus