No actual progress.

This commit is contained in:
Simon Brooke 2020-02-13 19:46:58 +00:00
parent 40ab296d1a
commit 8032ad60af
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
2 changed files with 15 additions and 33 deletions

View file

@ -175,8 +175,6 @@
(defn process-photoswipe (defn process-photoswipe
[^String url-or-pswp-spec ^Integer index] [^String url-or-pswp-spec ^Integer index]
(log/info "process-photoswipe called with arg1 `"
url-or-pswp-spec "`; arg2 `" index "`.")
(let [data (resource-url-or-data->data url-or-pswp-spec) (let [data (resource-url-or-data->data url-or-pswp-spec)
spec (cs/trim (:data data)) spec (cs/trim (:data data))
result result
@ -184,5 +182,6 @@
(cs/starts-with? spec "![") (cs/starts-with? spec "![")
(process-simple-photoswipe spec index) (process-simple-photoswipe spec index)
(process-full-photoswipe spec index))] (process-full-photoswipe spec index))]
(log/info "process-photoswipe returning `" result "`.") ;; (log/info "process-photoswipe returning `" result "`.")
result
)) ))

View file

@ -63,32 +63,9 @@
no-text-error)) no-text-error))
(defn yaml->json
"Rewrite this string, assumed to be in YAML format, as JSON."
[^String yaml-src]
(json/write-str (yaml/parse-string yaml-src)))
(declare process-text) (declare process-text)
(defn process-vega
"Process this `vega-src` string, assumed to be in YAML format, into a specification
of a Vega chart, and add the plumbing to render it."
[^String vega-src ^Integer index]
(str
"<div class='data-visualisation' id='vis" index "'></div>\n"
"<script>\n//<![CDATA[\nvar vl"
index
" = "
(yaml->json (str "$schema: https://vega.github.io/schema/vega-lite/v2.json\n" vega-src))
";\nvegaEmbed('#vis"
index
"', vl"
index
");\n//]]\n</script>"))
(defn process-backticks (defn process-backticks
"Effectively, escape the backticks surrounding this `text`, by protecting them "Effectively, escape the backticks surrounding this `text`, by protecting them
from the `md->html` filter." from the `md->html` filter."
@ -117,7 +94,7 @@
(cons fragment processed))) (cons fragment processed)))
(defn- apply-formatter (defn apply-formatter
"Within the context of `process-text`, process a fragment for which an explicit "Within the context of `process-text`, process a fragment for which an explicit
§formatter has been identified. §formatter has been identified.
@ -128,11 +105,14 @@
[index result fragments processed fragment token formatter] [index result fragments processed fragment token formatter]
(let (let
[kw (keyword (str "inclusion-" index))] [kw (keyword (str "inclusion-" index))]
(assoc-in
(process-text (process-text
(inc index) (inc index)
(assoc-in result [:inclusions kw] (apply formatter (list (subs fragment (count token)) index))) result
(rest fragments) (rest fragments)
(cons kw processed)))) (cons kw processed))
[:inclusions kw]
(apply formatter (list (subs fragment (count token)) index)))))
(defn process-text (defn process-text
@ -182,8 +162,11 @@
fragment fragment
first-token first-token
formatter)] formatter)]
;; TODO: consistency: either these things are `extensions`, or
;; they're `formatters`. I incline to the view that they're
;; `:extensions`
(assoc-in result [:extensions kw] (-> config :formatters kw))) (assoc-in result [:extensions kw] (-> config :formatters kw)))
true :else
;; Otherwise process the current fragment as markdown and recurse on ;; Otherwise process the current fragment as markdown and recurse on
;; down the list ;; down the list
(process-markdown-fragment (process-markdown-fragment