Paste ASCII Table

by Antonin
5
4
3
2
1
Score: 50/100

Description

Obsidian plugin that turns box-drawing / ASCII art tables into real Markdown tables the moment you paste them.

Reviews

No reviews yet.

Stats

0
stars
100
downloads
0
forks
52
days
6
days
6
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
3
commits

Latest Version

6 days ago

Changelog

Adds support for space-aligned tables, the ones pandoc and document converters write, where a ruler of dash runs is the only structure and there is no delimiter anywhere:

 -------------------------------- -------------------- --------- 
  Group                            Subgroup             Members  
 -------------------------------- -------------------- --------- 
  Alpha (#101)                     Team one (#9001)     250      
 -------------------------------- -------------------- --------- 

Columns are cut at the offsets the ruler declares. The header may sit between two rulers or above its only one, rulers may be - or =, and a row may be one line or several lines separated by a blank line, which covers pandoc's simple and multiline tables. Cells the renderer wrapped are rejoined as before, and alignment is still inferred from the padding.

Output aligned by spaces with no ruler at all (kubectl get pods, ls -l) is left untouched on purpose: the ruler is the only thing that tells a table from a paragraph that happens to line up.

Also in this release: Convert ASCII table (selection or table at cursor) now takes the block bounds from the converter instead of guessing them from the lines around the cursor, so a table containing a blank line converts whole.

Install manually by copying main.js and manifest.json into <vault>/.obsidian/plugins/paste-ascii-table/.

README file from

Github

Paste ASCII Table

Obsidian plugin that turns box-drawing / ASCII art tables into real Markdown tables the moment you paste them.

Paste this (terminal output, Claude Code, mysql, psql, rich, comfy-table, tabulate, ...):

┌──────────────────────────────┬───────────────────────────────────────────────┐
│            Route             │                     Notes                     │
├──────────────────────────────┼───────────────────────────────────────────────┤
│ GET /email-deliveries        │ paginated list; search + search_scope, types, │
│                              │  statuses, engagement, export file name       │
├──────────────────────────────┼───────────────────────────────────────────────┤
│ GET /email-deliveries/types  │ types present in the caller's scope           │
└──────────────────────────────┴───────────────────────────────────────────────┘

and get this in the note:

| Route | Notes |
| --- | --- |
| GET /email-deliveries | paginated list; search + search_scope, types, statuses, engagement, export file name |
| GET /email-deliveries/types | types present in the caller's scope |

Space-aligned tables, the ones pandoc and document converters write, work the same way:

 -------------------------------- -------------------- --------- 
  Group                            Subgroup             Members  
 -------------------------------- -------------------- --------- 
  Alpha (#101)                     Team one (#9001)     250      
  The longest placeholder (#102)   Team two (#9002)     169      
 -------------------------------- -------------------- --------- 
| Group | Subgroup | Members |
| --- | --- | --- |
| Alpha (#101) | Team one (#9001) | 250 |
| The longest placeholder (#102) | Team two (#9002) | 169 |

Install

No build step, the plugin is plain JavaScript.

./install.sh ~/path/to/vault

Then in Obsidian: Settings, Community plugins, Installed plugins, enable Paste ASCII Table. If it does not show up, use the reload icon next to Installed plugins, Obsidian only scans the plugins folder at startup.

What it handles

  • Unicode box drawing in light, heavy, double and rounded variants, plus +---+ ASCII borders and border-less psql output.
  • Space-aligned tables with no delimiter at all, where a ruler of dash runs (---- ------- ---) is the only structure. Columns are cut at the offsets the ruler declares. The header may sit between two rulers or above the only one, and rows may be single lines or several lines separated by a blank line, which covers pandoc's simple and multiline tables.
  • Cells the terminal wrapped over several lines are rejoined into one Markdown cell. This is the whole reason the plugin exists, a naive find-and-replace leaves you with half sentences in phantom rows.
  • Tables with a separator between every row, and tables with only a header separator.
  • Leading indentation (terminal output is often indented) is removed.
  • ANSI colour codes are stripped.
  • Prose before, between and after tables is preserved, and several tables in one paste are all converted.
  • Column alignment is inferred from the cell padding and written into the separator row.
  • A literal | inside a cell is escaped so it cannot break the table.
  • Existing Markdown tables and ordinary prose are left untouched, so normal pasting is unaffected.

Commands

Both work on text already in a note:

  • Convert ASCII table (selection or table at cursor) converts the selection, or the table block the cursor sits in.
  • Convert all ASCII tables in this note sweeps the whole note.

Settings

Setting Default What it does
Convert on paste on Turn off to use only the commands.
Wrapped cell handling Smart Smart rebuilds the original sentence, Always join with a space never glues words together, Keep the line break as <br> preserves genuinely multi-line cells.
Escape pipes on Escapes | characters found inside cells.
Detect column alignment on Writes ---: / :---: when the padding shows the column was right aligned or centred.
Pad columns off Aligns the pipes in the produced Markdown. Off keeps wide tables readable.

Known limits

The first three belong to delimited tables and come from one design choice: their columns are found by counting delimiters per line rather than by taking the delimiter offsets from the border, the way a space-aligned table takes its columns from the ruler. Reading the geometry off the border would lift all three.

  • A two column border-less table (a | b under a ---+--- rule) is not detected, because one | per line is counted the same as prose. Three or more columns work, as does any table with outer borders.

  • A cell containing | in a +---+ style table is mangled: | is both delimiter and content there, so the row is read as having extra columns and the table is split in two. Box-drawing tables are unaffected, a | in their cells stays content.

  • When a table has no row separators, a wrapped row is recognised by the cells that fall blank on the continuation line. A wrap where every column continues at once is read as a new row.

  • Output aligned by spaces alone, with no ruler (kubectl get pods, ls -l, df -h), is left as it is. The ruler is the only thing that separates a table from a paragraph that happens to line up, and guessing the columns from the runs of spaces would convert prose by accident.

Tests

The converter is pure JavaScript with no Obsidian dependency, so it runs under plain node:

npm test