Skip to content

Commit

Permalink
Propertize GFM code blocks upon insertion
Browse files Browse the repository at this point in the history
See GH-251.
  • Loading branch information
jrblevin committed Nov 8, 2017
1 parent 3b92618 commit e065615
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ```
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit e065615

Please sign in to comment.