Function: markdown-ts--decode-entity
markdown-ts--decode-entity is a byte-compiled function defined in
markdown-ts-mode.el.gz.
Signature
(markdown-ts--decode-entity TEXT)
Documentation
Decode HTML entity TEXT (e.g., "&") to its character string.
Return the decoded string, or nil if the entity is unknown.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--decode-entity (text)
"Decode HTML entity TEXT (e.g., \"&\") to its character string.
Return the decoded string, or nil if the entity is unknown."
(cond
;; Numeric hex 💩
((string-match "\\`&#x\\([[:xdigit:]]+\\);\\'" text)
(char-to-string (string-to-number (match-string 1 text) 16)))
;; Numeric decimal {
((string-match "\\`&#\\([[:digit:]]+\\);\\'" text)
(char-to-string (string-to-number (match-string 1 text))))
;; Named & © via org-entities, fall back to sgml-char-names
((string-match "\\`&\\([[:alnum:]]+\\);\\'" text)
(let ((name (match-string 1 text)))
(require 'org-entities)
(if-let* ((entry (org-entity-get name))
(utf8 (nth 6 entry)))
utf8
(require 'sgml-mode)
(when-let* ((code (seq-position sgml-char-names name #'equal)))
(char-to-string code)))))))