Function: markdown-code-block-lang

markdown-code-block-lang is a byte-compiled function defined in markdown-mode.el.

Signature

(markdown-code-block-lang &optional POS-PROP)

Documentation

Return the language name for a GFM or tilde fenced code block.

The beginning of the block may be described by POS-PROP, a cons of (pos . prop) giving the position and property at the beginning of the block.

Source Code

;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
(defun markdown-code-block-lang (&optional pos-prop)
  "Return the language name for a GFM or tilde fenced code block.
The beginning of the block may be described by POS-PROP,
a cons of (pos . prop) giving the position and property
at the beginning of the block."
  (or pos-prop
      (setq pos-prop
            (markdown-max-of-seq
             #'car
             (cl-remove-if
              #'null
              (cl-mapcar
               #'markdown-find-previous-prop
               (markdown-get-fenced-block-begin-properties))))))
  (when pos-prop
    (goto-char (car pos-prop))
    (set-match-data (get-text-property (point) (cdr pos-prop)))
    ;; Note: Hard-coded group number assumes tilde
    ;; and GFM fenced code regexp groups agree.
    (let ((begin (match-beginning 3))
          (end (match-end 3)))
      (when (and begin end)
        ;; Fix language strings beginning with periods, like ".ruby".
        (when (eq (char-after begin) ?.)
          (setq begin (1+ begin)))
        (buffer-substring-no-properties begin end)))))