Function: markdown-ts--toc-text-normalize

markdown-ts--toc-text-normalize is a byte-compiled function defined in markdown-ts-mode-x.el.gz.

Signature

(markdown-ts--toc-text-normalize HANDLE NODE &optional TEXT)

Documentation

Normalize NODE's TEXT according to its HANDLE.

TEXT should have no text properties. If TEXT is nil, use the NODE's text. This is not always correct so it's best to pass TEXT if you know it in the calling context.

If no normalizer is found, return TEXT.

One example normalization is atx_heading text that ends in trailing hash signs which are intended to be elided so "Heading Text ##" is transformed into "Heading Text".

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode-x.el.gz
(defun markdown-ts--toc-text-normalize (handle node &optional text)
  "Normalize NODE's TEXT according to its HANDLE.
TEXT should have no text properties.  If TEXT is nil, use the NODE's
text.  This is not always correct so it's best to pass TEXT if you know
it in the calling context.

If no normalizer is found, return TEXT.

One example normalization is atx_heading text that ends in trailing hash
signs which are intended to be elided so \"Heading Text ##\" is
transformed into \"Heading Text\"."
  (setq text (or text (treesit-node-text node 'no-property)))
  (if-let* ((fixer (alist-get handle markdown-ts--toc-text-normalizers)))
      (funcall fixer text)
    text))