[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode c1e9822 1/2: Fix table conversion issue
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode c1e9822 1/2: Fix table conversion issue |
Date: |
Sat, 14 Aug 2021 02:57:25 -0400 (EDT) |
branch: elpa/markdown-mode
commit c1e98229989426ef4248bb0aaf69122ce02bb67b
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>
Fix table conversion issue
---
CHANGES.md | 2 ++
markdown-mode.el | 12 ++++++++++--
tests/markdown-test.el | 15 +++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 73de87b..e2aacf1 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -72,6 +72,7 @@
- Fix table operations when table column contains escaped vertical bars
[GH-635][]
- Fix issue that executing `markdown-table-sort-lines` via menu-bar with
older Emacs(< 28) [GH-641][]
- Fix wrong markdown table command issue in menu [GH-639][]
+ - Fix table conversion issue [GH-639][]
[gh-290]: https://github.com/jrblevin/markdown-mode/issues/290
[gh-311]: https://github.com/jrblevin/markdown-mode/issues/311
@@ -104,6 +105,7 @@
[gh-634]: https://github.com/jrblevin/markdown-mode/issues/634
[gh-635]: https://github.com/jrblevin/markdown-mode/issues/635
[gh-639]: https://github.com/jrblevin/markdown-mode/issues/639
+ [gh-640]: https://github.com/jrblevin/markdown-mode/issues/640
[gh-641]: https://github.com/jrblevin/markdown-mode/issues/641
# Markdown Mode 2.4
diff --git a/markdown-mode.el b/markdown-mode.el
index 4e73fb2..2efbfd1 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -9552,10 +9552,18 @@ spaces, or alternatively a TAB should be used as the
separator."
((integerp separator)
(if (< separator 1)
(user-error "Cell separator must contain one or more spaces")
- (format "^ *\\| *\t *\\| \\{%d,\\}" separator)))
+ (format "^ *\\| *\t *\\| \\{%d,\\}\\|$" separator)))
((stringp separator) (format "^ *\\|%s" separator))
(t (error "Invalid cell separator"))))
- (while (re-search-forward re end t) (replace-match "| " t t)))
+ (let (finish)
+ (while (and (not finish) (re-search-forward re end t))
+ (if (eolp)
+ (progn
+ (replace-match "|" t t)
+ (forward-line 1)
+ (when (eobp)
+ (setq finish t)))
+ (replace-match "| " t t)))))
(goto-char begin)
(when markdown-table-align-p
(markdown-table-align))))
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index c066b14..ff1ed54 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -7028,6 +7028,21 @@ title: asdasdasd
(markdown-table-forward-cell)
(should (string= (buffer-string) expected))))))
+(ert-deftest test-markdown-table/convert-table-region ()
+ "Test markdown-table-convert-region.
+https://github.com/jrblevin/markdown-mode/issues/640"
+ (let ((markdown-table-align-p t))
+ (markdown-test-string "1 2 3
+4 5 6"
+ (markdown-table-convert-region (point-min) (point-max))
+ (should (string= (buffer-substring-no-properties (point-min) (point-max))
+ "| 1 | 2 | 3 |
+| 4 | 5 | 6 |\n")))
+ (markdown-test-string "1 2 3 \n4 5 6 "
+ (markdown-table-convert-region (point-min) (point-max))
+ (should (string= (buffer-substring-no-properties (point-min) (point-max))
+ "| 1 | 2 | 3 |\n| 4 | 5 | 6 |\n")))))
+
(provide 'markdown-test)
;;; markdown-test.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/markdown-mode c1e9822 1/2: Fix table conversion issue,
ELPA Syncer <=