Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support writing to org files? #11

Open
nishadsabnis opened this issue Sep 28, 2019 · 4 comments
Open

Support writing to org files? #11

nishadsabnis opened this issue Sep 28, 2019 · 4 comments

Comments

@nishadsabnis
Copy link

Is there any plan to support writing to org files? i.e. creating new org-nodes?

@karlicoss
Copy link
Owner

karlicoss commented Sep 29, 2019

Hey, I actually do have a small library, inorganic to write org-mode files and you can see examples in doctests and in orger library. I implemented this in a separate library because want to understand what would be a good API first. So let me know if inorganic works for you and I'd be curious about your usecase, so I could think of a convenient interface!

@hrehfeld
Copy link

Is there any reason why there's no documentation on constructing nodes? It seems that roundtrip even with complex files works flawflessly, the only part that is missing is how to construct the ast by hand?

@karlicoss
Copy link
Owner

@hrehfeld for documentation, do you mean in orgparse, or in the inorganic library I mentioned above?
For orgparse, I guess the main issue that the original author of library (and me) didn't have this in mind, so the 'ast' is geared towards single pass document reading. It's also possible to take the document object tree and modify it... but writing back might be a bit more complicated, although doable. I just didn't have many usecases for it so far.

@hrehfeld
Copy link

Hm, I see.

@hrehfeld for documentation, do you mean in orgparse, or in the inorganic library I mentioned above?
I mainly need full round-trip org-mode parsing, i.e. parse the file, change something, write back the changes. So.. a separation doesn't really make that much sense here other than to keep reading/writing separate.

For orgparse, I guess the main issue that the original author of library (and me) didn't have this in mind, so the 'ast' is geared towards single pass document reading. It's also possible to take the document object tree and modify it... but writing back might be a bit more complicated, although doable. I just didn't have many usecases for it so far.

my usecase is definitely:

root = orgparse.parse('myfile.org')
root.title = 'Look Ma, I changed the Title!'
orgparse.dump(root, 'myfile.org')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants