Function: markdown-ts-emphasize

markdown-ts-emphasize is an interactive and byte-compiled function defined in markdown-ts-mode.el.gz.

Signature

(markdown-ts-emphasize &optional CHAR)

Documentation

Insert or change emphasis on text.

If there is an active region, wrap it with emphasis markers. If there is no region, insert marker pairs and place point between them. CHAR selects the emphasis type:

  b **bold** B __bold__
  i *italic* I _italic_
  a ***bold+italic***
  s ~~strikethrough~~
  c `code`
  SPC remove emphasis at point or region

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts-emphasize (&optional char)
  "Insert or change emphasis on text.
If there is an active region, wrap it with emphasis markers.
If there is no region, insert marker pairs and place point between
them.  CHAR selects the emphasis type:

  b   **bold**       B  __bold__
  i   *italic*       I  _italic_
  a   ***bold+italic***
  s   ~~strikethrough~~
  c   `code`
  SPC remove emphasis at point or region"
  (interactive
   "cEmphasis [b]old [B]old_ [i]talic [I]talic_ [a]ll [s]trike [c]ode SPC remove:")
  (if (eq char ?\s)
      (markdown-ts-remove-emphasis)
    (if-let* ((marker (cdr (assq char markdown-ts-emphasis-alist))))
        (if (use-region-p)
            (let ((beg (region-beginning))
                  (end (copy-marker (region-end))))
              (save-excursion
                (goto-char end)
                (insert marker)
                (goto-char beg)
                (insert marker)))
          (if-let* ((bounds (bounds-of-thing-at-point 'word)))
              (save-excursion
                (goto-char (cdr bounds))
                (insert marker)
                (goto-char (car bounds))
                (insert marker))
            (insert marker marker)
            (backward-char (length marker))))
      (user-error "No such emphasis marker: %c" char))))