Parser of my blog post Org mode based format. It takes Org mode format as the input and gives JSON with fields title
, excerpt
and body
as the output. It will also surface any top-level properties.
My raw blog posts are available here, they can serve as an example of expected input.
For DATE
, see https://orgmode.org/manual/Export-Settings.html. We use the ISO 8601 standard for formatting it.
#+DATE: 2021-06-11T18:37:05+05:00
* Blog post title
This is the excerpt of the blog post.
** First heading
Content
// TODO: Make it a Rust example once I know how the smeg to program in it.
import { postToJSON, bodyToHTML } from "jakub-stastny/blog.parser.org"
const post = postToJSON(org_string, timezone)
console.log(JSON.stringify(post))
{
"title": "Blog post title",
"excerpt": "This is the excerpt of the blog post.",
"body": "** First heading\n\nContent",
"published_timestamp": 1623454660
}
Notice that the body
is still Org mode formatted.
Nothing is being exported to HTML, since we parse Org mode on the front-end as well. That’s what the bodyToHTML
function is for: just compile this package as a WebAssembly module and use it on both your back-end and your front-end!
Published timestamp is unix epoch timestamp.
This repository is only one of many packages that I wrote for my blog. For the overall architecture and documentation please see the blog meta repo. That’s also the place to raise any issues if you encounter any and to discuss the project and ask questions.
Where’s all the source code?
In case you’re wondering where are all the Rust files, you have to tangle code blocks from Org mode files in src
into actual Rust files using Org mode in Emacs.
Don’t worry about it though – unless you want to set up the code locally, there is no need. Just read the Org mode files in the src
directory, it contains well-documented code.
If you’re curious why am I doing this, you can check my post on literate programming.
If you want to contribute or just play around with it, check out how to set up the repository.