;; content-on-sx — callout / admonition block.
;;
;; CtCallout holds a `kind` (note/warning/tip/…) and `text`. Self-contained: it
;; answers asHTML/asSx/asText/asMarkdown: so it composes with the render boundary
;; with no changes elsewhere. HTML text is htmlEscaped, SX text sxEscaped.
;;
;; Requires (loaded by harness): block.sx, doc.sx, render.sx (escapers);
;; markdown.sx / text.sx for those formats.

(define
  content-bootstrap-callout!
  (fn
    ()
    (begin
      (st-class-define! "CtCallout" "CtBlock" (list "kind" "text"))
      (ct-def-method! "CtCallout" "kind" "kind ^ kind")
      (ct-def-method! "CtCallout" "text" "text ^ text")
      (ct-def-method! "CtCallout" "type" "type ^ #callout")
      (ct-def-method!
        "CtCallout"
        "asHTML"
        "asHTML ^ '<aside class=\"callout callout-' , kind htmlEscaped , '\">' , text htmlEscaped , '</aside>'")
      (ct-def-method!
        "CtCallout"
        "asSx"
        "asSx ^ '(aside :class \"callout callout-' , kind sxEscaped , '\" \"' , text sxEscaped , '\")'")
      (ct-def-method! "CtCallout" "asText" "asText ^ text")
      (ct-def-method!
        "CtCallout"
        "asMarkdown:"
        "asMarkdown: nl ^ '> **' , kind , ':** ' , text")
      true)))

(define
  mk-callout
  (fn
    (id kind text)
    (st-iv-set!
      (st-iv-set!
        (st-iv-set! (st-make-instance "CtCallout") "id" id)
        "kind"
        kind)
      "text"
      text)))

(define
  callout?
  (fn (b) (and (st-instance? b) (= (get b :class) "CtCallout"))))
(define callout-kind (fn (b) (st-send b "kind" (list))))
