Skip to content

jakub-stastny/blog.parser.post.org

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

https://github.com/jakub-stastny/blog.parser.post.org/actions/workflows/test.yml/badge.svg

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.

Format

#+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.

Resources and community

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.

Understanding the code base

Where’s all the source code?

Literate programming

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.

Setup

If you want to contribute or just play around with it, check out how to set up the repository.