Compare commits
7 Commits
fix-tikz-s
...
d0840233c9
| Author | SHA1 | Date | |
|---|---|---|---|
| d0840233c9 | |||
| 86db8d0fe2 | |||
| 2198b5f409 | |||
| bc5138086d | |||
| 6d1d94194b | |||
| fd9322740d | |||
| e5b47898a5 |
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
const { parse } = require ("uniorg-parse/lib/parser.js");
|
const { parse } = require ("uniorg-parse/lib/parser.js");
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
trackPosition: true
|
||||||
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const chunks = []
|
const chunks = []
|
||||||
for await (const chunk of process.stdin) {
|
for await (const chunk of process.stdin) {
|
||||||
chunks.push (chunk)
|
chunks.push (chunk)
|
||||||
}
|
}
|
||||||
const orgText = Buffer.concat (chunks).toString ("utf8")
|
const orgText = Buffer.concat (chunks).toString ("utf8")
|
||||||
process.stdout.write (JSON.stringify (parse (orgText)))
|
process.stdout.write (JSON.stringify (parse (orgText, opts)))
|
||||||
}
|
}
|
||||||
|
|
||||||
main ()
|
main ()
|
||||||
|
|||||||
@@ -48,6 +48,12 @@
|
|||||||
\newcommand{\optic}[3]{\opticname{#1}^\prime\;#2\;#3}
|
\newcommand{\optic}[3]{\opticname{#1}^\prime\;#2\;#3}
|
||||||
\newcommand{\Optic}[5]{\opticname{#1}\;#2\;#3\;#4\;#5}
|
\newcommand{\Optic}[5]{\opticname{#1}\;#2\;#3\;#4\;#5}
|
||||||
|
|
||||||
|
% Default uses arrow glyphs from the active font, which are kinda ugly in the
|
||||||
|
% case of Plex.
|
||||||
|
\tikzcdset{
|
||||||
|
arrow style=tikz
|
||||||
|
}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\setlength\abovedisplayskip{0pt} % Remove padding before equation environments.
|
\setlength\abovedisplayskip{0pt} % Remove padding before equation environments.
|
||||||
%% \color[rgb]{0.000,0.000,0.004}\special{dvisvgm:currentcolor on}\setcounter{equation}{0}%
|
%% \color[rgb]{0.000,0.000,0.004}\special{dvisvgm:currentcolor on}\setcounter{equation}{0}%
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ section {
|
|||||||
p,
|
p,
|
||||||
dl,
|
dl,
|
||||||
ol,
|
ol,
|
||||||
|
.latex-fragment,
|
||||||
ul {
|
ul {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
line-height: 1.5rem;
|
line-height: 1.5rem;
|
||||||
|
|||||||
@@ -208,3 +208,36 @@
|
|||||||
:children first-section-nodes})
|
:children first-section-nodes})
|
||||||
rest)]
|
rest)]
|
||||||
(assoc node :children new-children)))
|
(assoc node :children new-children)))
|
||||||
|
|
||||||
|
(defn- neighbourly-mapcat [coll f]
|
||||||
|
(let [rest-coll (rest coll)]
|
||||||
|
(map f
|
||||||
|
coll
|
||||||
|
rest-coll
|
||||||
|
(concat (rest rest-coll) [nil]))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(-> [1 2 3 4]
|
||||||
|
(neighbourly-mapcat prn) )
|
||||||
|
(def doc (read-string (slurp some-org-file)))
|
||||||
|
|
||||||
|
(let [r (atom [])
|
||||||
|
blah
|
||||||
|
(sp/transform
|
||||||
|
[postorder-walker
|
||||||
|
(sp/must :children)
|
||||||
|
(sp/collect-one sp/VAL)
|
||||||
|
sp/INDEXED-VALS
|
||||||
|
#_
|
||||||
|
#(of-type? (second %) "latex-environment")
|
||||||
|
#_
|
||||||
|
sp/ALL
|
||||||
|
#_
|
||||||
|
sp/INDEXED-VALS]
|
||||||
|
(fn [siblings x]
|
||||||
|
x)
|
||||||
|
doc)]
|
||||||
|
@r))
|
||||||
|
|
||||||
|
(defn gather-latex-paragraphs [node]
|
||||||
|
())
|
||||||
|
|||||||
@@ -34,33 +34,24 @@
|
|||||||
;; it doesn't get e.g. TikZ arrows.
|
;; it doesn't get e.g. TikZ arrows.
|
||||||
(str/replace #"stroke=['\"]#000['\"]" "stroke=\"currentColor\"")))
|
(str/replace #"stroke=['\"]#000['\"]" "stroke=\"currentColor\"")))
|
||||||
|
|
||||||
(def ^:dynamic *save-snippets?* false)
|
|
||||||
|
|
||||||
(defn render-snippets [snippet-promises]
|
(defn render-snippets [snippet-promises]
|
||||||
(with-redefs [fs/delete-tree
|
(fs/with-temp-dir [svg-dir {:prefix "doerg-svg-"}]
|
||||||
(fn
|
(let [rendered-snippets
|
||||||
([path]
|
(delay (->> snippet-promises
|
||||||
(l/warnf "refusing to delete %s" path))
|
(map first)
|
||||||
([path opts]
|
(apply native/render svg-dir)))]
|
||||||
(lr/warnf "refusing to delete %s with opts %s"
|
(doseq [[snippet p] snippet-promises]
|
||||||
path opts)))]
|
(try (let [temml (temml/render snippet)]
|
||||||
(fs/with-temp-dir [svg-dir {:prefix "doerg-svg-"}]
|
(->> (if (temml/erroneous-output? temml)
|
||||||
(let [rendered-snippets
|
(let [tex (get @rendered-snippets snippet)]
|
||||||
(delay (->> snippet-promises
|
(if (:errors tex)
|
||||||
(map first)
|
temml
|
||||||
(apply native/render svg-dir)))]
|
(read-and-patch-generated-svg tex)))
|
||||||
(doseq [[snippet p] snippet-promises]
|
temml)
|
||||||
(try (let [temml (temml/render snippet)]
|
hiccup/raw (deliver p)))
|
||||||
(->> (if (temml/erroneous-output? temml)
|
(catch Exception e
|
||||||
(let [tex (get @rendered-snippets snippet)]
|
(l/error e "Error in TeX thread")
|
||||||
(if (:errors tex)
|
(throw e)))))))
|
||||||
temml
|
|
||||||
(read-and-patch-generated-svg tex)))
|
|
||||||
temml)
|
|
||||||
hiccup/raw (deliver p)))
|
|
||||||
(catch Exception e
|
|
||||||
(l/error e "Error in TeX thread")
|
|
||||||
(throw e))))))))
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(let [snippets (for [x ["\\(\\ifxetex blah \\fi\\)"
|
(let [snippets (for [x ["\\(\\ifxetex blah \\fi\\)"
|
||||||
|
|||||||
Reference in New Issue
Block a user