File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -4376,6 +4376,14 @@ be used to populate the title attribute when converted to XHTML."
43764376 (immediately (markdown-end-of-text-block))
43774377 (subtree (markdown-end-of-subtree))
43784378 (header (markdown-end-of-defun)))
4379+ ;; Skip backwards over local variables. This logic is similar to the one
4380+ ;; used in ‘hack-local-variables’.
4381+ (when (and enable-local-variables (eobp))
4382+ (search-backward "\n\f" (max (- (point) 3000) (point-min)) :move)
4383+ (when (let ((case-fold-search t))
4384+ (search-forward "Local Variables:" nil :move))
4385+ (beginning-of-line 0)
4386+ (when (eq (char-before) ?\n) (backward-char))))
43794387 (unless (or (markdown-cur-line-blank-p)
43804388 (thing-at-point-looking-at markdown-regex-reference-definition))
43814389 (insert "\n"))
Original file line number Diff line number Diff line change @@ -1134,6 +1134,26 @@ Test point position upon removal and insertion."
11341134 (should (= (point) 38))
11351135 (should (looking-back "https://www.gnu.org/\n\\[2\\]: " nil)))))
11361136
1137+ (ert-deftest test-markdown-insertion/reference-link-before-file-locals ()
1138+ "Test inserting a reference link before file-local variables."
1139+ (markdown-test-string "
1140+
1141+ <!-- Local Variables: -->
1142+ <!-- mode: markdown -->
1143+ <!-- End: -->
1144+ "
1145+ (markdown-insert-reference-link "link" "" "http://jblevins.org/")
1146+ (should (equal (buffer-substring-no-properties 1 (point-max))
1147+ "[link][]
1148+
1149+ \[link]: http://jblevins.org/
1150+
1151+ <!-- Local Variables: -->
1152+ <!-- mode: markdown -->
1153+ <!-- End: -->
1154+ "))
1155+ (should (equal (point) 9))))
1156+
11371157(ert-deftest test-markdown-insertion/inline-to-reference-link ()
11381158 "Inline link to reference link conversion with tab completion."
11391159 (markdown-test-string "[text](http://jblevins.org/ \"title\")"
You can’t perform that action at this time.
0 commit comments