Scripting - easy creation of text tables (flat and nested)


#1

Here are two KeyBoard Maestro macros which:

  1. Make it easy to create and pretty-print text tables (MMD Format)

  2. Provide conversion from simple outlines to nested MMD tables, and vice versa.

(Github page)

Automatically complete, pretty-print, and convert MultiMarkdown tables in FoldingText

Two Keyboard Maestro macros

Installation

  • If you have installed Github for Mac you should be able to open and install the KM Macros by clicking the open button at the top of this page
  • Otherwise save the plist text on that page as a text file with the .kmmacros extension, and open it in KeyBoard Maestro.

Use

  • Place your cursor anywhere in rough table or MD outline,
  • run one of the two macros from KM.

Pretty-print as MMD table

(from selected rough table or md outline)
  • Performs automatic completion and monospaced pretty-printing of an existing MMD table containing the cursor,
alpha|beta|gamma
1|23|45
7|8|9

Is converted to:

| alpha | beta | gamma |  
|:-----:|:----:|:-----:|  
|   1   |  23  |   45  |  
|   7   |  8   |   9   |  
  • or converts a Markdown outline containing the cursor to a nested MMD table.
# Three Sections
- Section One
	- 1
	- 4
	- 9
- Section Two
	- 16
	- 25
	- 36
- Section Three
	- 49
	- 64
	- 81

Is converted to:

|              Three Sections             |||||||||  
|:---:|:--:|:--:|:---:|:--:|:--:|:---:|:---:|:---:|  
| Section One ||| Section Two ||| Section Three |||  
|  1  | 4  | 9  |  16 | 25 | 36 |  49 |  64 |  81 |  

Convert (nested or flat) table to outline

  • Reverses the kind of outline → nested table conversion above (gives an automatic table → outline conversion)

Place the cursor anywhere in a simple MD outline or a nested MMD table, and run one of these Keyboard Maestro macros.

The → Table script can also be used to pretty-print or complete a partially specified MMD table (nested - with some parent cells spanning child cells - or flat/tabular)

The → Outline script translates the nesting structure of the selected MMD table to an outline combining hash headings with tab-indented lists.

Example of a source outline and a table generated from that outline (previewed in Marked):

NestedTablePreview

The outline and the MMD table text version in FoldingText:

OutlineAndMMDTable



FoldingText Extensions Wiki
Org mode style tables
#2

When I try this macro on the example above, I get

[alpha|beta|gamma
1|23|45
7|8|9]()

Has anyone else been able to get this to work?


#3

Consider TableFlip