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 @@ -4367,6 +4367,14 @@ be used to populate the title attribute when converted to XHTML."
43674367 (immediately (markdown-end-of-text-block))
43684368 (subtree (markdown-end-of-subtree))
43694369 (header (markdown-end-of-defun)))
4370+ ;; Skip backwards over local variables. This logic is similar to the one
4371+ ;; used in ‘hack-local-variables’.
4372+ (when (and enable-local-variables (eobp))
4373+ (search-backward "\n\f" (max (- (point) 3000) (point-min)) :move)
4374+ (when (let ((case-fold-search t))
4375+ (search-forward "Local Variables:" nil :move))
4376+ (beginning-of-line 0)
4377+ (when (eq (char-before) ?\n) (backward-char))))
43704378 (unless (or (markdown-cur-line-blank-p)
43714379 (thing-at-point-looking-at markdown-regex-reference-definition))
43724380 (insert "\n"))
Original file line number Diff line number Diff line change @@ -1129,6 +1129,26 @@ Test point position upon removal and insertion."
11291129 (should (= (point) 38))
11301130 (should (looking-back "https://www.gnu.org/\n\\[2\\]: " nil)))))
11311131
1132+ (ert-deftest test-markdown-insertion/reference-link-before-file-locals ()
1133+ "Test inserting a reference link before file-local variables."
1134+ (markdown-test-string "
1135+
1136+ <!-- Local Variables: -->
1137+ <!-- mode: markdown -->
1138+ <!-- End: -->
1139+ "
1140+ (markdown-insert-reference-link "link" "" "http://jblevins.org/")
1141+ (should (equal (buffer-substring-no-properties 1 (point-max))
1142+ "[link][]
1143+
1144+ \[link]: http://jblevins.org/
1145+
1146+ <!-- Local Variables: -->
1147+ <!-- mode: markdown -->
1148+ <!-- End: -->
1149+ "))
1150+ (should (equal (point) 9))))
1151+
11321152(ert-deftest test-markdown-insertion/inline-to-reference-link ()
11331153 "Inline link to reference link conversion with tab completion."
11341154 (markdown-test-string "[text](http://jblevins.org/ \"title\")"
You can’t perform that action at this time.
0 commit comments