Skip to content

Commit

Permalink
fix style to html and rename some functions; tag 0.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Jan 19, 2024
1 parent 5000da5 commit 2c42d39
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
36 changes: 20 additions & 16 deletions calcit.cirru

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions compact.cirru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{} (:package |respo)
:configs $ {} (:init-fn |respo.main/main!) (:reload-fn |respo.main/reload!) (:version |0.16.3)
:configs $ {} (:init-fn |respo.main/main!) (:reload-fn |respo.main/reload!) (:version |0.16.4)
:modules $ [] |memof/ |lilac/ |calcit-test/
:entries $ {}
:files $ {}
Expand Down Expand Up @@ -912,7 +912,7 @@
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo.css $ :require
respo.render.html :refer $ style->string
respo.render.dom :refer $ style->string
|respo.cursor $ %{} :FileEntry
:defs $ {}
|update-states $ %{} :CodeEntry (:doc |)
Expand Down Expand Up @@ -1262,7 +1262,7 @@
&doseq (child-element child-elements)
if (some? child-element) (.!appendChild element child-element)
, element
|style->string $ %{} :CodeEntry (:doc |)
|style->string $ %{} :CodeEntry (:doc "|this functions is used inside DOM operations, inserting styles into a `<style>` element. to render to HTML, use `style->html` instead")
:code $ quote
defn style->string (styles)
apply-args ("\"" styles)
Expand Down Expand Up @@ -1370,7 +1370,7 @@
respo.util.list :refer $ val-of-first
|respo.render.html $ %{} :FileEntry
:defs $ {}
|element->string $ %{} :CodeEntry (:doc |)
|element->string $ %{} :CodeEntry (:doc "|which is actually `element->html`")
:code $ quote
defn element->string (element)
let
Expand All @@ -1385,7 +1385,7 @@
tailored-props $ &let
props $ -> attrs (dissoc :innerHTML) (dissoc :inner-text)
if (empty? styles) props $ assoc props :style styles
props-in-string $ props->string tailored-props
props-in-string $ props->html tailored-props
if (&set:includes? self-closing tag-name)
str |< tag-name
if (blank? props-in-string) | "| "
Expand All @@ -1401,9 +1401,9 @@
, props-in-string |>
either text-inside $ join-str children |
, |</ tag-name |>
|entry->string $ %{} :CodeEntry (:doc |)
|entry->html $ %{} :CodeEntry (:doc |)
:code $ quote
defn entry->string (entry)
defn entry->html (entry)
let
k $ first entry
v $ last entry
Expand All @@ -1412,7 +1412,7 @@
, |= $ .escape
cond
= k :style
style->string v
style->html v
(bool? v) (str v)
(number? v) (str v)
(tag? v) (turn-string v)
Expand All @@ -1426,24 +1426,25 @@
:code $ quote
defn make-string (element)
element->string $ purify-element (mute-element element)
|props->string $ %{} :CodeEntry (:doc |)
|props->html $ %{} :CodeEntry (:doc |)
:code $ quote
defn props->string (props)
defn props->html (props)
-> props (.to-list)
filter $ fn (pair)
let
k $ first pair
v $ last pair
and (some? v)
not $ starts-with? (turn-string k) |on-
map entry->string
.sort-by first
map entry->html
join-str "| "
|self-closing $ %{} :CodeEntry (:doc |)
:code $ quote
def self-closing $ #{} "\"area" "\"base" "\"br" "\"col" "\"embed" "\"hr" "\"img" "\"input" "\"link" "\"meta" "\"param" "\"source" "\"track" "\"wbr"
|style->string $ %{} :CodeEntry (:doc |)
|style->html $ %{} :CodeEntry (:doc "|this function is intended for HTML rendering since it escaped characters.")
:code $ quote
defn style->string (styles)
defn style->html (styles)
-> styles
map $ fn (entry)
let
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.3",
"version": "0.16.4",
"dependencies": {
"@calcit/procs": "^0.8.16"
},
Expand All @@ -8,6 +8,6 @@
},
"devDependencies": {
"bottom-tip": "^0.1.5",
"vite": "^5.0.11"
"vite": "^5.0.12"
}
}
2 changes: 1 addition & 1 deletion test/examples/quote.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div value="a&quot;b&quot;c" x="y" style="content:d&quot;e&quot;f;"></div>
<div style="content:d&quot;e&quot;f;" value="a&quot;b&quot;c" x="y"></div>
2 changes: 1 addition & 1 deletion test/examples/simple.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<html><head><title>Demo</title><link type="image/png" rel="icon" ><script>{}</script></head><body><div id="app"><div></div></div></body></html>
<html><head><title>Demo</title><link rel="icon" type="image/png" ><script>{}</script></head><body><div id="app"><div></div></div></body></html>
8 changes: 4 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c42d39

Please sign in to comment.