Commit graph

31 commits

Author SHA1 Message Date
Niklas Fasching
9a0a9c11eb Export WriteNodesAsString on writer interface
WriteNodesAsString is simple enough to implement but exposing it is helpful in
the implementation of extending writers and we don't aim to keep writer a small
interface so let's expose it.
2019-11-02 23:44:16 +01:00
Niklas Fasching
20970ec872 Add support for NAME keyword 2019-10-27 15:12:38 +01:00
Niklas Fasching
9de65240a0 Allow customizing reading of #+INCLUDE files
It's not always sensible to allow #+INCLUDE of arbitrary files (e.g. user
provided content)
2019-10-06 19:27:42 +02:00
Niklas Fasching
6dc04b4b02 Refactor footnote handling
- Remove unused footnote section title option
- Move away from maintaining a list of footnotes in the document (only needed
  for html export, potential maintainance overhead when modifying the document)
  and rather only build it on export when required.
- HTML export: Rename all footnotes to numbers (so we can support anonymous
  footnote references by assigning them a number) and export footnotes in order
  of reference, not definition. The implementation of this makes it natural to
  also stop exporting unused footnote definitions so we do that as well.
2019-07-07 10:01:43 +02:00
Niklas Fasching
63fef04fb3 Add support for timestamps 2019-01-06 21:01:47 +01:00
Niklas Fasching
bd33e8885e Add String() method to Node interface
Being able to very easily get the original [1] Org mode content seems like
something that will come up quite often and is very little code.

[1] it's not really the original content, but rather the pretty printed version
of that - as the semantics don't change it shouldn't matter.
2019-01-06 20:50:02 +01:00
Niklas Fasching
faea88d48e Refactor Writer Interface
The existing approach made it hard to extend existing writers.
With this change, replacing individual methods of a writer is possible by
embedding it.

Sharing the WriteNodes function also removes some unnecesseray duplication, so
win win.
2019-01-04 20:13:42 +01:00
Niklas Fasching
56ecb2d401 Add some documentation & split Document into Configuration+Document 2019-01-02 19:17:17 +01:00
Niklas Fasching
c98cdea4f0 Improve document.GetOption: Merge default and buffer local options
Unlike the other BufferSettings, #+OPTIONS: specifies multiple options and we
cannot just look it up in either BufferSettings or DefaultSettings - both have
to be checked
2019-01-02 18:52:03 +01:00
Niklas Fasching
f62a00863f Remove FrontMatter
After giving it some thought I don't think this belongs in go-org - there's
just no use for it outside of hugo front matter handling
2019-01-02 18:34:40 +01:00
Niklas Fasching
348f697b41 Make Writer interface methods public: Allow other implementations 2019-01-02 18:34:40 +01:00
Niklas Fasching
fb39e59e6b Cleanup: Remove unused Document.StatusKeywords field & clean len checks
Leftover from the days before BufferSettings & DefaultSettings - now that those
exists the status keywords are actually defined in
- DefaultSettings["TODO"] for the default
- BufferSettings["TODO"] for any customizations

Also ! i < len => i >= len because it's easier on the eyes
2019-01-02 18:34:38 +01:00
Niklas Fasching
940b1c7125 Fix outline nesting
oops - that got lost during the rebase - here we go
2018-12-26 17:44:01 +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
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
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
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
2295594970 Refactor FrontMatter parsing to better fit hugo requirements 2018-12-19 19:34:04 +01:00
Niklas Fasching
788e466ab1 Match goorgeous frontmatter parsing behaviour 2018-12-19 01:07:22 +01:00
Niklas Fasching
c554023a60 Hide logs behind document.Debug flag 2018-12-19 00:30:23 +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
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
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
Niklas Fasching
04df30a7b5 Convert panics to errors for public interface 2018-12-14 16:37:32 +01:00
Niklas Fasching
a0e87057d6 Fix BufferSettings append & add ParseFrontMatter
until now buffersettings were always appended using \n which means the first
value would already be written as "\nVALUE". Not anymore.

Also we finally add an option to parse just the front matter. Still not
efficient as we tokenize the whole org file but i don't think saving a few
milliseconds would be worth making the code uglier.
2018-12-13 17:44:26 +01:00
Niklas Fasching
3c2e9ed204 Add option to disable AutoLink parsing 2018-12-02 23:53:31 +01:00
Niklas Fasching
d5bf4317b2 Fix footnote ordering and some other bugs 2018-12-02 20:09:40 +01:00
Niklas Fasching
fc982125c9 Restructure directory layout: org subpackage 2018-12-02 18:37:55 +01:00
Renamed from document.go (Browse further)