Commit graph

285 commits

Author SHA1 Message Date
Niklas Fasching
d7ef673644 Update blorg about 2020-06-26 21:47:38 +02:00
Niklas Fasching
d2bbcc8881 Update blorg and add it to gh-pages. Update README 2020-06-26 21:00:25 +02:00
Niklas Fasching
e076412b29 html: Implement fat table rows (use tbodies to represent separators)
html does not support table separator rows as Org mode does. Emacs org export
simulates rows as defined by separators by wrapping all the rows between 2
separators into a separate tbody. The html spec is fine with that [0] so we
follow.

[0] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
2020-06-26 20:11:14 +02:00
Niklas Fasching
5917d8fb1c Store table separator indices
We want to support fat rows in tables - for that we need to know where the
separators are.
2020-06-26 20:05:59 +02:00
Niklas Fasching
a383eef7a6 html: Remove cosmetic whitespace inside p tags
All tags are put on a line by themselves to help with visual
diffing. Apparently this extra cosmetic whitespace causes problems inside p
tags for ppl who want to use `white-space: pre`. Not much hurt for visual
diffing in removing cosmetic whitespace for just p tags and can't think of
anything that would break because of this right now. So let's do it and wait
for things to break.
2020-06-26 18:55:15 +02:00
Niklas Fasching
30dd2794cf Introduce blorg: MVP static site generator
hugo is nice - but it's huge. I've never built a static site generator before
and thought the world could use one more - it's not like there's already enough
choice out there!

No, but seriously. I love hugo and it has all the bells and whistles and you
should definitely use that and not this. I just like reinventing the wheel to
learn about stuff - and I like the 80/20 rule. This gives like 60% of what I
want already and is tiny fraction of hugo in terms of LOC (hugo without it's
bazillion dependencies is like 80k+ - this is like 500 and very likely won't
ever grow above let's say 5k).

Also org mode is awesome and why not use it as a configuration format as
well. Let's see where this goes. YOLO.
2020-06-26 18:52:43 +02:00
Niklas Fasching
5e50794af0 Add title export option
see https://orgmode.org/manual/Export-Settings.html
2020-06-26 12:25:17 +02:00
Niklas Fasching
9ffcaa8e1c Add support for table column display width markers
see https://orgmode.org/manual/Column-Width-and-Alignment.html#Column-Width-and-Alignment
2020-06-21 22:13:31 +02:00
Niklas Fasching
9f7e8a8fbd Implement #+MACRO 2020-04-17 16:41:06 +02:00
Niklas Fasching
2ab65d300a Fix #+LINK: file xyz edge case
if we define a custom LINK for file we run into index problems bc it's trimmed
before already - this fixes that. Shouldn't ever happen but whatever, fuzzing
found it.
2020-04-17 16:18:33 +02:00
Niklas Fasching
1e36b3b46b Implement #+LINK 2020-04-17 15:59:03 +02:00
Niklas Fasching
47a3653d61 Fix inline src index off by one
thank god for fuzzing
2020-04-17 15:39:43 +02:00
Niklas Fasching
7e69931976 html: Implement source block :exports parameter 2020-04-17 15:24:42 +02:00
Niklas Fasching
efe1c4eb07 html: Cleanup block name switch 2020-04-17 15:12:04 +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
232c27327c html: Fix inline source block highlighting & escaping 2020-04-16 16:22:36 +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
cbf1b8c38c html: Allow inline html export in #+TITLE 2020-04-16 15:18:33 +02:00
Niklas Fasching
4b56810a65 Implement inline export blocks
https://orgmode.org/manual/Quoting-HTML-tags.html
2020-04-16 14:58:23 +02:00
Niklas Fasching
3018ace8d0 Implement inline source blocks
https://orgmode.org/manual/Structure-of-Code-Blocks.html
2020-04-16 14:58:13 +02:00
Niklas Fasching
6ed46ba95d html: Do not render non-html export blocks 2020-03-31 16:30:38 +02:00
Niklas Fasching
c68d931100 html: Fix example blocks - escape html
While example blocks do not render inline markup and are thus parsed raw in
some way, their contents are not literal html and thus still need to be html
escaped.
2020-03-31 16:30:28 +02:00
Niklas Fasching
115a8b9c1b Fix latex fragment parsing
delimiters are not always 2 in length - $ being the exception. Also we have to
make sure to handle both $ and $$ delimiters.

Not proud of this solution but can't think of anything simpler right now - will
come back to this later hopefully.
2020-01-20 18:47:26 +01:00
Niklas Fasching
f1361615ed html: Allow limiting level of headlines to be included in toc
The org mode toc OPTION does not just support true/false - it also allows
specifying the max headline level [1] to be included in the toc.

[1] headline level as seen in org mode - not the html tag level
2020-01-20 18:44:09 +01:00
Niklas Fasching
7a2cd1abb1 Refactor: Return string value from GetOption
Turns out org export options can have meaningful values beside true and false -
let's make it possible to use them.
2020-01-20 18:14:10 +01:00
Niklas Fasching
614307a8f5 HTML export: Export #+TITLE as h1 and offset other headlines accordingly
emacs exports #+TITLE as <h1> and all other headlines accordingly as
`lvl + 1` - we'll go with that.
2019-12-22 14:17:14 +01:00
Niklas Fasching
b61e49eb85 Preserve whitespace (indentation) inside paragraphs
We want original whitespace to be rendered in some cases (e.g. verse
blocks). This requires information about the original whitespace to be
preserved during paragraph parsing. As html ignores (collapses) whitespace by
default we don't have to adapt the html writer and can just selectively enable
rendering of the preseverved whitespace wherever we want it using
css (white-space: pre).

To differentiate meaningful whitespace from document structure based
indentation (i.e. list item base indentation) we need to introduce
document.baseLvl. A paragraph by itself does not have enough information to
differentiate both kinds of whitespace and needs this information as context
[0].

As we're already touching list indentation i went along and improved (fixed?)
descriptive list item indentation rendering in the org writer (it should match
emacs tab behavior - i.e. indent subsequent lines up to the `:: `).

[0] e.g. list items can contain blank lines - a paragraph starting with a blank
line would not know that it is part of a list item / has a base indentation -
the blank line would suggest a baseLvl of 0.
2019-12-22 14:17:14 +01:00
Niklas Fasching
466903d3ac
Merge pull request #15 from niklasfasching/nodes-as-string
Improve ease of extending writers
2019-11-02 23:48:20 +01: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
c9d11e1556 Refactor OrgWriter and HTMLWriter: Remove cloning
Extension of the org & html writers is made possible by creating circular
references between the extending and extended writer - that way the extending
writer can forward all methods it doesn't implement to the extended writer and the
extended writer can use the extending writer as the root for method calls to
make sure methods overridden in the extending writer are used even for nested
method calls.

This circular reference leads to problems when cloning writers - cloning the
extended writer merely copies the pointer to the extending writer - i.e. the
extending writer does not get cloned with an updated reference to the extended
writer. Thus method calls to the extending writer act as if no cloning took
place and things break.

The easiest solution is to just get rid of cloning. We could also clone the
ExtendingWriter and replace it's reference to the extended writer with the just
cloned one but that's harder so we just remove it.

As there are a lot of "extending writer" and "extended writer" in the above
paragraphs and I'm too lazy to write up something better here's another attempt
at a TLDR:

Cloning is broken as ExtendingWriter is a reference to a writer that has
a reference to the writer we are cloning - that writer would have to have it's
reference updated but that's hard. So we solve it it by not cloning at all.
2019-11-02 23:33:34 +01:00
Niklas Fasching
4292628c80 Fix ExplicitLineBreak parsing
fuzzed index out of range and moved range check into for condition as \\
followed by spaces at the end of the inline text should not be turned into an
ExplicitLineBreak (just like \\ not followed by spaces).
2019-10-29 01:03:10 +01:00
Niklas Fasching
14900e97e2 Add support for extending writers
Go does not support inheritance, just composition. While composition with type
embedding (i.e. forwarding method calls to the embedded type) can replace
inheritance for most use cases this is not one of them. We really want to
overwrite methods so that method calls from inside the base writer also use the
custom methods ouf our extending writer - naive embedding does not work here
as the this in this.WriteText refers to the embedded type rather than the outer
extending type (see open recursion).

A simple solution is to make a reference of the extending type
available from the extended type and use that for nested method calls. We'll go
with that one as it does not require huge code changes. Another solution would
be to flatten the writing process and not use nested method calls - this is
what blackfriday does. Assuming the current solution works I feel it's cleaner
and keeps the ugliness of simulating inheritance with composition contained to
a small portion of the code while blackfridays approach requires all write
methods to be written in a flat style (i.e. not do nested calls to write by
being called twice with entering / leaving). The current solution becomes ugly
if we want to do multiple levels of extending but i don't expect that to be a
valid use case - if it turns out to be one we can always adapt to it
later. YAGNI.
2019-10-27 16:43:42 +01:00
Niklas Fasching
f69b043136 Fix index out of range in headline priority parsing
fuzzed - counting is hard...
2019-10-27 15:24:24 +01:00
Niklas Fasching
20970ec872 Add support for NAME keyword 2019-10-27 15:12:38 +01:00
Niklas Fasching
2afd11581c Use document.ReadFile to read #+SETUPFILE
Now that we allow providing a custom ReadFile implementation we should use it
everywhere we read files.
2019-10-08 22:25:35 +02: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
2347800922 Remove superfluous latex test case and fix description 2019-09-28 15:22:59 +02:00
Niklas Fasching
adeeb9235d Handle malformed :PROPERTY: drawers
Until now we'd get index out of range errors trying to index into the match if
:PROPERTIES: was followed by a non-property. Thanks fuzz
2019-09-28 15:12:19 +02:00
Niklas Fasching
76b157b8ce Add support for latex fragments 2019-09-28 15:04:04 +02:00
Niklas Fasching
de302bbc0a Add make preview & update README with basic development instructions
not sure how helpful this really this but something is better than nothing i
guess
2019-09-22 02:02:32 +02:00
Niklas Fasching
a143b04826 html: write descriptive list closing dt tag on separate line
now that i'm already looking at it due to the bug leenzhu found why not put the
</dt> on a separate line to match the convention - looks better to me; doesn't
change anything.
2019-08-26 14:37:52 +02:00
Niklas Fasching
e6c8cdbd9d
Merge pull request #9 from leenzhu/master
WriteDescriptiveListItem() missing closing tags for dt and dd
2019-08-26 14:34:26 +02:00
leen
9aec7ca151 WriteDescriptiveListItem() missing closing tags for dt and dd 2019-08-26 18:38:04 +08:00
Niklas Fasching
f67a251e27 html: Fix html writer footnotes (in headlines)
writer.footnotes must be a pointer as we copy the writer in nodesAsString() and
can thus end up modifying the footnotes.list slice without it being reflected in
the original writer (i.e. when the backing array of the slice changes).
2019-08-24 12:11:23 +02:00
Niklas Fasching
97fe8b7850 html: Fix code block export (superfluous newlines)
I didn't consider that all newlines in the pre block will be printed and we
thus shouldn't wrap html that has it's tags on separate lines (i.e. contains
superfluous newlines) - wrapping in a div less accurately represents
org-html-export but it provides the same information and gives us more freedom
in the return value of HighlightCodeBlock as well as allowing us to keep the
html tags on new lines (consistency).
2019-07-28 16:40:09 +02:00
Niklas Fasching
777899c803 HTML export: Update footnote numbering to start with 1
I went with 0 based numbering because it was easier but after looking at the
results 0 based numbering looks bad to me... let's start with 1 like everyone
else as it's just a few more lines of code.
2019-07-07 21:25:42 +02:00
Niklas Fasching
d154403f06 HTML export: Improve handling of missing footnote definitions 2019-07-07 18:01:22 +02:00
Niklas Fasching
09c85c3e66 Update README
I never wanted to reproduce the emacs org-export-as-html output exactly but
rather just provide a sensible exporter - the README should tell users what to
expect here.
2019-07-07 17:38:47 +02:00
Niklas Fasching
37d33c1206 HTML export: Export src block language as css class
Org mode exports source blocks with the language as a css-class of the exported
source block - it's easy enough to do the same.
2019-07-07 10:19:24 +02:00