(ansi-sgr-string->browser-dev-console-array s)Intended to convert an ANSI SGR-tagged string to a format specifier-tagged string, with a corresponding vector of css style strings. The resulting string and styles can be supplied to a browser development console to format messages. See https://developer.chrome.com/docs/devtools/console/format-style for more background.
Replaces all ANSI SGR tags in supplied string with CSS format specifier tag, "%c". Analyzes all ANSI SGR tags, and produces a vector of corresponding css style strings. Returns a vector of the format-specifier-tagged strings, followed by the contents of the styles array. In ClojureScript, returns an array.
Example usage in ClojureScript:
(def console-array
(->> :foo
bling.hifi/hifi
ansi-sgr-string->browser-dev-console-array))
;; =>
;; ["%c:foo%c",
;; "color: rgb(122, 62, 157)",
;; "line-height: 1.45; color: default"]
;; Print the value, with formatting, to dev console:
(.apply js/console.log js/console console-array)
Intended to convert an ANSI SGR-tagged string to a format specifier-tagged
string, with a corresponding vector of css style strings. The resulting string
and styles can be supplied to a browser development console to format
messages. See https://developer.chrome.com/docs/devtools/console/format-style
for more background.
Replaces all ANSI SGR tags in supplied string with CSS format specifier tag,
"%c". Analyzes all ANSI SGR tags, and produces a vector of corresponding
css style strings. Returns a vector of the format-specifier-tagged strings,
followed by the contents of the styles array. In ClojureScript, returns an
array.
Example usage in ClojureScript:
```Clojure
(def console-array
(->> :foo
bling.hifi/hifi
ansi-sgr-string->browser-dev-console-array))
;; =>
;; ["%c:foo%c",
;; "color: rgb(122, 62, 157)",
;; "line-height: 1.45; color: default"]
;; Print the value, with formatting, to dev console:
(.apply js/console.log js/console console-array)
```
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |