Commit 9cb5e048a0

9cb5e048a0e70a986be15162bcd4f49f71836582

parent: 91703eee0a

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-09 02:33 UTC

Let the nearest heading's header-args win

ancestors(of:) is outermost first, so reversing it applied the outermost heading's header-args last.

Layout: unified · split

Changed files (2)
Sources/OrgCore/Compute/Babel.swift +1 −1 · view
@@ -1022,7 +1022,7 @@ public enum Babel {
10221022 static func propertyLayers(language: String, heading: Int?, model: DocumentModel) -> [[(String, String)]] {
10231023 var levels = [model.fileProperties]
10241024 if let heading {
1025 levels += (model.ancestors(of: heading).reversed() + [heading]).map { model.headings[$0].properties }
1025 levels += (model.ancestors(of: heading) + [heading]).map { model.headings[$0].properties }
10261026 }
10271027 return ["header-args", "header-args:\(language)"].compactMap { key in
10281028 var value: String?
Tests/OrgCoreTests/BabelTests.swift +2 · view
@@ -201,6 +201,8 @@ struct BabelTests {
201201 "#+begin_src sh :dir (concat \"/\" \"usr\") :results output\npwd\n#+end_src\n",
202202 "#+begin_src sh :dir /tmp :results output\npwd\n#+end_src\n",
203203 "#+NAME: items\n- one\n- two\n\n#+begin_src shell :var l=items :results output\necho \"$l\"\n#+end_src\n",
204 // The nearest heading's header-args win.
205 "* A\n:PROPERTIES:\n:header-args: :var x=1\n:END:\n** B\n:PROPERTIES:\n:header-args: :var x=2\n:END:\n*** C\n#+begin_src sh\necho $x\n#+end_src\n",
204206 // Lisp values.
205207 "#+begin_src python :var l='(1 2) m='((1 2) (3 4)) n=(+ 1 2) s='(\"a\" \"b\")\nreturn [l, m, n, s]\n#+end_src\n",
206208 "#+begin_src emacs-lisp :var l='(1 2) h='((1 2) hline (3 4)) s=(concat \"a\" \"b\")\n(list l h s)\n#+end_src\n",
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form