Liking cljdoc? Tell your friends :D

com.blockether.svar.internal.codes

Fenced code-block extraction from raw LLM text responses.

Pure parsing. No HTTP, no provider knowledge. Used by ask-code! to turn a plain-text completion ((defn …) wrapped in ```clojure fences) into a single concatenated source string ready for the caller to read/eval.

Lenient+ rules — handles the three shapes models produce in practice:

  1. Tagged fence: clojure\n…\n
  2. Untagged fence: \n…\n
  3. No fence at all: entire response treated as one untagged block.

Multiple fences are concatenated (joined with a blank line) so the model can split a response across narration + multiple code blobs and the caller still receives one source string.

Fenced code-block extraction from raw LLM text responses.

Pure parsing. No HTTP, no provider knowledge. Used by `ask-code!` to turn
a plain-text completion (`(defn …) wrapped in ```clojure fences`) into a
single concatenated source string ready for the caller to read/eval.

Lenient+ rules — handles the three shapes models produce in practice:
  1. Tagged fence:        ```clojure\n…\n```
  2. Untagged fence:      ```\n…\n```
  3. No fence at all:     entire response treated as one untagged block.

Multiple fences are concatenated (joined with a blank line) so the model
can split a response across narration + multiple code blobs and the
caller still receives one source string.
raw docstring

concat-sourcesclj

(concat-sources blocks)

Concatenate :source of each block, joined by a blank line.

Concatenate `:source` of each block, joined by a blank line.
sourceraw docstring

extract-code-blocksclj

(extract-code-blocks raw)

Parse fenced code blocks from raw text.

Returns a vector of {:lang <str-or-nil> :source <str>}. :lang is the tag after the opening ``` (lower-cased), or nil for untagged fences. :source is the body verbatim (newlines preserved; no trim applied to internal whitespace).

Lenient+ fallback: when raw contains NO fenced block at all, returns one block {:lang nil :source <trimmed-raw>}. Empty / blank input returns [].

Parse fenced code blocks from `raw` text.

Returns a vector of `{:lang <str-or-nil> :source <str>}`. `:lang` is the
tag after the opening ``` (lower-cased), or `nil` for untagged fences.
`:source` is the body verbatim (newlines preserved; no trim applied to
internal whitespace).

Lenient+ fallback: when `raw` contains NO fenced block at all, returns
one block `{:lang nil :source <trimmed-raw>}`. Empty / blank input
returns `[]`.
sourceraw docstring

select-blocksclj

(select-blocks blocks lang)

Filter blocks to those whose :lang matches lang (case-insensitive) OR is nil (untagged — treated as a match for any language).

lang MUST be a non-blank string; pass "clojure", "python", etc.

Filter `blocks` to those whose `:lang` matches `lang` (case-insensitive)
OR is `nil` (untagged — treated as a match for any language).

`lang` MUST be a non-blank string; pass `"clojure"`, `"python"`, etc.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close