Skip to content

Commit

Permalink
Merge pull request #872 from shipmints/markdown-wiki-link-retain-case
Browse files Browse the repository at this point in the history
Add defcustom markdown-wiki-link-retain-case
  • Loading branch information
syohex authored Jan 15, 2025
2 parents e100778 + f6ab102 commit 3c28f0c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Trailing whitespace characters for line breaks are hidden when using
`markdown-hide-markup`
- `fill-paragraph` considers GFM alert syntax [GH-838][]
- Add new flag `markdown-wiki-link-retain-case` [GH-839][]

* Bug fixes:
- Don't highlight superscript/subscript in math inline/block [GH-802][]
Expand All @@ -40,6 +41,7 @@
[gh-827]: https://github.com/jrblevin/markdown-mode/issues/827
[gh-834]: https://github.com/jrblevin/markdown-mode/issues/834
[gh-838]: https://github.com/jrblevin/markdown-mode/issues/838
[gh-839]: https://github.com/jrblevin/markdown-mode/issues/839
[gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
[gh-848]: https://github.com/jrblevin/markdown-mode/issues/848
[gh-855]: https://github.com/jrblevin/markdown-mode/issues/855
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ provides an interface to all of the possible customizations:
(default: `t`). When set to nil, they will be treated as
`[[PageName|link text]]`.
* `markdown-wiki-link-retain-case nil` - set a non-nil value not to
change wiki link file name case
* `markdown-uri-types` - a list of protocol schemes (e.g., "http")
for URIs that `markdown-mode` should highlight.
Expand Down
9 changes: 8 additions & 1 deletion markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ cause lag when typing on slower machines."
:safe 'booleanp
:package-version '(markdown-mode . "2.2"))

(defcustom markdown-wiki-link-retain-case nil
"When non-nil, wiki link file names do not have their case changed."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.7"))

(defcustom markdown-uri-types
'("acap" "cid" "data" "dav" "fax" "file" "ftp"
"geo" "gopher" "http" "https" "imap" "ldap" "mailto"
Expand Down Expand Up @@ -8374,7 +8381,7 @@ in parent directories if
;; This function must not overwrite match data(PR #590)
(let* ((basename (replace-regexp-in-string
"[[:space:]\n]" markdown-link-space-sub-char name))
(basename (if (derived-mode-p 'gfm-mode)
(basename (if (and (derived-mode-p 'gfm-mode) (not markdown-wiki-link-retain-case))
(concat (upcase (substring basename 0 1))
(downcase (substring basename 1 nil)))
basename))
Expand Down
19 changes: 19 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -7123,6 +7123,25 @@ Detail: https://github.com/jrblevin/markdown-mode/pull/590"
(should (string= (expand-file-name link) expected))))
(kill-buffer)))))

(ert-deftest test-markdown-ext/wiki-link-retain-case ()
"Test that searching link under project root."
(let ((markdown-wiki-link-retain-case nil))
(find-file "wiki/pr666/jump_wiki_link.md")
(unwind-protect
(progn
(gfm-mode)
(let ((link-file-name (markdown-convert-wiki-link-to-filename "FOOBAR")))
(should (string= "Foobar.md" (file-name-nondirectory link-file-name)))))
(kill-buffer)))
(let ((markdown-wiki-link-retain-case t))
(find-file "wiki/pr666/jump_wiki_link.md")
(unwind-protect
(progn
(gfm-mode)
(let ((link-file-name (markdown-convert-wiki-link-to-filename "FOOBAR")))
(should (string= "FOOBAR.md" (file-name-nondirectory link-file-name)))))
(kill-buffer))))

(ert-deftest test-markdown-ext/wiki-link-major-mode ()
"Test major-mode of linked page."
(let ((markdown-enable-wiki-links t)
Expand Down

0 comments on commit 3c28f0c

Please sign in to comment.