Skip to content

Commit

Permalink
- applying :kindly/options in all hiccup-based pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Sep 10, 2024
1 parent 5487c5d commit 845bcfa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. This change
- bugfix in handling options in notebook generation
- bugfix: handling the edge case of string hiccup carefully
- bugfix: handling `:kind/hidden` correctly in notebook generation
- applying `:kindly/options` in all hiccup-based pathways

## [2-beta15] - 2024-07-27
- introducing code-and-value and horizontal layout - WIP (PR #127)
Expand Down
30 changes: 18 additions & 12 deletions src/scicloj/clay/v2/prepare.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
[clojure.walk]
[hiccup.core :as hiccup]
[charred.api :as charred]
[scicloj.clay.v2.util.merge :as merge]))
[scicloj.clay.v2.util.merge :as merge]
[scicloj.kindly.v4.kind :as kind]))

(def *kind->preparer
(atom {}))
Expand Down Expand Up @@ -70,13 +71,19 @@
(md/->hiccup mdctx md))


(defn complete-hiccup [hiccup {:as item
:keys [item-class script]}]
(-> hiccup
(add-class-to-hiccup item-class)
(merge-attrs (some-> (:kindly/options item)
(select-keys [:style :class])))
(cond-> script
(conj script))))

(defn item->hiccup [{:as note
(defn item->hiccup [{:as item
:keys [hiccup html md
script
item-class
inside-a-table]}
{:as context
{:as clay-options
:keys [format kind]}]
(-> (or hiccup
(some->> html
Expand All @@ -97,24 +104,23 @@
second
item/katex-hiccup)
form)))))))
(add-class-to-hiccup item-class)
(merge-attrs (some-> (:kindly/options note) (select-keys [:style :class])))
(cond-> script
(conj script))))
(complete-hiccup item)))

(defn item->md [{:as context
(defn item->md [{:as item
:keys [hiccup html md
script
item-class]}]
(-> (if script
(-> context
(-> item
(dissoc :script)
(update :hiccup conj script)
item->md)
(-> (or md
(format "\n```{=html}\n%s\n```\n"
(or html
(some-> hiccup hiccup/html))))))
(some-> hiccup
(complete-hiccup item)
hiccup/html))))))
(cond-> item-class
(#(format "::: {.%s}\n%s\n:::\n" item-class %)))))

Expand Down

0 comments on commit 845bcfa

Please sign in to comment.