Converts ANSI SGR-styled strings to browser dev console format: a string with a %c format specifier in place of each SGR sequence, followed by one CSS string per %c. Used by sugar.core/print-styled in browsers.
Converts ANSI SGR-styled strings to browser dev console format: a string with a %c format specifier in place of each SGR sequence, followed by one CSS string per %c. Used by sugar.core/print-styled in browsers.
(adjusted-char-count s)Given a string containing ANSI SGR tags, returns the character count of the string minus the char count of all the ANSI SGR tags.
Given a string containing ANSI SGR tags, returns the character count of the string minus the char count of all the ANSI SGR tags.
(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", after escaping every % in the text as %%. 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.4; 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", after escaping every % in the text as %%. 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.4; color: default"]
;; Print the value, with formatting, to dev console:
(.apply js/console.log js/console console-array)
```
(sgr-count s)Given a string containing ANSI SGR tags, returns the character count of the ANSI SGR tags. 0 when there are none, or s is nil.
Given a string containing ANSI SGR tags, returns the character count of the ANSI SGR tags. 0 when there are none, or s is nil.
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 |