A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jrblevin/markdown-mode/issues/266 below:

Pipe table support implemented · Issue #266 · jrblevin/markdown-mode · GitHub

Inspired by the excellent Org mode table editor, I've implemented pipe table support in Markdown mode.

markdown-mode-table.zip

A simple pipe table looks like this:

| Right | Left | Center | Default |
|------:|:-----|:------:|---------|
|    12 | 12   | 12     | 12      |
|   123 | 123  | 123    | 123     |
|     1 | 1    | 1      | 1       |

First line contains column headers. Second line contains a separator line between the headers and the content. Each following line is a row in the table. Columns are always separated by the pipe character. The colons indicate column alignment.

The code provides context-sensitive key bindings, basically the same as of the Org mode table editor. A table is re-aligned automatically each time you press <TAB> or <RET> inside the table. <TAB> also moves to the next field (<RET> to the next row) and creates new table rows at the end of the table or before horizontal separator lines. The indentation of the table is set by the first line. Column centering inside Emacs is not supported.

Beginning pipe characters are required for proper detection of table borders inside Emacs. Any line starting with |- or |: is considered as a horizontal separator line and will be expanded on the next re-align to span the whole table width. No padding is allowed between the beginning pipe character and header separator symbol. So, to create the above table, you would only type

|Right|Left|Center|Default|
|-

and then press <TAB> to align the table and start filling in cells.

Then you can jump with the <TAB> from one cell to the next or with S-<TAB> to the previous one. <RET> will jump to the to the next cell in the same column, and create a new row if there is no such cell or if the next row is beyond a separator line.

You can also convert selected region to a pipe table via C-c |. Basic editing capabilities comprise inserting, deleting, and moving of columns and rows, and table sorting and transposing:

The code can be loaded and used in combination with the current stable version of Markdown mode, just by putting the file markdown-mode-table.el somewhere in the Emacs load path and adding to your .emacs file:

(require 'markdown-mode-table)

but I would love to see it implemented in the Markdown mode itself. Basically one just needs to copy the content of the file and adapt some functions for the context-sensitive key bindings.

grayhempAmbrevar, cjk and aparkerlue


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4