From 40f24268a14b03269462755f22e4c5ffd084c4e0 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sat, 27 Dec 2025 11:27:35 +0100 Subject: [PATCH] add single row table --- lisp/0patches/notes | 4 +++ ...x-rst_ox-rst.el_add-single-row-table.patch | 35 +++++++++++++++++++ lisp/ox-rst/ox-rst.el | 24 ++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 lisp/0patches/ox-rst_ox-rst.el_add-single-row-table.patch diff --git a/lisp/0patches/notes b/lisp/0patches/notes index a4551e41..b1c76386 100644 --- a/lisp/0patches/notes +++ b/lisp/0patches/notes @@ -16,3 +16,7 @@ ox-rst_ox-rst.el_add-code-block-caption.patch patch -d . -p1 -i lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch - reverse patch patch -R -d . -p1 -i lisp/0patches/ox-rst_ox-rst.el_add-code-block-caption.patch + +ox-rst_ox-rst.el_add-single-row-table.patch +- create the patch using git + git diff lisp/ox-rst/ox-rst.el >lisp/0patches/ox-rst_ox-rst.el_add-single-row-table.patch diff --git a/lisp/0patches/ox-rst_ox-rst.el_add-single-row-table.patch b/lisp/0patches/ox-rst_ox-rst.el_add-single-row-table.patch new file mode 100644 index 00000000..544d3af8 --- /dev/null +++ b/lisp/0patches/ox-rst_ox-rst.el_add-single-row-table.patch @@ -0,0 +1,35 @@ +diff --git a/lisp/ox-rst/ox-rst.el b/lisp/ox-rst/ox-rst.el +index fc423eac..0b19576d 100644 +--- a/lisp/ox-rst/ox-rst.el ++++ b/lisp/ox-rst/ox-rst.el +@@ -1542,7 +1542,29 @@ a communication channel." + (when (= 0 row-number) + (concat (funcall makeline contents ?-) "\n")) + "|" contents "|\n" hline)) +- nil ++ ;; nil ++ ;; the else section is hit whenever there is a new group, i.e. the row ++ ;; after a hline, OR if there is only one row in the table!!! ++ ;; (org-export-table-row-number table-row info) returns non-nil if there ++ ;; is only ONE row in the table (nil otherwise) ++ ;; same for `contents'; it is nil if not first row ++ (when contents ++ (let* ((makeline ++ (function ++ (lambda (_rowcontents linebit) ++ (format "+%s+" ++ (mapconcat ++ 'identity ++ (mapcar ++ (lambda (table-cell) ++ (make-string (string-width table-cell) ++ linebit)) ++ (split-string contents "|")) ++ "+")))))) ++ (concat ++ (concat (funcall makeline contents ?-) "\n") ++ (concat "|" contents "|\n") ++ (concat (funcall makeline contents ?-) "\n")))) + ))) + + diff --git a/lisp/ox-rst/ox-rst.el b/lisp/ox-rst/ox-rst.el index fc423eac..0b19576d 100644 --- a/lisp/ox-rst/ox-rst.el +++ b/lisp/ox-rst/ox-rst.el @@ -1542,7 +1542,29 @@ a communication channel." (when (= 0 row-number) (concat (funcall makeline contents ?-) "\n")) "|" contents "|\n" hline)) - nil + ;; nil + ;; the else section is hit whenever there is a new group, i.e. the row + ;; after a hline, OR if there is only one row in the table!!! + ;; (org-export-table-row-number table-row info) returns non-nil if there + ;; is only ONE row in the table (nil otherwise) + ;; same for `contents'; it is nil if not first row + (when contents + (let* ((makeline + (function + (lambda (_rowcontents linebit) + (format "+%s+" + (mapconcat + 'identity + (mapcar + (lambda (table-cell) + (make-string (string-width table-cell) + linebit)) + (split-string contents "|")) + "+")))))) + (concat + (concat (funcall makeline contents ?-) "\n") + (concat "|" contents "|\n") + (concat (funcall makeline contents ?-) "\n")))) )))