https://github.com/bobbicodes/instacode
Clojure notebook generator with KaTeX and KLIPSE
https://github.com/bobbicodes/instacode
Last synced: 9 months ago
JSON representation
Clojure notebook generator with KaTeX and KLIPSE
- Host: GitHub
- URL: https://github.com/bobbicodes/instacode
- Owner: bobbicodes
- License: epl-2.0
- Created: 2019-05-02T05:58:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-29T00:23:13.000Z (almost 5 years ago)
- Last Synced: 2025-06-04T10:10:37.547Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://porkostomus.github.io/instacode/
- Size: 766 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Instacode
Clojure notebook generator with [KaTeX](https://github.com/KaTeX/KaTeX) and [KLIPSE](https://github.com/viebel/klipse)
## Generate static content from the REPL
The `nb` function takes 2 strings, a text block which may include KaTeX formulas (inline or display style), and an interactive code block. Slashes (`\`), quotes (`"`), etc. must be escaped when used from the REPL.
The page [here](https://porkostomus.github.io/instacode/) was generated from the REPL like this:
```
~/instacode$ lein repl
instacode.core=> (nb "$$\\huge{\\pink{x}=\\dfrac{-\\blue{b}\\pm\\sqrt{\\blue{b}\\purple{^2}-4\\red{a}\\orange{c}}}{2\\red{a}}}$$" "(defn prime-factors
([n] (prime-factors 2 n))
([f n]
(if (= n 1)
(if (zero? (mod n f))
(cons f (prime-factors f (/ n f)))
(recur (inc f) n)))))
(defn perfect-squares [s]
(loop [items (sort s) pairs []]
(if (empty? items) pairs
(if (= (first items) (second items))
(recur (drop 2 items) (conj pairs (first items)))
(recur (rest items) pairs)))))
(defn simplify-sqrt [sqrt]
(let [sq (reduce * (perfect-squares (prime-factors sqrt)))]
[sq (/ sqrt (* sq sq))]))
(defn quadratic-rational [[a b c]]
(let [discriminant (simplify-sqrt (- (* b b) (* 4 a c)))]
[(/ (- b) (first discriminant))
(last discriminant) (/ (* 2 a) (first discriminant))]))
(quadratic-rational [3 24 48])")
```

## Start a web server
```
~/instacode$ lein run
```
