Find a file
Niklas Fasching 5464ab37d2 Fix race condition surrounding global orgWriter
Since writers are normally only used synchronously (i.e. to write one document
at a time), we don't guard modifications to their internal
state (e.g. temporarily replacing the string.Builder in WriteNodesAsString)
against race conditions.

The package global `orgWriter` and corresponding use cases of it (`org.String`,
`$node.String`) break that pattern - the writer is potentially used from
multiple go routines at the same time. This results in race conditions that
manifest as error messages like e.g.

    could not write output: runtime error: invalid memory address or nil pointer dereference. Using unrendered content.

Additionally, since we catch panics in `Document.Write`, the corresponding
stack trace is lost and dependents of go-org never know what hit them.

As using a writer across simultaneously across go routines is not a standard
pattern, we'll sync the use of the global `orgWriter` instead of trying to make
the actual writer threadsafe; less code noise for the common use case.
2023-03-12 11:28:55 +01:00
.github/workflows Revert "Manually install go 1.16 until github actions updates image" 2021-03-28 17:23:05 +02:00
blorg Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
etc make: Allow generating single fixture 2022-07-24 00:28:23 +02:00
org Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
.gitignore Migrate from travisci to github actions 2021-01-02 20:42:59 +01:00
go.mod Refresh test fixtures for chroma v2.2.0 2022-06-28 06:37:06 -06:00
go.sum Refresh test fixtures for chroma v2.2.0 2022-06-28 06:37:06 -06:00
LICENSE Add MIT License 2018-12-20 20:30:14 +01:00
main.go highlight: support highlighting lines in the default writer 2022-07-18 03:56:15 +09:00
Makefile make: Allow generating single fixture 2022-07-24 00:28:23 +02:00
README.org README: Remove deprecated install target and check for go in setup 2022-03-19 18:39:14 +01:00

go-org

An Org mode parser and static site generator in go. Take a look at github pages

https://raw.githubusercontent.com/niklasfasching/go-org/master/etc/example.png

Please note

  • the goal for the html export is to produce sensible html output, not to exactly reproduce the output of org-html-export.
  • the goal for the parser is to support a reasonable subset of Org mode. Org mode is huge and I like to follow the 80/20 rule.

usage

command line

$ go-org
Usage: go-org COMMAND [ARGS]...
Commands:
- render [FILE] FORMAT
  FORMAT: org, html, html-chroma
  Instead of specifying a file, org mode content can also be passed on stdin
- blorg
  - blorg init
  - blorg build
  - blorg serve

as a library

see main.go and hugo org/convert.go

development

  1. make setup
  2. change things
  3. make preview (regenerates fixtures & shows output in a browser)

in general, have a look at the Makefile - it's short enough.