Skip to content

Commit

Permalink
No actual progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-brooke committed Feb 13, 2020
1 parent 40ab296 commit 8032ad6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/smeagol/extensions/photoswipe.clj
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,13 @@

(defn process-photoswipe
[^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)
spec (cs/trim (:data data))
result
(if
(cs/starts-with? spec "![")
(process-simple-photoswipe spec index)
(process-full-photoswipe spec index))]
(log/info "process-photoswipe returning `" result "`.")
;; (log/info "process-photoswipe returning `" result "`.")
result
))
43 changes: 13 additions & 30 deletions src/smeagol/formatting.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,9 @@
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)


(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
"Effectively, escape the backticks surrounding this `text`, by protecting them
from the `md->html` filter."
Expand Down Expand Up @@ -117,7 +94,7 @@
(cons fragment processed)))


(defn- apply-formatter
(defn apply-formatter
"Within the context of `process-text`, process a fragment for which an explicit
§formatter has been identified.
Expand All @@ -128,11 +105,14 @@
[index result fragments processed fragment token formatter]
(let
[kw (keyword (str "inclusion-" index))]
(process-text
(inc index)
(assoc-in result [:inclusions kw] (apply formatter (list (subs fragment (count token)) index)))
(rest fragments)
(cons kw processed))))
(assoc-in
(process-text
(inc index)
result
(rest fragments)
(cons kw processed))
[:inclusions kw]
(apply formatter (list (subs fragment (count token)) index)))))


(defn process-text
Expand Down Expand Up @@ -182,8 +162,11 @@
fragment
first-token
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)))
true
:else
;; Otherwise process the current fragment as markdown and recurse on
;; down the list
(process-markdown-fragment
Expand Down

0 comments on commit 8032ad6

Please sign in to comment.