Skip to content

Commit

Permalink
fix #71
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny McClanahan authored and jrblevin committed Jan 11, 2016
1 parent fc1204b commit cf1ed9f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
21 changes: 14 additions & 7 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,12 @@ curly braces. They may be of arbitrary capitalization, though."
:group 'markdown
:type 'boolean)

(defcustom markdown-gfm-downcase-languages t
"Downcase suggested languages when inserting them to code blocks with
`markdown-electric-backquote'."
:group 'markdown
:type 'boolean)


;;; Regular Expressions =======================================================

Expand Down Expand Up @@ -3281,9 +3287,12 @@ already in `markdown-gfm-recognized-languages' or

(defun markdown-gfm-get-corpus ()
"Create corpus of recognized GFM code block languages for the given buffer."
(append markdown-gfm-used-languages
markdown-gfm-additional-languages
markdown-gfm-recognized-languages))
(let ((given-corpus (append markdown-gfm-additional-languages
markdown-gfm-recognized-languages)))
(append
markdown-gfm-used-languages
(if markdown-gfm-downcase-languages (cl-mapcar #'downcase given-corpus)
given-corpus))))

(defun markdown-add-language-if-new (lang)
(let* ((cleaned-lang (markdown-clean-language-string lang))
Expand All @@ -3301,16 +3310,14 @@ the region boundaries are not on empty lines, these are added
automatically in order to have the correct markup."
(interactive
(list (let ((completion-ignore-case nil))
(condition-case _err
(condition-case nil
(markdown-clean-language-string
(completing-read
(format "Programming language [%s]: "
(or markdown-gfm-last-used-language "none"))
(markdown-gfm-get-corpus)
nil 'confirm nil
'markdown-gfm-language-history
(or markdown-gfm-last-used-language
(car markdown-gfm-additional-languages))))
'markdown-gfm-language-history))
(quit "")))))
(unless (string= lang "") (markdown-add-language-if-new lang))
(when (> (length lang) 0) (setq lang (concat " " lang)))
Expand Down
16 changes: 15 additions & 1 deletion tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,21 @@ indented the same amount."
(markdown-insert-gfm-code-block "newlang")
(should (equal markdown-gfm-used-languages
(list "newlang" "MaDeUp" "LANGUAGES" "MADEUP")))
(should (equal markdown-gfm-last-used-language "newlang"))))
(should (equal markdown-gfm-last-used-language "newlang"))
(let ((markdown-gfm-downcase-languages nil))
(should
(equal (markdown-gfm-get-corpus)
(append markdown-gfm-used-languages
markdown-gfm-additional-languages
markdown-gfm-recognized-languages))))
(let ((markdown-gfm-downcase-languages t))
(should
(equal
(markdown-gfm-get-corpus)
(append markdown-gfm-used-languages
(cl-mapcar #'downcase
(append markdown-gfm-additional-languages
markdown-gfm-recognized-languages))))))))

(ert-deftest test-markdown-gfm/code-block-font-lock ()
"GFM code block font lock test."
Expand Down

0 comments on commit cf1ed9f

Please sign in to comment.