diff --git a/README.org b/README.org index 49faa3f..7d8bec7 100644 --- a/README.org +++ b/README.org @@ -3,18 +3,23 @@ A basic org-mode parser in go - have a org-mode AST to play around with building an org-mode language server - hopefully add reasonable org-mode support to hugo - sadly [[https://github.com/chaseadamsio/goorgeous][goorgeous]] is broken & abandoned * next +- handle #+RESULTS: raw and stuff - hugo frontmatter - see https://gohugo.io/content-management/front-matter/ - captions: images, tables & blocks +*** TODO [[https://github.com/chaseadamsio/goorgeous/issues/72][#72:]] Support for #+ATTR_HTML +*** 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 -- affiliated keywords - see org-element.el - org-element-affiliated-keywords +- affiliated keywords: see org-element.el - org-element-affiliated-keywords - keywords: support both multi (e.g. LINK, TODO) & normal (e.g. AUTHOR, TITLE) keywords - links based on #+LINK -- includes https://orgmode.org/manual/Include-files.html - could be used to have a single org file (ignored via hugo ignoreFiles) and then for each post a file including the relevant headline -- tables - colgroups https://orgmode.org/worg/org-tutorials/tables.html -- org-entities replacement: see org-entities-help +- table colgroups https://orgmode.org/worg/org-tutorials/tables.html +- table pretty printing * resources - syntax - https://orgmode.org/worg/dev/org-syntax.html diff --git a/org/block.go b/org/block.go index 07cc060..63d3a8c 100644 --- a/org/block.go +++ b/org/block.go @@ -32,7 +32,12 @@ func (d *Document) parseBlock(i int, parentStop stopFn) (int, Node) { if parentStop(d, i) { return 0, nil } - nodes = append(nodes, Line{[]Node{Text{trim(d.tokens[i].matches[0])}}}) + text := trim(d.tokens[i].matches[0]) + if name == "SRC" || name == "EXAMPLE" { + nodes = append(nodes, Line{[]Node{Text{text}}}) + } else { + nodes = append(nodes, Line{d.parseInline(text)}) + } } return i + 1 - start, Block{name, parameters, nodes} } diff --git a/org/html.go b/org/html.go index 765b597..9c47dd0 100644 --- a/org/html.go +++ b/org/html.go @@ -102,15 +102,6 @@ func (w *HTMLWriter) writeNodes(ns ...Node) { } } -func (w *HTMLWriter) writeLines(lines []Node) { - for i, line := range lines { - w.writeNodes(line) - if i != len(lines)-1 && line.(Line).Children != nil { - w.WriteString(" ") - } - } -} - func (w *HTMLWriter) writeBlock(b Block) { switch b.Name { case "SRC": @@ -125,17 +116,22 @@ func (w *HTMLWriter) writeBlock(b Block) { w.WriteString(w.HighlightCodeBlock(strings.Join(lines, "\n"), lang)) w.WriteString("\n\n") case "EXAMPLE": - w.WriteString(`
` + "\n") + w.WriteString(`\n") case "QUOTE": w.WriteString("\n`) w.writeNodes(b.Children...) - w.WriteString("\n\n") + w.WriteString("
\n") w.writeNodes(b.Children...) - w.WriteString("\n\n") + w.WriteString("\n") case "CENTER": - w.WriteString(`
` + "\n") w.writeNodes(b.Children...) - w.WriteString("\n
`, strings.ToLower(b.Name)) + "\n") + w.writeNodes(b.Children...) + w.WriteString("
\n") + } } @@ -159,6 +155,7 @@ func (w *HTMLWriter) writeFootnotes(d *Document) { } w.WriteString("\n\n") } + func (w *HTMLWriter) writeHeadline(h Headline) { w.WriteString(fmt.Sprintf("") - w.writeLines(p.Children) + w.WriteString("
\n") + w.writeNodes(p.Children...) w.WriteString("
\n") } @@ -248,15 +242,15 @@ func (w *HTMLWriter) writeHorizontalRule(h HorizontalRule) { } func (w *HTMLWriter) writeTable(t Table) { - w.WriteString("To validate the parser we'll try printing the AST back to org-mode source - if that works we can be kind of sure that the parsing worked. At least I hope so - I would like to get around writing tests for the individual parsing functions...
++To validate the parser we'll try printing the AST back to org-mode source - if that +works we can be kind of sure that the parsing worked. +At least I hope so - I would like to get around writing tests for the individual parsing +functions... +
this one is cheating a little as tags are ALWAYS printed right aligned to a given column number...
++this one is cheating a little as tags are ALWAYS printed right aligned to a given column number... +
unordered list item 2 - with inline
markup
+unordered list item 1 +
+
+unordered list item 2 - with inline
markup
+
ordered sublist item 1
++ordered sublist item 1 +
+ordered sublist item 1 +
++ordered sublist item 2 +
++ordered sublist item 3 +
++ordered sublist item 2 +
+unordered list item 3 - and a link and some lines of text
++unordered list item 3 - and a link +and some lines of text +
and another subitem
++and another subitem +
echo with a block
and another one with a table
++and another one with a table +
a | b | c | @@ -38,29 +81,87 @@
---|
and text with an empty line in between as well!
++and text with an empty line in between as well! +
+unordered list item 4 +
+verbatim
code
links
+
+emphasis and a hard line break
+
+see?
+
+.emphasis with dot border chars. +
++emphasis with a slash/inside +
++emphasis followed by raw text with slash / +
++->/not an emphasis/<- +
++links with slashes do not become emphasis: https://somelinkshouldntrenderaccidentalemphasis.com/ emphasis +
+
+underlined bold verbatim
code
strikethrough
+
+bold string with an *asterisk inside +
++links +
\[[square brackets]\]
https://www.example.com+regular link https://example.com link without description +
++regular link example.com link with description +
+
+regular link to a file (image)
+
+auto link, i.e. not inside \[[square brackets]\]
https://www.example.com
+
-an example blockwith multiple lines +\nan example block +with multiple linesMongodb is very webscale+issues from goorgeous (free test cases, yay!)
+#29: Support verse block
++This +is +verse +
++or even a totally custom kind of block +crazy ain't it? +
+#47: Consecutive
+code
wrapped text gets joined+either
+this
orthat
foo. +eitherthis
+orthat
foo. +#68: Quote block with inline markup
++this is markup! ++#77: Recognize
+code
--- as code plus dash#75: Not parsing nested lists correctly
+
+bullet 1 +
++sub bullet +
++italics +
++Text +italics +
++just a space as title... +
++Foo paragraph. +
++Bar paragraph +
+normal footnote reference 1 +
++further references to the same footnote should not 1 render duplicates in the footnote list +
++inline footnotes are also supported via 2. +
+and other elements
++footnotes can contain markup +
++and other elements +
like blocks
++like blocks +
other non-plain
and tables
-1 | a |
2 | b |
3 | c |