Popularity
92 Stars
Updated Last
4 Months Ago
Started In
November 2021

Org.jl

A library for working with Org files. Specifically, this provides utilities for:

  • Parsing Org text to an AST (Abstract Syntax Tree)
  • Regenerating Org text from an AST
  • Basic manipulation and analysis of an Org document AST
  • Generating basic representations Org content in the terminal, and a few other forms.

With the exception of some of the particularly fancy capabilities provided by org-mode (like Babel and Calc-based spreadsheeting), this project aims to exactly match the interpretation of Org mode markup — specifically the AST generated by org-element.el. This goal is not yet achieved, however the bulk of the work is now complete.

Org.jl implements the vast majority of the org-syntax document (see the Progress table). This can be checked by looking at Org.compatability in Julia.

Basic usage

# after installing with ~] add Org~ or ~Pkg.add("Org")~
using Org
text1 = org"Some *Org* markup, written with ease using the ~org\"\"~ macro."
parsetree(text1)  # show the generated parse tree

text2 = parse(OrgDoc, "Some *Org* markup, written with ease using the ~parse~ function.")
diff(text1, text2)  # show the components of the parse trees that differ

dochead = @doc Org.Heading  # the documentation for the Heading component (::OrgDoc)
org(dochead)  # generate Org text that produces the Org.Heading object
string(dochead)  # as above, but produces a String

parse(OrgDoc, string(dochead)) == dochead  # round-trip equality

# get the lang of each source block
[c.lang for c in dochead.components if c isa Org.SourceBlock]

Progress

ComponentTypeParseOrgTermHTML
HeadingXXXXX
SectionXXXXX
Affiliated KeywordsXXXX
GreaterBlockXXXXX
DrawerXXXXX
DynamicBlockXXXXX
FootnoteDefinitionXXXX
InlineTaskX
ItemXXXXX
ListXXXXX
PropertyDrawerXXXXX
TableXXXXX
BabelCallXXXXX
BlockXXXX
ClockXXXX
DiarySexpXXXX
PlanningXXXX
CommentXXXXX
FixedWidthXXXXX
HorizontalRuleXXXXX
KeywordXXXX
LaTeXEnvironmentXXXX
NodePropertyXXXXX
ParagraphXXXXX
TableRowXXXXX
TableHRuleXXXXX
BlankLineXXXXX
OrgEntityXXXXX
LaTeXFragmentXXXX
ExportSnippetXXXXX
FootnoteReferenceXXXXX
InlineBabelCallXXXXX
InlineSrcBlockXXXXX
RadioLinkXXXXX
PlainLinkXXXXX
AngleLinkXXXXX
RegularLinkXXXXX
LineBreakXXXXX
MacroXXXXX
CitationXXXXX
RadioTargetXXXXX
TargetXXXXX
StatisticsCookieXXXXX
SubscriptXXXXX
SuperscriptXXXXX
TableCellXXXXX
TimestampXXXXX
TextPlainXXXXX
TextMarkupXXXXX