diff --git a/contrib/lisp/org-element.el b/contrib/lisp/org-element.el index 73687e8f6..9f9f9da5e 100644 --- a/contrib/lisp/org-element.el +++ b/contrib/lisp/org-element.el @@ -3038,10 +3038,12 @@ Nil values returned from FUN are ignored in the result." ;; included file becomes a direct child of ;; the current headline in the buffer. :headline-offset - ,(- (+ (plist-get - (plist-get --local :inherited-properties) - :level) - (or (plist-get --local :headline-offset) 0)) + ,(- (let ((parent + (org-export-get-parent-headline + --blob --local))) + (if (not parent) 0 + (org-export-get-relative-level + parent --local))) (1- (org-export-get-min-level --data --local)))))))) ;; Limiting recursion to greater elements, and --BLOB diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 9483472a9..974ec60e1 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2267,17 +2267,17 @@ Return the transcoded string." data backend (org-combine-plists info - ;; Store full path of already included files to avoid - ;; recursive file inclusion. + ;; Store full path of already included files to avoid recursive + ;; file inclusion. `(:included-files ,(cons (expand-file-name file) (plist-get info :included-files)) - ;; Ensure that a top-level headline in the included - ;; file becomes a direct child of the current headline - ;; in the buffer. + ;; Ensure that a top-level headline in the included file + ;; becomes a direct child of the current headline in the + ;; buffer. :headline-offset - ,(- (+ (org-element-get-property - :level (org-export-get-parent-headline keyword info)) - (plist-get info :headline-offset)) + ,(- (let ((parent (org-export-get-parent-headline keyword info))) + (if (not parent) 0 + (org-export-get-relative-level parent info))) (1- (org-export-get-min-level data info))))))))) (defun org-export-get-file-contents (file &optional lines)