niklasfasching / go-org

Org mode parser with html & pretty printed org rendering. also shitty static site generator.
https://niklasfasching.github.io/go-org/
MIT License
353 stars 48 forks source link

Question: What is the purpose of NodeWithName? #106

Closed andrewebdev closed 1 month ago

andrewebdev commented 9 months ago

Hi, I'm building an application that depends on go-org. I'm wondering what the purpose of the NodeWithName [1] struct is.

I looked through org-mode syntax documentation, but could not find anything regarding this keyword usage. Are you using this for something internal to go-org only?

[1] https://github.com/niklasfasching/go-org/blob/master/org/keyword.go#L17

niklasfasching commented 9 months ago

Hi,

That struct is used to support the #+NAME: affiliated keyword (example) to e.g. reference source blocks by name. We're not writing the name to html so not much is happening with it. blorg uses it to keep named templates in an org file

andrewebdev commented 9 months ago

Okay, thanks. Ideally, I would expect the writer to deal with such edge cases so that the AST doesn't have any assumptions. I'm using #+name: in some of my documents to store variables for macro expansion later. So this slightly gets in my way. I'm wondering if it's not better to just keep it as a normal keyword, but as part of the node it's attached to, rather than the current section.

I'm not complaining however, It's your project, so your decisions ;) ...

I'm not 100% ready to share my project yet, but I'm aiming to open source that soon, but in short I built an app that can generate multiple types of document formats, from one org file. From one file, you can generate, Markdown, Html, Typst (for simple PDF generation), and more ... So you can see why I'm making these suggestions.

niklasfasching commented 9 months ago

Not sure I follow, could you expand on why this is a problem for your use case? A lot of org constructs are currently implemented in this "wrapper-node" fashion (e.g. Emphasis, NodeWithMeta) and this didn't feel out of place. As said, currently the only use case is lookup (i.e. document.NamedNodes is enough, we don't have to create NodeWithName wrappers).

I'm not convinced it's adding assumptions to the AST though... Happy to talk more :)

niklasfasching commented 1 month ago

Feel free to re-open if you get back to this