fix: use win32 specific method to detect absolute path

This commit is contained in:
thezjy
2021-05-14 19:19:13 +08:00
parent 3ab36705cc
commit b87da8a7f4

View File

@@ -140,7 +140,7 @@
parts-2 (string/split path #"/")
current-dir (string/join "/" (drop-last 1 parts))]
(cond
(util/starts-with? path "/")
(if util/win32? (utils/win32 path) (util/starts-with? path "/"))
path
(and (not (util/starts-with? path ".."))
@@ -1810,7 +1810,7 @@
(->elem
:li
(cond->
{:checked checked?}
{:checked checked?}
number
(assoc :value number))
(vec-cat
@@ -2044,168 +2044,168 @@
(let [format (or (:block/format config)
:markdown)]
(try
(match item
["Properties" m]
[:div.properties
(for [[k v] (dissoc m :roam_alias :roam_tags)]
(when (and (not (and (= k :macros) (empty? v))) ; empty macros
(not (= k :title))
(not (= k :filters)))
[:div.property
[:span.font-medium.mr-1 (str (name k) ": ")]
(if (coll? v)
(let [vals (for [item v]
(if (coll? v)
(let [config (if (= k :alias)
(assoc config :block/alias? true))]
(page-cp config {:block/name item}))
(inline-text format item)))]
(interpose [:span ", "] vals))
(inline-text format v))]))]
(match item
["Properties" m]
[:div.properties
(for [[k v] (dissoc m :roam_alias :roam_tags)]
(when (and (not (and (= k :macros) (empty? v))) ; empty macros
(not (= k :title))
(not (= k :filters)))
[:div.property
[:span.font-medium.mr-1 (str (name k) ": ")]
(if (coll? v)
(let [vals (for [item v]
(if (coll? v)
(let [config (if (= k :alias)
(assoc config :block/alias? true))]
(page-cp config {:block/name item}))
(inline-text format item)))]
(interpose [:span ", "] vals))
(inline-text format v))]))]
["Paragraph" l]
["Paragraph" l]
;; TODO: speedup
(if (re-find #"\"Export_Snippet\" \"embed\"" (str l))
(->elem :div (map-inline config l))
(->elem :div.is-paragraph (map-inline config l)))
(if (re-find #"\"Export_Snippet\" \"embed\"" (str l))
(->elem :div (map-inline config l))
(->elem :div.is-paragraph (map-inline config l)))
["Horizontal_Rule"]
(when-not (:slide? config)
[:hr])
["Heading" h]
(block-container config h)
["List" l]
(let [lists (divide-lists l)]
(if (= 1 (count lists))
(let [l (first lists)]
(->elem
(list-element l)
(map #(list-item config %) l)))
[:div.list-group
(for [l lists]
["Horizontal_Rule"]
(when-not (:slide? config)
[:hr])
["Heading" h]
(block-container config h)
["List" l]
(let [lists (divide-lists l)]
(if (= 1 (count lists))
(let [l (first lists)]
(->elem
(list-element l)
(map #(list-item config %) l)))]))
["Table" t]
(table config t)
["Math" s]
(if html-export?
(latex/html-export s true true)
(latex/latex (str (dc/squuid)) s true true))
["Example" l]
[:pre.pre-wrap-white-space
(join-lines l)]
["Quote" l]
(->elem
:blockquote
(markup-elements-cp config l))
["Raw_Html" content]
(when (not html-export?)
[:div.raw_html {:dangerouslySetInnerHTML
{:__html content}}])
["Export" "html" options content]
(when (not html-export?)
[:div.export_html {:dangerouslySetInnerHTML
{:__html content}}])
["Hiccup" content]
(ui/catch-error
[:div.warning {:title "Invalid hiccup"}
content]
(-> (safe-read-string content)
(security/remove-javascript-links-in-href)))
(map #(list-item config %) l)))
[:div.list-group
(for [l lists]
(->elem
(list-element l)
(map #(list-item config %) l)))]))
["Table" t]
(table config t)
["Math" s]
(if html-export?
(latex/html-export s true true)
(latex/latex (str (dc/squuid)) s true true))
["Example" l]
[:pre.pre-wrap-white-space
(join-lines l)]
["Quote" l]
(->elem
:blockquote
(markup-elements-cp config l))
["Raw_Html" content]
(when (not html-export?)
[:div.raw_html {:dangerouslySetInnerHTML
{:__html content}}])
["Export" "html" options content]
(when (not html-export?)
[:div.export_html {:dangerouslySetInnerHTML
{:__html content}}])
["Hiccup" content]
(ui/catch-error
[:div.warning {:title "Invalid hiccup"}
content]
(-> (safe-read-string content)
(security/remove-javascript-links-in-href)))
["Export" "latex" options content]
(if html-export?
(latex/html-export content true false)
(latex/latex (str (dc/squuid)) content true false))
["Export" "latex" options content]
(if html-export?
(latex/html-export content true false)
(latex/latex (str (dc/squuid)) content true false))
["Custom" "query" _options result content]
(try
(let [query (reader/read-string content)]
(custom-query config query))
(catch js/Error e
(println "read-string error:")
(js/console.error e)
[:div.warning {:title "Invalid query"}
content]))
["Custom" "query" _options result content]
(try
(let [query (reader/read-string content)]
(custom-query config query))
(catch js/Error e
(println "read-string error:")
(js/console.error e)
[:div.warning {:title "Invalid query"}
content]))
["Custom" "note" options result content]
(admonition config "note" options result)
["Custom" "note" options result content]
(admonition config "note" options result)
["Custom" "tip" options result content]
(admonition config "tip" options result)
["Custom" "tip" options result content]
(admonition config "tip" options result)
["Custom" "important" options result content]
(admonition config "important" options result)
["Custom" "important" options result content]
(admonition config "important" options result)
["Custom" "caution" options result content]
(admonition config "caution" options result)
["Custom" "caution" options result content]
(admonition config "caution" options result)
["Custom" "warning" options result content]
(admonition config "warning" options result)
["Custom" "warning" options result content]
(admonition config "warning" options result)
["Custom" "pinned" options result content]
(admonition config "pinned" options result)
["Custom" "pinned" options result content]
(admonition config "pinned" options result)
["Custom" name options l content]
(->elem
:div
{:class name}
(markup-elements-cp config l))
["Custom" name options l content]
(->elem
:div
{:class name}
(markup-elements-cp config l))
["Latex_Fragment" l]
[:p.latex-fragment
(inline config ["Latex_Fragment" l])]
["Latex_Fragment" l]
[:p.latex-fragment
(inline config ["Latex_Fragment" l])]
["Latex_Environment" name option content]
(let [content (latex-environment-content name option content)]
(if html-export?
(latex/html-export content true true)
(latex/latex (str (dc/squuid)) content true true)))
["Latex_Environment" name option content]
(let [content (latex-environment-content name option content)]
(if html-export?
(latex/html-export content true true)
(latex/latex (str (dc/squuid)) content true true)))
["Displayed_Math" content]
(if html-export?
(latex/html-export content true true)
(latex/latex (str (dc/squuid)) content true true))
["Displayed_Math" content]
(if html-export?
(latex/html-export content true true)
(latex/latex (str (dc/squuid)) content true true))
["Footnote_Definition" name definition]
(let [id (util/url-encode name)]
[:div.footdef
[:div.footpara
(conj
(markup-element-cp config ["Paragraph" definition])
[:a.ml-1 {:id (str "fn." id)
:style {:font-size 14}
:class "footnum"
:on-click #(route-handler/jump-to-anchor! (str "fnr." id))}
[:sup.fn (str name "↩︎")]])]])
["Footnote_Definition" name definition]
(let [id (util/url-encode name)]
[:div.footdef
[:div.footpara
(conj
(markup-element-cp config ["Paragraph" definition])
[:a.ml-1 {:id (str "fn." id)
:style {:font-size 14}
:class "footnum"
:on-click #(route-handler/jump-to-anchor! (str "fnr." id))}
[:sup.fn (str name "↩︎")]])]])
["Src" options]
(when options
(let [{:keys [language options lines pos_meta]} options
attr (if language
{:data-lang language})
code (join-lines lines)]
(cond
html-export?
(highlight/html-export attr code)
["Src" options]
(when options
(let [{:keys [language options lines pos_meta]} options
attr (if language
{:data-lang language})
code (join-lines lines)]
(cond
html-export?
(highlight/html-export attr code)
:else
(let [language (if (contains? #{"edn" "clj" "cljc" "cljs" "clojure"} language) "text/x-clojure" language)]
(highlight/highlight (str (medley/random-uuid)) {:data-lang language} code)
:else
(let [language (if (contains? #{"edn" "clj" "cljc" "cljs" "clojure"} language) "text/x-clojure" language)]
(highlight/highlight (str (medley/random-uuid)) {:data-lang language} code)
;; (if (:slide? config)
;; (highlight/highlight (str (medley/random-uuid)) {:data-lang language} code)
;; [:div
;; (lazy-editor/editor config (str (dc/squuid)) attr code pos_meta)
;; (when (and (= language "text/x-clojure") (contains? (set options) ":results"))
;; (sci/eval-result code))])
))))
))))
:else
"")
(catch js/Error e
(println "Convert to html failed, error: " e)
""))))
:else
"")
(catch js/Error e
(println "Convert to html failed, error: " e)
""))))
(defn markup-elements-cp
[config col]