Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting code cell & result visibility
You can control visibility in Clerk by setting the `:nextjournal.clerk/visibility` which takes a keyword or a set of keywords. Valid values are: * `:show` (the default) * `:fold` displays the cells collapsed and allows to uncollapse the, * `:hide` completely hides the code cells A declartion on the `ns` form let's all code cells in the notebook inherit the value. On the `ns` form you can also use `:fold-ns` or `:hide-ns` if you'd like an option to only apply to the namespace form. A `ns` form is treated special in that when hidden Clerk will also hide its `nil` result. The `clerk/hide-result` viewer allows you to hide the result of a code cell.
- Loading branch information
Showing
7 changed files
with
178 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
;; # Controlling Visibility 🙈 | ||
;; You can control visibility in Clerk by setting the `:nextjournal.clerk/visibility` which takes a keyword or a set of keywords. Valid values are: | ||
;; * `:show` (the default) | ||
;; * `:hide` to hide the cells w | ||
;; * `:fold` which shows the cells collapsed and lets users uncollapse them | ||
|
||
;; A declartion on the `ns` form let's all code cells in the notebook inherit the value. On the `ns` form you can also use `:fold-ns` or `:hide-ns` if you'd like an option to only apply to the namespace form. | ||
^{:nextjournal.clerk/visibility #{:fold}} | ||
(ns visibility | ||
(:require [clojure.string :as str] | ||
[nextjournal.clerk :as clerk])) | ||
|
||
;; So a cell will only show the result now while you can uncoallpse the code cell. | ||
(+ 39 3) | ||
|
||
;; If you want, you can override it. So the following cell is shown: | ||
^{::clerk/visibility :show} (range 25) | ||
|
||
;; While this one is completely hidden, without the ability to uncollapse it. | ||
^{::clerk/visibility :hide} (shuffle (range 25)) | ||
|
||
;; In the rare case you'd like to hide the result of a cell, use `clerk/hide-result`. | ||
^{::clerk/visibility :show} | ||
(clerk/hide-result (range 500)) | ||
|
||
;; In a follow-up, we'll remove the `::clerk/visibility` metadata from the code cells to not distract from the essence. | ||
|
||
;; Fin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.