 (defn- set-marker [title]
   [:fo:block {:keep-with-next "always"}
    [:fo:marker {:marker-class-name running-header-class-name} title]])
+
+(defn- add-number [coll number]
+  (when (not-empty coll)
+    (conj coll (inc number))))
 
 (defn- order
   "Return `items` ordered. Checks first if `items` are either a subset

      editorial? (concat [:editorial recommendation] entries)
      :else entries)))

(defn toc [items path depth & {:keys [heading? editorial? recommendation-at-end? single-recommendation?]}]
  (when (map? items)
    [:fo:block {:line-height "150%"
                :role "TOC"}
     (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`"


    (let [subitems (get items fmt)]
      [:fo:flow {:flow-name "xsl-region-body"}
       (toc (select-keys items [fmt]) [] 3
            :heading? true :editorial? true :recommendation-at-end? true :numbered? true)
       (block {:break-before "odd-page"}) ;; the very first format should start on recto
       (heading :h1 :editorial [:editorial] [1])
       (heading :h1 :hörbuch [:hörbuch] [2])
       (letfn [(numbered-genre [number genre]
                 (genre-sexp (get subitems genre) fmt genre 2 (add-number [2] number)))]
         (apply concat (map-indexed #(numbered-genre %1 %2) (order (keys subitems)))))
       (heading :h1 :recommendations [:recommendations] [3])])]])

(defmethod document-sexp :all-formats
  [items _ {:keys [description date]}]
