diff --git a/markdown-mode.el b/markdown-mode.el index a92c7624..e49b7639 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -5131,13 +5131,14 @@ automatically in order to have the correct markup." (markdown-gfm-get-corpus) nil 'confirm (car markdown-gfm-used-languages) 'markdown-gfm-language-history)) - (quit ""))))) + (quit ""))) + current-prefix-arg)) (unless (string= lang "") (markdown-gfm-add-used-language lang)) (when (> (length lang) 0) (setq lang (concat (make-string markdown-spaces-after-code-fence ?\s) lang))) (if (markdown-use-region-p) - (let* ((b (region-beginning)) (e (region-end)) + (let* ((b (region-beginning)) (e (region-end)) end (indent (progn (goto-char b) (current-indentation)))) (goto-char e) ;; if we're on a blank line, don't newline, otherwise the ``` @@ -5147,6 +5148,7 @@ automatically in order to have the correct markup." (indent-to indent) (insert "```") (markdown-ensure-blank-line-after) + (setq end (point)) (goto-char b) ;; if we're on a blank line, insert the quotes here, otherwise ;; add a new line first @@ -5155,17 +5157,20 @@ automatically in order to have the correct markup." (forward-line -1)) (markdown-ensure-blank-line-before) (indent-to indent) - (insert "```" lang)) - (let ((indent (current-indentation))) + (insert "```" lang) + (markdown-syntax-propertize-fenced-block-constructs (point-at-bol) end)) + (let ((indent (current-indentation)) start) (delete-horizontal-space :backward-only) (markdown-ensure-blank-line-before) (indent-to indent) + (setq start (point)) (insert "```" lang "\n") (indent-to indent) (insert ?\n) (indent-to indent) (insert "```") - (markdown-ensure-blank-line-after)) + (markdown-ensure-blank-line-after) + (markdown-syntax-propertize-fenced-block-constructs start (point))) (end-of-line 0))) (defun markdown-code-block-lang (&optional pos-prop)