Manipulate HTML nesting depth using `*html-path*`
masterThe variable *html-path* is the underlying storage for get-html-path. You can use let to bind *html-path* to a new list to manually simulate or preserve HTML nesting depth when splitting document generation across multiple functions.
WARNING: Spinneret binds *html-path* with dynamic extent. If you need to inspect or store the path value safely, use get-html-path instead of accessing the variable directly.
Example of preserving structure in sub-functions:
(defun inner-section ()
"""Binds *HTML-PATH* to replicate the depth the output is used in."""
(with-html-string
(let ((*html-path* (append *html-path* '(:section :section))))
(:h* "Heading three levels deep"))))
(defun outer-section (html)
"""Uses HTML from elsewhere and embed it into a section"""
(with-html-string
(:section
(:h* "Heading two levels deep")
(:section
(:raw html)))))
(outer-section (inner-section))
;; <section>
;; <h2>Heading two levels deep</h2>
;; <section><h3>Heading three levels deep</h3>
;; </section>
;;</section>(let ((*html-path* (append *html-path* '(:section :section))))
(:h* "Heading three levels deep"))