mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Allow generating wiki and mediawiki tables
* lisp/textmodes/table.el (table--generate-source-prologue) (table--generate-source-epilogue) (table--generate-source-scan-rows) (table--generate-source-cells-in-a-row): Insert the wiki/mediawiki separators. * lisp/textmodes/table.el (table-source-languages): Add support for wiki and mediawiki tables (bug#13287). 2019-06-27 Lars Ingebrigtsen <larsi@gnus.org> * doc/emacs/text.texi (Table Misc): Mention the new wiki and mediawiki formats.
This commit is contained in:
parent
573de396f0
commit
d64c72f50c
3 changed files with 38 additions and 17 deletions
|
|
@ -2851,11 +2851,12 @@ cell interval, and the justification of the text in each cell.
|
|||
@findex table-generate-source
|
||||
@kbd{M-x table-generate-source} generates a table formatted for a
|
||||
specific markup language. It asks for a language (which must be one
|
||||
of @code{html}, @code{latex}, or @code{cals}), a destination buffer in
|
||||
which to put the result, and a table caption, and then inserts the
|
||||
generated table into the specified buffer. The default destination
|
||||
buffer is @code{table.@var{lang}}, where @var{lang} is the language
|
||||
you specified.
|
||||
of @code{html}, @code{latex}, @code{cals}, @code{wiki} or
|
||||
@code{mediawiki}), a destination buffer in which to put the result,
|
||||
and a table caption, and then inserts the generated table into the
|
||||
specified buffer. The default destination buffer is
|
||||
@code{table.@var{lang}}, where @var{lang} is the language you
|
||||
specified.
|
||||
|
||||
@node Two-Column
|
||||
@section Two-Column Editing
|
||||
|
|
|
|||
4
etc/NEWS
4
etc/NEWS
|
|
@ -475,6 +475,10 @@ current and the previous or the next line, as before.
|
|||
|
||||
* Changes in Specialized Modes and Packages in Emacs 27.1
|
||||
|
||||
** table
|
||||
** `table-generate-source' and friends now support outputting wiki and
|
||||
mediawiki format tables.
|
||||
|
||||
---
|
||||
** telnet-mode
|
||||
*** Reverting a buffer in `telnet-mode' will restart a closed
|
||||
|
|
|
|||
|
|
@ -882,7 +882,7 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu
|
|||
(push '(table-mode-indicator (table-fixed-width-mode " Fixed-Table" " Table"))
|
||||
minor-mode-alist))
|
||||
|
||||
(defconst table-source-languages '(html latex cals)
|
||||
(defconst table-source-languages '(html latex cals wiki mediawiki)
|
||||
"Supported source languages.")
|
||||
(defvar table-source-info-plist nil
|
||||
"General storage for temporary information used while generating source.")
|
||||
|
|
@ -3053,7 +3053,11 @@ CALS (DocBook DTD):
|
|||
(table-put-source-info 'row-type (if (zerop table-cals-thead-rows) "tbody" "thead"))
|
||||
(set-marker-insertion-type (table-get-source-info 'colspec-marker) nil) ;; insert after
|
||||
(insert (format " <%s valign=\"top\">\n" (table-get-source-info 'row-type))))
|
||||
)))
|
||||
((eq language 'mediawiki)
|
||||
(insert (format
|
||||
"<!-- This HTML table template is generated by Emacs %s -->\n"
|
||||
emacs-version))
|
||||
(insert "{|\n")))))
|
||||
|
||||
(defun table--generate-source-epilogue (dest-buffer language _col-list _row-list)
|
||||
"Generate and insert source epilogue into DEST-BUFFER."
|
||||
|
|
@ -3070,7 +3074,8 @@ CALS (DocBook DTD):
|
|||
(dolist (col (sort (table-get-source-info 'colnum-list) '<))
|
||||
(insert (format " <colspec colnum=\"%d\" colname=\"c%d\"/>\n" col col))))
|
||||
(insert (format " </%s>\n </tgroup>\n</table>\n" (table-get-source-info 'row-type))))
|
||||
)))
|
||||
((eq language 'mediawiki)
|
||||
(insert "|}\n")))))
|
||||
|
||||
(defun table--generate-source-scan-rows (dest-buffer language _origin-cell col-list row-list)
|
||||
"Generate and insert source rows into DEST-BUFFER."
|
||||
|
|
@ -3082,7 +3087,11 @@ CALS (DocBook DTD):
|
|||
(insert " <tr>\n"))
|
||||
((eq language 'cals)
|
||||
(insert " <row>\n"))
|
||||
))
|
||||
((eq language 'wiki)
|
||||
(insert "|"))
|
||||
((and (eq language 'mediawiki)
|
||||
(> (table-get-source-info 'current-row) 1))
|
||||
(insert "|-\n"))))
|
||||
(table--generate-source-cells-in-a-row dest-buffer language col-list row-list)
|
||||
(with-current-buffer dest-buffer
|
||||
(cond
|
||||
|
|
@ -3092,7 +3101,9 @@ CALS (DocBook DTD):
|
|||
(insert " </row>\n")
|
||||
(unless (/= (table-get-source-info 'current-row) table-cals-thead-rows)
|
||||
(insert (format " </%s>\n" (table-get-source-info 'row-type)))
|
||||
(insert (format " <%s valign=\"top\">\n" (table-put-source-info 'row-type "tbody")))))))
|
||||
(insert (format " <%s valign=\"top\">\n" (table-put-source-info 'row-type "tbody")))))
|
||||
((eq language 'wiki)
|
||||
(insert "|\n"))))
|
||||
(table-put-source-info 'current-row (1+ (table-get-source-info 'current-row)))
|
||||
(setq row-list (cdr row-list))))
|
||||
|
||||
|
|
@ -3161,7 +3172,8 @@ CALS (DocBook DTD):
|
|||
(not (memq valign '(top none))))
|
||||
(insert " valign=\"" (symbol-name valign) "\""))
|
||||
(insert ">\n"))
|
||||
))
|
||||
((memq language '(wiki mediawiki))
|
||||
(insert "|"))))
|
||||
(table--generate-source-cell-contents dest-buffer language cell)
|
||||
(with-current-buffer dest-buffer
|
||||
(cond
|
||||
|
|
@ -3169,7 +3181,10 @@ CALS (DocBook DTD):
|
|||
(insert (format" </%s>\n" (table-get-source-info 'cell-type))))
|
||||
((eq language 'cals)
|
||||
(insert " </entry>\n"))
|
||||
))
|
||||
((eq language 'wiki)
|
||||
(insert "|"))
|
||||
((eq language 'mediawiki)
|
||||
(insert ?\n))))
|
||||
(table-forward-cell 1 t)
|
||||
(table-put-source-info 'current-column (table-get-source-info 'next-column))
|
||||
))))
|
||||
|
|
@ -3208,11 +3223,12 @@ CALS (DocBook DTD):
|
|||
(with-current-buffer dest-buffer
|
||||
(let ((beg (point)))
|
||||
(insert cell-contents)
|
||||
(indent-rigidly beg (point)
|
||||
(cond
|
||||
((eq language 'html) 6)
|
||||
((eq language 'cals) 10)))
|
||||
(insert ?\n)))))
|
||||
(when (memq language '(html cals))
|
||||
(indent-rigidly beg (point)
|
||||
(cond
|
||||
((eq language 'html) 6)
|
||||
((eq language 'cals) 10)))
|
||||
(insert ?\n))))))
|
||||
|
||||
(defun table--cell-horizontal-char-p (c)
|
||||
"Test if character C is one of the horizontal characters"
|
||||
|
|
|
|||
Loading…
Reference in a new issue