Commit graph

261 commits

Author SHA1 Message Date
Niklas Fasching
141d6a27a9 Update README 2018-12-26 17:31:59 +01:00
Niklas Fasching
d036ddea4d Add support for some #+OPTIONS toggles
see https://orgmode.org/manual/Export-settings.html
2018-12-26 16:58:16 +01:00
Niklas Fasching
5c51067b59 Rename files containing org and htm writer
The naming `org.go` is confusing as it's not the main class of the org package
2018-12-26 16:11:40 +01:00
Niklas Fasching
d921a68a55 Add support for Table of Contents 2018-12-26 16:10:23 +01:00
Niklas Fasching
eb7db9b968 Improve footnote handling
- Footnotes separator rather than headline to get around i18n
- Warn on footnote redefinition
- Do not export footnote definitions at point of definition, only in the
  footnote section.
- Do not automatically exclude Footnotes section to get around possibly hiding
  other content of such a section - and i18n.
  The user has the choice of explicitly hiding the section via a :noexport:
  tag.

and some other refactoring
2018-12-26 15:42:12 +01:00
Niklas Fasching
beff0c0d8a Add support for EXCLUDE_TAGS and :noexport: 2018-12-26 15:31:48 +01:00
Niklas Fasching
c3d635eacb Add more test cases 2018-12-21 16:05:38 +01:00
Niklas Fasching
c7c46ca1d9 Add MIT License
because I guess that's required for adding this for hugo (???)
2018-12-20 20:30:14 +01:00
Niklas Fasching
e8b90ab9d4 Update README 2018-12-20 16:49:26 +01:00
Niklas Fasching
854f8e181a Improve fuzzing function
We not only want to prevent panics, we also want rendering org -> org to not
change the meaning of the file. One easy way to check that (for the
nodes that print to html) whether that holds is to compare the html output.
2018-12-20 15:52:51 +01:00
Niklas Fasching
bc9c496f97 Misc cleanup: SETUP_FILE -> SETUPFILE, empty example lines, ... 2018-12-20 15:43:16 +01:00
Niklas Fasching
d1054063cf Anchor inline regexps and improve sub/super-script
The regexps are meant to extract a match immediately following the cursor - the
anchor should have been there from the beginning...

Also empty sub/superscript doesn't make sense - nested sub/superscript does
make sense but yagni.
2018-12-20 15:43:16 +01:00
Niklas Fasching
ab9d87fbc8 Clean up regexps 2018-12-20 15:43:16 +01:00
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