Commit graph

14 commits

Author SHA1 Message Date
Niklas Fasching
7e69931976 html: Implement source block :exports parameter 2020-04-17 15:24:42 +02:00
Niklas Fasching
cd923ba41a Implement source block results
To support code block directives like :exports none we need context - i.e. we
need to have the block and it's results at once and can't just render them
independently.
2020-04-17 15:02:56 +02:00
Niklas Fasching
f6f4646d45 Implement result blocks 2020-04-17 14:54:02 +02:00
Niklas Fasching
d417c2a6dd Implement escaping in src (org only) and example blocks
inside src example blocks lines starting with `\s*,` are escaped - i.e. org
mode will not try to parse them as e.g. a headline. We don't want to render the
escape commata to html so let's take them out - and put them back in before
rendering to org. Doing it this way allows us to render them correctly even
when the input did not include them.

see https://orgmode.org/manual/Literal-Examples.html#Literal-Examples
2020-04-16 16:07:54 +02:00
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
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
148eef5aeb Refactor: Move some code
Example nodes are a kind of block and it's not much code so we can just put it
next to the Block code. Feels cleaner but doesn't change much.
2019-01-06 20:49:49 +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
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
53b61abfd0 Support html export blocks 2018-12-11 16:05:36 +01:00
Niklas Fasching
6637e63892 Fix multiline emphasis
I didn't have a test case for this and broke it when i introduced Line nodes to
support printing back to org mode. Oops
2018-12-10 17:53:12 +01:00
Niklas Fasching
8f06883ec5 Allow blocks to contain paragraphs and other top level elements 2018-12-03 16:59:01 +01:00
Niklas Fasching
592be07cfd Refactor space handling of writers
I went through the issues of goorgeous and picked a few that seemed easy enough
to add (and added some fore as todos for later). That helped a lot and showed
some bugs / edge cases that required changes.

- the org writer wrote a lot of eol spaces and just removed it whenever
  String() was actually called. That worked until now but did not bode with
  rendering an empty headline - by removing ALL eol space we would render "* "
  back as just "*" -> not a headline anymore.
- the html writer had some special handling for line spacing inside paragraphs
  and list items - with the introduction of more blocks we need that handling
  everywhere.
  As browsers / html renderers are nice enough to collapse whitespace (and
  especially collapse "\s*\n" into " ") we can just write out the newlines and
  let the renderer take care of the rest.
2018-12-02 23:34:21 +01:00
Niklas Fasching
fc982125c9 Restructure directory layout: org subpackage 2018-12-02 18:37:55 +01:00
Renamed from block.go (Browse further)