emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode 9afb59fce2 1/3: Fix table alignment if there


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 9afb59fce2 1/3: Fix table alignment if there is a separator in inline code
Date: Thu, 30 Nov 2023 01:00:18 -0500 (EST)

branch: elpa/markdown-mode
commit 9afb59fce2bc82226101a738c4ac57bb08cc75a2
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>

    Fix table alignment if there is a separator in inline code
---
 markdown-mode.el       | 21 +++++++++++----------
 tests/markdown-test.el | 15 +++++++++++++++
 2 files changed, 26 insertions(+), 10 deletions(-)

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 |



reply via email to

[Prev in Thread] Current Thread [Next in Thread]