6262; ; using `ox-json-encode-auto' .
6363
6464; ; :json-postprocess (symbol) - How to postprocess the final output. Values are `pretty'
65- ; (indent properly), `minimal' (remove whitespace), and nil (nothing, maybe faster?).
65+ ; ; (indent properly), `minimal' (remove whitespace), and nil (nothing, maybe faster?).
6666
6767; ;; Code:
6868
@@ -106,6 +106,7 @@ be overridden with the :json-exporters option.")
106106 all (
107107 ; Never include parent, leads to infinite recursion
108108 :parent nil
109+ :buffer nil
109110 ; These properties have to do with absolute buffer positions and thus probably aren't useful to export
110111 :begin nil
111112 :end nil
@@ -356,9 +357,29 @@ Used for error reporting.")
356357; ;; Org-mode utility code
357358
358359(defun ox-json-node-properties (node )
359- " Get property plist of element/object NODE."
360- ; It's the 2nd element of the list
361- (cadr node))
360+ " Org v9.7 introduced two significant changes to the AST that must be
361+ considered when enumerating a node's properties:
362+
363+ 1. Some properties which were previously present in the property
364+ list (e.g. :begin and :end) are now stored as elements of a vector
365+ under the :standard-properties key in the property list.
366+
367+ 2. Property values can now be 'deferred', meaning they are not
368+ calculated until accessed via a getter function like
369+ ~org-element-property~.
370+
371+ ~org-element-properties-map~ is now the recommended way to traverse a
372+ node's properties and handles both of these changes."
373+ (if (fboundp 'org-element-properties-map )
374+ (let ((expanded-properties nil ))
375+ (org-element-properties-map
376+ (lambda (name value )
377+ (setq expanded-properties (plist-put expanded-properties name value)))
378+ node t )
379+ expanded-properties)
380+ ; for org versions < 9.7, just return the property list, which is the second
381+ ; element of the list
382+ (cadr node)))
362383
363384(defun ox-json--is-node (value )
364385 " Check if VALUE is an org element/object."
@@ -945,6 +966,12 @@ JSON-encoded values."
945966 info
946967 type-plists)))
947968
969+ (defun ox-json--skip-property (property )
970+ " Return non-nil if an element property PROPERTY should be skipped, regardless of the value of the
971+ :json-property-types option."
972+ ; Apparently 9.7 introduces some private property names, skip these.
973+ (cl-search " --" (symbol-name property)))
974+
948975(defun ox-json--export-properties-base (property-plist default-type info &rest type-plists )
949976 " Export org node property values by looking up their types in a series of plists.
950977
@@ -962,7 +989,7 @@ JSON-encoded values."
962989 (ox-json--loop-plist (key value property-plist)
963990 do (setq property-type
964991 (apply #'ox-json--plists-get-default key default-type type-plists))
965- if property-type
992+ if ( and property-type ( not (ox-json--skip-property key)))
966993 collect (cons key (ox-json-encode-with-type property-type value info)))))
967994
968995(cl-defun ox-json-export-node-base
@@ -1162,7 +1189,7 @@ INFO is the plist of export options."
11621189 :extra-properties (ox-json-timestamp-extra-properties timestamp info))))
11631190
11641191
1165- ; ;; Filter functions functions
1192+ ; ;; Filter functions
11661193
11671194(defun ox-json-filter-final-output (text back-end info )
11681195 " Post-process the entire output."
0 commit comments