Commit graph

270 commits

Author SHA1 Message Date
Eng Zer Jun
568df2c38d
build: update go directive in go.mod to 1.17
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-01-07 09:08:56 +08:00
Niklas Fasching
f2286d48ff cli: Fix support for reading input from stdin - prefer file input
Apparently that way of detecting data on stdin is not really fool
proof. Instead of improving that let's just swap the order and look for a file
first. yolo.
2021-12-26 23:25:30 +01:00
Niklas Fasching
c82b26b540 cli: Support reading input from stdin 2021-12-26 23:17:19 +01:00
Niklas Fasching
df89d27a4e
Merge pull request #65 from josephburnett/trim-fast-tags
Support fast tags by trimming the key binding.
2021-10-28 22:10:58 +02:00
Joseph Burnett
aff78bc23d Support fast tags by trimming the key binding. 2021-10-28 17:23:19 +02:00
Niklas Fasching
9995b3cdad html: Improve link abbreviation (#+LINK) resolution
Handle `%s`/`%h` interpolation and add support for shorthand of prefix only
links / links with empty tag (i.e. `[example]` instead of [example:]). See
[1] and [2]. As so often we don't match org mode output completely but our
output looks sane enough to me so let's move along for now.

[1] https://orgmode.org/manual/Link-Abbreviations.html
[2] https://github.com/bzg/org-mode/blob/main/lisp/ol.el#L1011
2021-10-25 16:50:15 +02:00
Niklas Fasching
34dfe32024 Document ealb in options.org fixture 2021-07-25 21:54:15 +02:00
Niklas Fasching
c901c00166 Add non-standard ealb (east asian line break) option
See pandoc: https://pandoc.org/MANUAL.html#extension-east_asian_line_breaks
2021-07-20 22:33:28 +02:00
Niklas Fasching
0e68f1db40 Update stylesheet to handle unwrapped list items 2021-07-20 22:24:29 +02:00
Ori
4d3a099922 For simple list items, don't wrap in <p> tags
This also removes extra newlines for simple list items, see changes to
tests for details.

Closes #57
2021-07-13 23:41:32 +02:00
Niklas Fasching
429602aba7 make: fix preview command 2021-07-13 22:13:58 +02:00
Niklas Fasching
abb81851be html: Hide excluded headlines from TOC
emacs org mode did it first
2021-07-13 20:54:23 +02:00
Niklas Fasching
e5ae608865 Improve Makefile: Only install dependencies and rebuild when required
By getting rid of the PHONY install and bundling the go get with its uses we
can prevent unnecessary go gets in `make build` - this speeds up development as
I run `make generate-fixtures` a lot and fetching dependencies takes
comparatively long.

We also add the `-d` flag to go get to get rid of the deprecation warning
```
go get: installing executables with 'go get' in module mode is deprecated.
	To adjust and download dependencies of the current module, use 'go get -d'.
	To install using requirements of the current module, use 'go install'.
	To install ignoring the current module, use 'go install' with a version,
	like 'go install example.com/cmd@latest'.
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
```
2021-04-17 15:48:41 +02:00
Niklas Fasching
21f1af7d48 Add support for custom numbering of ordered list using [@\d+]
org mode supports [1] setting the value attribute [2] of ordered list items to
change the numbering for the current and following items. Let's do the same. As
the attribute has no meaning for other types of lists [2] we'll just not
support it for those cases [3].

[1] https://orgmode.org/manual/Plain-Lists.html#Plain-Lists
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li#attributes
[3]
Org mode seems to instead set the id attribute for e.g. unordered lists
starting with `[@\d+]\s` - but I don't really see the value in that and will
skip that for now.
2021-04-17 15:43:19 +02:00
Niklas Fasching
b3edd6c182 Improve block parameter parsing
The actual parameter parsing logic in emacs org mode is quite complex [1]. All
we want for now is to handle parameter values containing spaces [2]. Splitting
on ` :` gets us close enough for now. As I'm very opposed to copying 100 lines
of parameter parsing logic just to get exports right let's wait for use cases -
no hurt in gathering requirements as we go.

[1] https://github.com/bzg/org-mode/blob/master/lisp/ob-core.el#L1481
[2] I never ran into such parameters before and wrongly assumed that splitting
on spaces would be enough. boy was i wrong - just look at that massive
function [1]! that's why we can't have nice things!
2021-04-11 21:52:12 +02:00
Niklas Fasching
b9f05878fa Revert "Manually install go 1.16 until github actions updates image"
This reverts commit bf7f957af2.

We still have to manually install it for now but we don't have to fuck around
with env vars anymore. github actions still defaults to go 1.15 [1]. Whatever.

[1]
```
ls -lisah $(which go)
108022 0 lrwxrwxrwx 1 root root 42 Mar 18 22:15 /usr/bin/go ->
/opt/hostedtoolcache/go/1.15.10/x64/bin/go
```
2021-03-28 17:23:05 +02:00
Niklas Fasching
7c239a7aeb html: Add support for #+TOC keyword
org mode allows rendering the toc anywhere in the html document using the `TOC`
keyword [1]. There's more options but `#+TOC: headlines $n` should be enough
for starters. Note that org mode still requires setting `#+OPTIONS: toc:nil` to
disable the default toc

[1] https://orgmode.org/manual/Table-of-Contents.html
2021-03-28 17:12:25 +02:00
Niklas Fasching
bf7f957af2 Revert Me: Manually install go 1.16 until github actions updates image 2021-03-01 14:19:14 +01:00
Niklas Fasching
703066682e Update to go v1.16 and embed more extensive default blorg.org
Instead of the bare bones default config we embedded as a string until now we
can use go 1.16 embed to embed the test blorg.org which makes a much better
starting config (if only to see what's possible).
2021-03-01 14:10:34 +01:00
Niklas Fasching
02df432d76 Refactor main cmd: Improve error messages and code layout 2021-01-23 20:50:57 +01:00
Niklas Fasching
5dadf8c4c2 html: Support pretty relative links
Hugo defaults to serving files with pretty urls [1] - this means
`/posts/foo.org` is served at `/posts/foo/`. This works because servers
default to serving index.html when a directory is specified and hugo renders
the post to `/posts/foo/index.html` instead of `/posts/foo.html`. To make
relative links work we need to (1) remove the fake `foo/` subdirectory from
unrooted links and (2) replace any `.org` suffix with `/`.

[1] https://gohugo.io/content-management/urls/#pretty-urls
2021-01-02 20:48:28 +01:00
Niklas Fasching
84d56e9562 html: Rewrite local links to .org files to .html
emacs rewrites links to `.org` files to corresponding links with `.html`
extension in the html export.
2021-01-02 20:47:55 +01:00
Niklas Fasching
1b68e209ac Migrate from travisci to github actions
because all my other repos use it and hackernews told me travisci free tier is
dead.
2021-01-02 20:42:59 +01:00
Niklas Fasching
cdc54f17b1 Setup go.mod 2021-01-02 20:42:16 +01:00
Niklas Fasching
a8e74684a5
Merge pull request #43 from pjkundert/fix-drawer-end
Make ORG-mode drawer "🔚" case-insensitivie
2020-11-27 23:37:21 +01:00
Perry Kundert
4cf9dff010 Add a lower-case org-mode drawer 🔚 test 2020-11-20 11:41:24 -08:00
Perry Kundert
04fec98ffd Make ORG-mode drawer "🔚" case-insensitivie 2020-11-16 12:37:37 -08:00
Niklas Fasching
1cd3791386 Add helper script to simplify creating hugo pull requests
For hugo to pull in changes we need to create a pull request. Creating the
branch for that is repetitive and can be easily automated, so let's do
that. Creating the pull request itself is not as easily automated as it might
be necessary to provide a little context for the changes - so let's keep it
manual.
2020-07-28 20:39:06 +02:00
Niklas Fasching
c025db7bdd Fix comments: comments must start with #\s not just # 2020-07-28 19:28:30 +02:00
Niklas Fasching
16ccafe8a3 blorg: ignore draft pages 2020-07-24 18:45:22 +02:00
Niklas Fasching
64b2b22270 Fix list item parsing and headline token lvls
As headlines are always lvl (indent) 0 I thought it would be clever to abuse
the lvl field to store the headline lvl. Well, here we are - it wasn't clever.

List items only end when their parent ends or they run into something that's
not indented enough - everything else becomes part of the list item. Abusing
the token.lvl field (indent) for the headline lvl means headlines look indented
to the list item parsing logic - i.e. they become part of the list item if the
headline has a high enough lvl. That should never happen - so let's get rid of
the hack and (re-)calculate the headline lvl when we need it.
2020-07-22 13:49:58 +02:00
Niklas Fasching
add727c011 html: Wrap headline+content & headline content in containers
Org mode does it.
2020-06-29 16:48:46 +02:00
Niklas Fasching
55b149054d fuzz: Fix index out of range for results without content
Offending crasher:

"\n\n\n\n\n\n\n\n\n#+RESULTS:"
2020-06-28 21:26:55 +02:00
Niklas Fasching
d85768891c html: Support links with image descriptions
Turns out Org mode supports image links natively and we don't have to go out of
spec!

From https://orgmode.org/manual/Images-in-HTML-export.html:

[...] if the description part of the Org link is itself another link, such as
‘file:’ or ‘http:’ URL pointing to an image, the HTML export back-end in-lines
this image and links to [...]
2020-06-28 21:16:46 +02:00
Niklas Fasching
c536adf6e9 Update blorg test - make it actually fail when public changes 2020-06-26 22:21:43 +02:00
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