Lets
rstMdSGRDefault = toTable([("singlestar", "italic ; -italic"), ("doublestar", "bold ; -bold"), ("triplestar", "bold italic ; -bold -italic"), ("singlebquo", "underline ; -underline"), ("doublebquo", "inverse ; -inverse")])
Consts
textAttrHelp = "Style: bold italic blink inverse struck under{line double dot dash curl};\nSame w/leading \'-\': turn that off; turn all off: plain(0) NONE none off;\nBasic Color: black red green yellow blue purple cyan white;\nUPPERCASE => HIGH intensity; \"on_\" prefix => BACKGROUND color;\nxterm256: {fbu}(0-23|0-50-50-5) for F)ORE B)ACKgrnd U)NDER (greyLevel|6cube);\nTrue color: {fbu}RRGGBB with RGB hex digits.\n{fbu}sNAME<0.-1>[,..]: element of NAME: viridis hue[,s,v] wLen[,s,v] gray pm3d"
textAttrOff = "\e[m"
Procs
proc cmpN(a, b: string): int {....raises: [], tags: [], forbids: [].}
- Cmp strs w/"to end of string" numeric substrs as nums. Eg., "x.20" >"x.1".
proc humanDuration(dt: int; fmt: string; plain = false): string {. ...raises: [ValueError], tags: [], forbids: [].}
- fmt is divisor-aka-numerical-unit-in-seconds unit-text [attrs]
proc humanReadable4(bytes: uint; binary = false): string {....raises: [], tags: [], forbids: [].}
- A low-precision always <= 4 text columns human readable size formatter. If binary is true use power of 2 units instead of SI/decimal units.
proc initRstMdSGR(attrs = rstMdSGRDefault; plain = false): rstMdSGR {. ...raises: [IOError, KeyError, ValueError], tags: [WriteIOEffect], forbids: [].}
- A hybrid restructuredText-Markdown-to-ANSI SGR/highlighter/renderer that does only inline font markup (single-|double-|triple-)(*|) since A) that is what is most useful for terminal display and B) the whole idea of these markups is to be readable as-is. Backslash escape & spacing work as usual to block adornment interpretation. This proc inits rstMdSGR with a Table of {style: "open;close"} text adornments. plain==true will make the associated render proc merely remove all such adornments.
proc parseInt(s: string; valIfNAN: int): int {....raises: [ValueError], tags: [], forbids: [].}
- A helper function to parse s into an integer, but default to some value when s is not an number at all.
proc specifierHighlight(fmt: string; pctTerm: set[char]; plain = false; pct = '%'; openBkt = "([{"; closeBkt = ")]}"; keepPct = true; termInAttr = true): string {. ...raises: [KeyError, ValueError], tags: [], forbids: [].}
- ".. %X(A1 A2)Ya .." -> ".. ON[A1 A2]%XYaOFF .."
proc textAttrAlias(name, value: string) {....raises: [], tags: [], forbids: [].}
proc textAttrAliasClear() {....raises: [], tags: [], forbids: [].}
proc textAttrOn(spec: seq[string]; plain = false): string {. ...raises: [KeyError, ValueError], tags: [], forbids: [].}
proc textAttrParse(s: string): string {....raises: [KeyError, ValueError], tags: [], forbids: [].}
proc textAttrRegisterAliases(colors: seq[string]) {....raises: [], tags: [], forbids: [].}