Liking cljdoc? Tell your friends :D

com.blockether.spel.markdown

Parse and generate GitHub-flavored markdown tables.

Converts between markdown table strings and Clojure data:

  • from-markdown-table : markdown string → vector of maps
  • to-markdown-table : vector of maps → markdown string

Useful in --eval scripts for processing tabular data from web pages, API responses, or LLM output.

Parse and generate GitHub-flavored markdown tables.

Converts between markdown table strings and Clojure data:
- `from-markdown-table` : markdown string → vector of maps
- `to-markdown-table`   : vector of maps → markdown string

Useful in --eval scripts for processing tabular data from web pages,
API responses, or LLM output.
raw docstring

from-markdown-tableclj

(from-markdown-table s)
(from-markdown-table s opts)

Parses a markdown table string into a vector of maps.

Each map has keys from the header row (as strings by default, or as keywords when :keywordize true).

Options: :keywordize - Convert header names to keywords (default: false)

Examples: (from-markdown-table "| Name | Age |\n|---|---|\n| Alice | 30 |") ;; => [{"Name" "Alice", "Age" "30"}]

(from-markdown-table "| Name | Age |\n|---|---|\n| Alice | 30 |" {:keywordize true}) ;; => [{:name "Alice", :age "30"}]

Parses a markdown table string into a vector of maps.

Each map has keys from the header row (as strings by default,
or as keywords when :keywordize true).

Options:
  :keywordize  - Convert header names to keywords (default: false)

Examples:
  (from-markdown-table "| Name | Age |\n|---|---|\n| Alice | 30 |")
  ;; => [{"Name" "Alice", "Age" "30"}]

  (from-markdown-table "| Name | Age |\n|---|---|\n| Alice | 30 |" {:keywordize true})
  ;; => [{:name "Alice", :age "30"}]
sourceraw docstring

to-markdown-tableclj

(to-markdown-table rows)
(to-markdown-table rows opts)

Converts a vector of maps to a markdown table string.

Options: :columns - Explicit column order (vector of keys). Default: sorted keys from first map. :headers - Custom header labels (map of key → label string). Default: key as string. :align - Column alignment (map of key → :left/:right/:center). Default: :left.

Examples: (to-markdown-table [{"Name" "Alice" "Age" "30"} {"Name" "Bob" "Age" "25"}]) ;; => "| Age | Name |\n|-----|------|\n| 30 | Alice |\n| 25 | Bob |"

(to-markdown-table [{:name "Alice" :age 30}] {:columns [:name :age]}) ;; => "| name | age |\n|------|-----|\n| Alice | 30 |"

(to-markdown-table [{:name "Alice" :age 30}] {:columns [:name :age] :headers {:name "Name" :age "Age"} :align {:age :right}}) ;; => "| Name | Age |\n|------|----:|\n| Alice | 30 |"

Converts a vector of maps to a markdown table string.

Options:
  :columns  - Explicit column order (vector of keys). Default: sorted keys from first map.
  :headers  - Custom header labels (map of key → label string). Default: key as string.
  :align    - Column alignment (map of key → :left/:right/:center). Default: :left.

Examples:
  (to-markdown-table [{"Name" "Alice" "Age" "30"} {"Name" "Bob" "Age" "25"}])
  ;; => "| Age | Name |\n|-----|------|\n| 30  | Alice |\n| 25  | Bob  |"

  (to-markdown-table [{:name "Alice" :age 30}] {:columns [:name :age]})
  ;; => "| name | age |\n|------|-----|\n| Alice | 30 |"

  (to-markdown-table [{:name "Alice" :age 30}]
    {:columns [:name :age]
     :headers {:name "Name" :age "Age"}
     :align   {:age :right}})
  ;; => "| Name | Age |\n|------|----:|\n| Alice | 30 |"
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