      " " [:fo:leader {:leader-pattern "dots" :role "NonStruct"}] " "
      [:fo:page-number-citation {:ref-id (hash path) :role "Reference"}]]
     (when (and (map? items) (< current-depth depth))
-      (keep #(toc-entry (% items) (conj path %) depth (inc current-depth)) (order (keys items))))]))
+      (map #(toc-entry (% items) (conj path %) depth (inc current-depth)) (order (keys items))))]))
 
 (defn- add-extra-headings [entries editorial? recommendation-at-end? single-recommendation?]
   (let [recommendation (if single-recommendation? :recommendation :recommendations)]

  (keyword (str "h" level)))

(defn subgenre-sexp [items fmt genre subgenre level]
  (when-let [items (subgenre items)]
    [(heading (level-to-h level) subgenre [fmt genre subgenre])
     (when-not (#{:kinder-und-jugendbücher} genre)
       (set-marker (layout/translations subgenre)))
     (entries-sexp items)]))

(defn subgenres-sexp [items fmt genre level]
  (mapcat #(subgenre-sexp items fmt genre % level) (order (keys items))))

(defn genre-sexp [items fmt genre level]
  (when-let [items (genre items)]
    [(heading (level-to-h level) genre [fmt genre])
     (set-marker (layout/translations genre))
     (cond
       (#{:kinder-und-jugendbücher} genre) (subgenres-sexp items fmt genre (inc level))
       (#{:hörbuch} fmt) (subgenres-sexp items fmt genre (inc level))
       :else (entries-sexp items))]))

(defn format-sexp [items fmt level]
  (when-let [items (fmt items)]
    [(heading (level-to-h level) fmt [fmt])
     (toc items [fmt] 2)
     (set-marker (layout/translations fmt))
     (case fmt
       (:hörfilm :ludo) (entries-sexp items)
       (mapcat #(genre-sexp items fmt % (inc level)) (order (keys items))))]))

(defn- page-number []
  [:fo:inline

     (when heading? (heading :h1 :inhalt []))
     (let [entries (-> items keys order
                    (add-extra-headings editorial? recommendation-at-end? single-recommendation?))]
       (map #(toc-entry (get items %) (conj path %) depth) entries))]))

(defn- to-url
  "Return an url given a `record-id`"
