Commit graph

248 commits

Author SHA1 Message Date
Niklas Fasching
36436a4c59 Fix inline parser unanchored regexps
fuzzed
2018-12-20 15:43:02 +01:00
Niklas Fasching
8e154c2fd8 Set up fuzzing with go-fuzz 2018-12-20 00:30:58 +01:00
Niklas Fasching
7a8e90f786 Improve logging and error handling
- enable logging by default: debug was a bad name - it's error logging that I
  just want to hide in tests
- don't panic (all the time)
- use a logger. this allows us to add more information - like the path of the
  parsed file!
2018-12-19 20:25:16 +01:00
Niklas Fasching
c23f8cc281 Add support for SETUP_FILE 2018-12-19 19:58:25 +01:00
Niklas Fasching
3ccbbc46ff Fix document parse() error handling
D'oh - I forgot to set the returned *Document when we panic.
2018-12-19 19:58:25 +01:00
Niklas Fasching
cbcdd4f923 Refactor: Move todoKeywords into parseHeadline
because.
2018-12-19 19:57:50 +01:00
Niklas Fasching
3709d1dc9c Revert "html: Export "#+HUGO: more" as <!--more-->"
This reverts commit 16a978fe48.

not needed after all - turns out hugo looks for the divider before rendering so
we can't do anything in go-org
2018-12-19 19:34:04 +01:00
Niklas Fasching
2295594970 Refactor FrontMatter parsing to better fit hugo requirements 2018-12-19 19:34:04 +01:00
Niklas Fasching
724cf6c23e Support list items with empty first line
also dismiss implementing ordered list bullet overrides for now, e.g.
1. [@10] foo

add it once someone needs it - for now it seems like needless complexity
2018-12-19 17:40:47 +01:00
Niklas Fasching
4e536f44bd Terminate descriptive list when list kind (ordered, unordered) changes 2018-12-19 17:34:46 +01:00
Niklas Fasching
1744ea100b Fix github pages
Oh bash...

Without this links all had the .sections styling and were put on a separate
line.
2018-12-19 14:59:31 +01:00
Niklas Fasching
ff9c077f65 Update README 2018-12-19 14:35:55 +01:00
Niklas Fasching
aa42998dbc Add support for headline CUSTOM_ID property & linking
this introduces the PropertyDrawer node to make it easier to access the
properties associated to a headline - normal drawers don't parse their content
into kv pairs
2018-12-19 14:31:07 +01:00
Niklas Fasching
ec895cbe83 Fix headline tags, table pretty printing and multiline links
- we can't just look at the len of the string (~ #bytes) - that breaks down for
  tables containing characters consisting of multiple bytes. This handles
  more (still not all) cases and is good enough for now
- add _ to allowed tag chars - also require space between headline and tags
- links (link itself, not the description) spanning multiple lines are not
  supported - otherwise we would have to take care of splitting link and adding
  indentation for org pretty printing - and that sounds like such an edge case
  that it seems cleaner to forbid them
2018-12-19 13:15:31 +01:00
Niklas Fasching
fb837e04af Fix parsing of regular links enclosed in [] 2018-12-19 12:24:02 +01:00
Niklas Fasching
905648c34b org: Fix drawer & block
- drawer entries without value were printed as FOO rather than :FOO:
- account for differences between raw & non-raw block:
  raw blocks are not wrapped in a further element, just raw text & line breaks:
  -> the first line has to be indented manually
  non raw blocks do not end in a linebreak newline -> the END_BLOCK line has to
  be indented (rather they end with a manual newline from another element)
2018-12-19 12:21:25 +01:00
Niklas Fasching
5f7d28f504 html: Handle bad usages of ATTR_HTML gracefully
log for debugging but do not panic
2018-12-19 11:43:35 +01:00
Niklas Fasching
788e466ab1 Match goorgeous frontmatter parsing behaviour 2018-12-19 01:07:22 +01:00
Niklas Fasching
16a978fe48 html: Export "#+HUGO: more" as <!--more--> 2018-12-19 01:07:22 +01:00
Niklas Fasching
144f2ce84f Trim space around keyword values 2018-12-19 01:07:22 +01:00
Niklas Fasching
b2f4f6ac57 Remove outdated information from captions fixture
Not anyomre - it's <figure> + <figcaption> now
2018-12-19 00:39:06 +01:00
Niklas Fasching
c554023a60 Hide logs behind document.Debug flag 2018-12-19 00:30:23 +01:00
Niklas Fasching
42dc70e7ad Support blocks with unindented content
list items only contain content that is indented to their respective
level. Except when that content is inside a block. To allow for this we have to
ignore the parentStop when parsing a block and just include everything until
the end of that block.
Can't think of any problems with this right now. Let's see if this comes
back to bite me.
2018-12-19 00:28:53 +01:00
Niklas Fasching
ade2a1c875 Improve tests: Add pretty_org fixtures to allow testing pretty printing
Until now we expected the .org file to print back to itself - we can't do that
when the input is not pretty printed already - with the introduction of blocks
with unindented content that will be the case.
2018-12-18 23:54:04 +01:00
Niklas Fasching
c26d39284c Improve main.go: log error to stderr, output to stdout 2018-12-18 23:53:32 +01:00
Niklas Fasching
941f3ea520 Inform user if gh-pages wasm demo cannot be instantiated 2018-12-18 19:14:27 +01:00
Niklas Fasching
56d47aeb8f Update README 2018-12-18 15:04:54 +01:00
Niklas Fasching
d6b7424da5 html: Fix headline priority export
when #+OPTIONS: pri:t is set (org-export-with-priority) Org mode exports the
priority as {[A], [B], [C]}, not {A, B, C} - we should do the same
2018-12-18 14:22:45 +01:00
Niklas Fasching
e9d9590d7a Fix drawer parsing
Found thx to trying out
https://github.com/kaushalmodi/ox-hugo/blob/master/test/site/content-org/all-posts.org
- handle properties without value (would normally begin a new drawer)
- handle drawer at eof
2018-12-18 14:17:27 +01:00
Niklas Fasching
7331d24452 Add support for list item checkboxes (e.g. [X])
see https://orgmode.org/manual/Checkboxes.html
We're deviating from Org mode regarding the assigned css classes but the chosen
classes feel better than (on, off, trans) and it's not like the export matches
1:1 otherwise.
2018-12-18 14:15:35 +01:00
Niklas Fasching
a60f844e38 Add basic support for statistic tokens (e.g. [100%] [1/1])
Org mode does not care where those tokens are when it comes to the
export (afaict). We'll do the same.

(They should only be in the first line of a list item or a headline)
2018-12-18 14:14:08 +01:00
Niklas Fasching
dce67eaddf Improve ATTR_HTML keyword parsing
Org mode separates kvs not as initially assumed by whitespace (~ csv) but
rather at keywords (~ :\w+).

This is still not replicating Org mode behaviour though as I decided against
attributes ignoring multi-definitions. Instead we stack their
values (and those existing on the element) for certain attributes (class, style
for now).

e.g.
[[foo]]

would become <foo class="a"> in Org mode but becomes <foo class="a b"> with
go-org.
2018-12-18 00:16:41 +01:00
Niklas Fasching
0e64f9df7f html: Render headline priority 2018-12-17 22:39:29 +01:00
Niklas Fasching
a861437185 Fix naming: org-mode -> Org mode
https://scripter.co/how-do-i-write-org-mode/

Prefer “Org mode” to “Org-mode” or “org-mode”. This is simply because it reflects an existing convention in The Emacs Manual which consistently documents mode names in this form - “Text mode”, “Outline mode”, “Mail mode”, etc.
2018-12-17 22:34:15 +01:00
Niklas Fasching
31a98da991 Update README with suggestions from @kaushalmodi
also see #1 - link official Org mode mirror
2018-12-17 22:33:33 +01:00
Niklas Fasching
c6854a40e1 Improve descriptive list org rendering
- indent to correct lvl
  - term ::
            |<- indent up to here
    |<- not here
2018-12-17 16:02:56 +01:00
Niklas Fasching
652290b857 Update README 2018-12-17 15:06:26 +01:00
Niklas Fasching
5afba92f5f Add (a bad) comparison to goorgeous to github pages
The stylesheet would have to be adapted to get a fair visual comparison - but
this should be enough for comparing behavior
2018-12-17 15:06:26 +01:00
Niklas Fasching
0eb3baf1bb Improve handling of elements containing raw text
While adding another test case from the goorgeous issues it became clear that
inline markup and html entity replacement were erronously applied to raw text
elements like inline code =foo=, src/example/export blocks, example lines,
etc.

To correctly handle those cases in both org and html exports a new
parseRawInline method had to be added.

Also some misc html export whitespace fixes and stuff
2018-12-17 13:40:15 +01:00
Niklas Fasching
ac2597af4c Refactor Footnotes: Exclude footnotes heading during export, not parsing
Until now the footnotes section was parsed but not included in the resulting
AST - his required rebuilding it in the OrgWriter. It feels cleaner to include
it in the AST and only exclude it in the export
2018-12-17 13:40:15 +01:00
Niklas Fasching
ced166dc18 Fix inline parseLineBreak: Handle end of input 2018-12-17 01:38:46 +01:00
Niklas Fasching
ba3cf9f948 Add support for descriptive lists 2018-12-17 01:38:46 +01:00
Niklas Fasching
376bb3652a Update README 2018-12-17 00:02:27 +01:00
Niklas Fasching
0186545123 Add basic support for drawers 2018-12-17 00:01:03 +01:00
Niklas Fasching
c012b0a533 Add support for ": example" elements 2018-12-16 23:23:47 +01:00
Niklas Fasching
24ace5aa0e html: Export headline todo status & tags 2018-12-16 22:45:18 +01:00
Niklas Fasching
6887fb2e02 Add wasm demo to github pages 2018-12-16 19:54:17 +01:00
Niklas Fasching
8a9bc2bead Update README: more todos 2018-12-15 14:50:16 +01:00
Niklas Fasching
ca5dbb0e48 Update README 2018-12-14 17:09:00 +01:00
Niklas Fasching
2947d7632d Support basic #+INCLUDE (src/example/export block only)
including org files is more complex - e.g. footnotes need to be namespaced to
their source file. org does this by prefixing each included files footnotes
with a number - but even that is not enough as it doesn't guarantee
uniqueness.

As I don't have a usecase for it, I'll avoid the additional complexity for
now.
2018-12-14 17:09:00 +01:00