Function: markdown-fontify-code-block-natively
markdown-fontify-code-block-natively is a byte-compiled function
defined in markdown-mode.el.
Signature
(markdown-fontify-code-block-natively LANG START END)
Documentation
Fontify given GFM or fenced code block.
This function is called by Emacs for automatic fontification when
markdown-fontify-code-blocks-natively is non-nil. LANG is the
language used in the block. START and END specify the block
position.
Source Code
;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
;; Based on `org-src-font-lock-fontify-block' from org-src.el.
(defun markdown-fontify-code-block-natively (lang start end)
"Fontify given GFM or fenced code block.
This function is called by Emacs for automatic fontification when
`markdown-fontify-code-blocks-natively' is non-nil. LANG is the
language used in the block. START and END specify the block
position."
(let ((lang-mode (if lang (markdown-get-lang-mode lang)
markdown-fontify-code-block-default-mode)))
(when (fboundp lang-mode)
(let ((string (buffer-substring-no-properties start end))
(modified (buffer-modified-p))
(markdown-buffer (current-buffer)) pos next)
(remove-text-properties start end '(face nil))
(with-current-buffer
(get-buffer-create
(format " *markdown-code-fontification:%s*" (symbol-name lang-mode)))
;; Make sure that modification hooks are not inhibited in
;; the org-src-fontification buffer in case we're called
;; from `jit-lock-function' (Bug#25132).
(let ((inhibit-modification-hooks nil))
(delete-region (point-min) (point-max))
(insert string " ")) ;; so there's a final property change
(unless (eq major-mode lang-mode) (funcall lang-mode))
(font-lock-ensure)
(setq pos (point-min))
(while (setq next (next-single-property-change pos 'face))
(let ((val (get-text-property pos 'face)))
(when val
(put-text-property
(+ start (1- pos)) (1- (+ start next)) 'face
val markdown-buffer)))
(setq pos next)))
(add-text-properties
start end
'(font-lock-fontified t fontified t font-lock-multiline t))
(set-buffer-modified-p modified)))))