@@ -1574,6 +1574,13 @@ MIDDLE-BEGIN is the start of the \"middle\" section of the block."
15741574 (put-text-property close-begin close-end
15751575 (cl-cadadr fence-spec) close-data))))
15761576
1577+ (defun markdown--triple-quote-single-line-p (begin)
1578+ (save-excursion
1579+ (goto-char begin)
1580+ (save-match-data
1581+ (and (search-forward "```" nil t)
1582+ (search-forward "```" (line-end-position) t)))))
1583+
15771584(defun markdown-syntax-propertize-fenced-block-constructs (start end)
15781585 "Propertize according to `markdown-fenced-block-pairs' from START to END.
15791586If unable to propertize an entire block (if the start of a block is within START
@@ -1608,7 +1615,8 @@ start which was previously propertized."
16081615 (while (re-search-forward start-reg end t)
16091616 ;; we assume the opening constructs take up (only) an entire line,
16101617 ;; so we re-check the current line
1611- (let* ((cur-line (buffer-substring (point-at-bol) (point-at-eol)))
1618+ (let* ((block-start (match-beginning 0))
1619+ (cur-line (buffer-substring (point-at-bol) (point-at-eol)))
16121620 ;; find entry in `markdown-fenced-block-pairs' corresponding
16131621 ;; to regex which was matched
16141622 (correct-entry
@@ -1625,18 +1633,20 @@ start which was previously propertized."
16251633 (cl-caadr correct-entry)
16261634 (if (and (match-beginning 1) (match-end 1))
16271635 (- (match-end 1) (match-beginning 1))
1628- 0))))
1629- ;; get correct match data
1630- (save-excursion
1631- (beginning-of-line)
1632- (re-search-forward
1633- (markdown-maybe-funcall-regexp (caar correct-entry))
1634- (point-at-eol)))
1635- ;; mark starting, even if ending is outside of region
1636- (put-text-property (match-beginning 0) (match-end 0)
1637- (cl-cadar correct-entry) (match-data t))
1638- (markdown-propertize-end-match
1639- end-reg end correct-entry enclosed-text-start))))))
1636+ 0)))
1637+ (prop (cl-cadar correct-entry)))
1638+ (when (or (not (eq prop 'markdown-gfm-block-begin))
1639+ (not (markdown--triple-quote-single-line-p block-start)))
1640+ ;; get correct match data
1641+ (save-excursion
1642+ (beginning-of-line)
1643+ (re-search-forward
1644+ (markdown-maybe-funcall-regexp (caar correct-entry))
1645+ (point-at-eol)))
1646+ ;; mark starting, even if ending is outside of region
1647+ (put-text-property (match-beginning 0) (match-end 0) prop (match-data t))
1648+ (markdown-propertize-end-match
1649+ end-reg end correct-entry enclosed-text-start)))))))
16401650
16411651(defun markdown-syntax-propertize-blockquotes (start end)
16421652 "Match blockquotes from START to END."
0 commit comments