Function: markdown-ts--convert-code-block-language

markdown-ts--convert-code-block-language is a byte-compiled function defined in markdown-ts-mode.el.gz.

Signature

(markdown-ts--convert-code-block-language NODE)

Documentation

Convert NODE to a language for the code block.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--convert-code-block-language (node)
  "Convert NODE to a language for the code block."
  (let* ((lang-string (alist-get (treesit-node-text node)
                                 markdown-ts--code-block-language-map
                                 (treesit-node-text node) nil #'equal))
         (lang (if (symbolp lang-string)
                   lang-string
                 (intern (downcase lang-string)))))
    ;; FIXME: Kind of a hack here: we use this function as a hook for
    ;; loading up configs for the language for the code block on-demand.
    (let ((mode (alist-get lang markdown-ts-code-block-source-mode-map)))
      ;; If there's no supported mode for the language, return nil,
      ;; which makes Emacs skip the code block.
      (if (not (and mode (fboundp mode)))
          nil
        ;; If there's a major mode for the language, set up the config
        ;; and return the language.
        (when (not (memq lang markdown-ts--configured-languages))
          (markdown-ts--add-config-for-mode lang mode)
          (push lang markdown-ts--configured-languages))
        lang))))