Skip to content

Commit 500a79a

Browse files
committed
add Character/isISOControl
1 parent 11e9e92 commit 500a79a

File tree

4 files changed

+186
-178
lines changed

4 files changed

+186
-178
lines changed

shadow-cljs.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
{:target :esm
77
:output-dir "public/js"
88
:modules {:sci {:exports {evalString lang-clojure-eval.main/eval-string
9-
context lang-clojure-eval.main/context}}}}}}
9+
context lang-clojure-eval.main/context
10+
isISOControl lang-clojure-eval.character/isISOControl}}}}}}

src/lang_clojure_eval/character.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(ns lang-clojure-eval.character)
2+
3+
(defn isISOControl [char]
4+
(boolean (re-seq #"[\u0000-\u001F\u007F-\u009F]" char)))

src/lang_clojure_eval/main.cljs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns lang-clojure-eval.main
22
(:require [sci.core :as sci]
33
[lang-clojure-eval.error :refer [error-handler]]
4+
[lang-clojure-eval.character :refer [isISOControl]]
45
[goog.string]
56
[goog.string.format]
67
[clojure.pprint :as pprint]
@@ -9,10 +10,12 @@
910
(defonce context
1011
(sci/init {:classes {'js goog/global
1112
:allow :all}
12-
:namespaces {'clojure.core {'format goog.string/format}}}))
13+
:namespaces {'clojure.core {'format goog.string/format}
14+
'lang-clojure-eval.character {'isISOControl isISOControl}}}))
1315

1416
(defn eval-string [source]
15-
(try (binding [*print-length* 100]
16-
(with-out-str (pprint/pprint (sci/eval-string* context source))))
17-
(catch :default e
18-
(with-out-str (error-handler source e)))))
17+
(let [reqs "(require '[lang-clojure-eval.character :as Character])"]
18+
(try (binding [*print-length* 100]
19+
(with-out-str (pprint/pprint (sci/eval-string* context (str reqs source)))))
20+
(catch :default e
21+
(with-out-str (error-handler source e))))))

0 commit comments

Comments
 (0)