[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode 141f9a05d1 3/3: Merge pull request #818 from
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/markdown-mode 141f9a05d1 3/3: Merge pull request #818 from jrblevin/issue/817 |
|
Date: |
Thu, 30 Nov 2023 01:00:18 -0500 (EST) |
branch: elpa/markdown-mode
commit 141f9a05d121f60fe5e411c0ad114e3d3216c9ad
Merge: b1a862f016 e0f2926038
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #818 from jrblevin/issue/817
Fix table alignment if there is a separator in inline code
---
CHANGES.md | 2 ++
markdown-mode.el | 21 +++++++++++----------
tests/markdown-test.el | 15 +++++++++++++++
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 6f0df291e6..ec60c06532 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -11,6 +11,7 @@
* Bug fixes:
- Don't highlight superscript/subscript in math inline/block [GH-802][]
+ - Fix table alignment when a column has a seperator in code block
[GH-817][]
* Improvements:
- Apply url-unescape against URL in an inline link [GH-805][]
@@ -19,6 +20,7 @@
[gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
[gh-804]: https://github.com/jrblevin/markdown-mode/issues/804
[gh-805]: https://github.com/jrblevin/markdown-mode/issues/805
+ [gh-817]: https://github.com/jrblevin/markdown-mode/issues/817
# Markdown Mode 2.6
diff --git a/markdown-mode.el b/markdown-mode.el
index 0771060ca7..f1aee9d1c5 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -9300,16 +9300,17 @@ This function assumes point is on a table."
(goto-char (point-min))
(let ((cur (point))
ret)
- (while (re-search-forward "\\s-*\\(|\\)\\s-*" nil t)
- (if (markdown--first-column-p (match-beginning 1))
- (setq cur (match-end 0))
- (cond ((eql (char-before (match-beginning 1)) ?\\)
- ;; keep spaces
- (goto-char (match-end 1)))
- ((markdown--thing-at-wiki-link (match-beginning 1))) ;; do
nothing
- (t
- (push (buffer-substring-no-properties cur (match-beginning
0)) ret)
- (setq cur (match-end 0))))))
+ (while (and (re-search-forward "\\s-*\\(|\\)\\s-*" nil t))
+ (when (not (markdown--face-p (match-beginning 1)
'(markdown-inline-code-face)))
+ (if (markdown--first-column-p (match-beginning 1))
+ (setq cur (match-end 0))
+ (cond ((eql (char-before (match-beginning 1)) ?\\)
+ ;; keep spaces
+ (goto-char (match-end 1)))
+ ((markdown--thing-at-wiki-link (match-beginning 1))) ;; do
nothing
+ (t
+ (push (buffer-substring-no-properties cur (match-beginning
0)) ret)
+ (setq cur (match-end 0)))))))
(when (< cur (length line))
(push (buffer-substring-no-properties cur (point-max)) ret))
(nreverse ret))))
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 0abcbc9423..8d68269f19 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -7379,6 +7379,21 @@ title: asdasdasd
| aaa | bbbb | ccccc | dddddd |
"))))
+(ert-deftest test-markdown-table/align-with-seperator-in-inline-code ()
+ "Test table realignment when separator is in inline code.
+Detail: https://github.com/jrblevin/markdown-mode/issues/817"
+ (markdown-test-string "| `<|--` | Inheritance |
+| `..|>` | Realization |
+"
+ (let ((columns (markdown--table-line-to-columns
+ (buffer-substring (line-beginning-position)
(line-end-position)))))
+ (should (equal columns '("`<|--`" "Inheritance"))))
+
+ (forward-line)
+ (let ((columns (markdown--table-line-to-columns
+ (buffer-substring (line-beginning-position)
(line-end-position)))))
+ (should (equal columns '("`..|>`" "Realization"))))))
+
(ert-deftest test-markdown-table/disable-table-align ()
"Test disable table alignment."
(let ((input "| 12345 | 6 |