aldrichtr / PSOrgMode

A module for reading and writing the org-mode markup format
0 stars 0 forks source link

Parse text in OrgMode format into an Object #12

Open aldrichtr opened 2 years ago

aldrichtr commented 2 years ago

Parsing text

A note to the reader

I am rewording the description of this issue rather than adding commentary to avoid confusion

I spent quite a few days trying to make this module behave like org-element.el, but in the end I made a different design choice. See my notes in this comment and this comment which were made before rewording this.

Although it is useful to keep a record of intentions, I felt like it was confusing to have the change in direction scattered in multiple comments, so I did a bit of "history editing" here.

"ConvertFrom" functions

PowerShell conventional naming for functions that parse text formats are ConvertFrom-<format> such as Json, Csv, etc.

In keeping with this convention, the function ConvertFrom-OrgMode should be exported from the module. It should be used in the same way as well, so:

Get-Content 'path/to/file.org' | ConvertFrom-OrgMode

ConvertFrom-OrgMode should chunk the input, send the input off to more specific parsers, and build the object tree as the objects are returned. For example ConvertFrom-OrgHeadline, ConvertFrom-OrgSection etc.

Currently, it is very much a "line-by-line" parser, with very basic recognition of org elements (namely, it can recognize headlines and planning). So, ConvertFrom-OrgMode needs the following:

aldrichtr commented 2 years ago

Currently, it is very much a "line-by-line" parser, with very basic recognition of org elements (namely, it can recognize headlines and planning). So, ConvertFrom-OrgMode needs the following:

After several attempts to make PowerShell behave like emacs, I have finally realized that is the wrong way to go about parsing a buffer. see my notes on #14 .

Ultimately, it should be a line-by-line parser, as that is exactly what PowerShell is good at...