Handle changes to org AST in v9.7#9
Merged
jlumpe merged 11 commits intojlumpe:masterfrom Aug 25, 2025
Merged
Conversation
Org v9.7 introduced two significant changes to the AST that must be
considered when enumerating a node's properties:
1. Some properties which were previously present in the property
list (e.g. :begin and :end) are now stored as elements of a vector
under the :standard-properties key in the property list.
2. Property values can now be 'deferred', meaning they are not
calculated until accessed via a getter function like
~org-element-property~.
~org-element-properties-map~ is now the recommended way to traverse a
node's properties and handles both of these changes.
Previously, ~test-export~ just asserted that the exported JSON was valid JSON and the $$data_type key of the top-level object was "org-document". This commit introduces a JSON file representing the expected output of the test with some keys whose values might change from one run to another (e.g. `ref`) omitted. To compare this file with the actual output of the test, an optional argument was added to the ~json-compare~ test helper that, when non-nil, causes the comparison not to fail when keys in one object are missing from the other.
It appears Emacs 30 introduces a new warning: ox-json.el:1086:26: Error: ‘memql’ called with literal list that may never match (element 1 of arg 2)
Owner
|
Hi tcahill, thanks for submitting the PR. Apologies for the delay in responding. I currently don't have a development environment set up for this project, but I am planning on getting that working again and reviewing + merging this PR when I have the time. Hopefully sometime this month. |
173a064 to
9797c65
Compare
Owner
|
Thanks for the great work on this. I finally got a good test environment set up and was able to revisit it. I actually spent a lot of time updating/improving the tests first and inadvertently duplicated your work there. I've merged the current master back into this PR, which required overwriting all the test improvements. Let me know if it looks alright. |
Owner
|
Merged, thanks for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I see you're not planning to continue maintaining this package, so it's totally fair if you don't want to integrate these changes - just thought I'd submit this for your consideration or in case anyone else might find it useful!
Currently using this package with org v9.7 causes most nodes to end up with an error object under the
standard-propertiesproperty like this:Additionally, some property values are now 'deferred' and look like this in the exported JSON:
It turns out that org 9.7 includes changes to the AST that account for both of these issues:
Some properties like
beginandendhave been moved into a vector understandard-properties.ox-json-encode-autodoesn't handle vectors, thus the error.Some properties can now be deferred and their value won't be calculated until accessed through an appropriate function like
org-element-property.Both of these changes were introduced in https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1260f61830bfdee821de9233051a821f4ac4831c. Here, I'm using the function now recommended when enumerating all of the node's properties,
org-element-properties-map, which both expandsstandard-propertiesand optionally resolves deferred properties.To ensure I'm not breaking earlier versions, I also extended the
test-exporttest to do a full comparison between the expected and actual JSON output. Becauserefs aren't stable and some properties don't appear to have consistent values across org-mode/Emacs versions, I removed some properties from the "expected" JSON and modified the JSON comparison helpers to optionally tolerate missing keys and just assert that the keys that two objects have in common have the same values. Tests are passing for all versions except 26.3, and it looks like that version is also broken on master.