diff --git a/.gitignore b/.gitignore index 611d8ac..060c24a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ bin coverage.html **/dist plugins/tabula.obsidian +demo/demo.gif +demo/input.csv diff --git a/Justfile b/Justfile index e8c69ae..e3b4b30 100644 --- a/Justfile +++ b/Justfile @@ -90,6 +90,14 @@ vscode-pack: cd plugins/tabula.vscode npm run package +demo: + cd demo && vhs demo.tape + cp demo.gif ./gh-pages/ + cp demo.gif ./plugins/tabula.vim/ + cp demo.gif ./plugins/tabula.vscode/ + cp demo.gif ./plugins/tabula.obsidian/ + cp demo.gif ./plugins/tabula.webstorm/ + # Vim vim-pack: #!/bin/sh diff --git a/README.md b/README.md index eaddc16..93c6d50 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ # ![Tabula](./gh-pages/icon.png) Tabula - Spreadsheet-Inspired CSV Transformation +![Tabula: save a CSV, formulas recompute in place](./demo.gif) + **Transform CSV files using familiar spreadsheet formulas from the command line.** ## 🎯 What is **Tabula**? diff --git a/VERSION.txt b/VERSION.txt index 58e72da..cd44e25 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.2.21 \ No newline at end of file +0.2.22 \ No newline at end of file diff --git a/cmd/cli/version.go b/cmd/cli/version.go index 2cf2fed..1ea6072 100644 --- a/cmd/cli/version.go +++ b/cmd/cli/version.go @@ -1,3 +1,3 @@ package main -const VERSION = "0.2.21" +const VERSION = "0.2.22" diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..a5f77d3 Binary files /dev/null and b/demo.gif differ diff --git a/demo/demo.tape b/demo/demo.tape new file mode 100644 index 0000000..8f6b490 --- /dev/null +++ b/demo/demo.tape @@ -0,0 +1,41 @@ +# Install VHS: +# brew install vhs + +Output ../demo.gif + +Require tabula + +Set Theme "GruvboxDark" +Set FontSize 22 +Set FontFamily "FiraCode Nerd Font Mono" +Set Width 860 +Set Height 480 +Set Padding 24 +Set TypingSpeed 55ms +Set PlaybackSpeed 1.0 +Set Shell "bash" + +# Reset demo state silently before we start recording visible frames +Hide +Type "cp input.template.csv input.csv && nvim input.csv" +Enter +Sleep 300ms +Show + +# Recording +Sleep 1800ms +Type 'ggg^fs' +Sleep 400ms +Type 'gf' +Sleep 1800ms +Ctrl+o +Sleep 400ms +Type 'g^jjj' +Sleep 1800ms +Type 'f1cw22' +Escape +Sleep 1800ms +Type 'kcw3' +Escape +Type ' fs' +Sleep 2800ms diff --git a/demo/input.template.csv b/demo/input.template.csv new file mode 100644 index 0000000..bf7cf0a --- /dev/null +++ b/demo/input.template.csv @@ -0,0 +1,6 @@ +#tabula #include "script.tbl" +Product , Price , Quantity , Total +Apple , $1.20 , 10 , $12.00 +Banana , $0.80 , 17 , $13.60 +Pear , $2.50 , 8 , $20.00 +TOTAL , , , $45.60 diff --git a/demo/script.tbl b/demo/script.tbl new file mode 100644 index 0000000..e10e15e --- /dev/null +++ b/demo/script.tbl @@ -0,0 +1,3 @@ +fmt B2:B4,D2:D4,D5 = "$%.2f"; +let D2:D4 = REF(REL(-2,0)) * REF(REL(-1,0)); +let D5 = SUM(D2:D4); diff --git a/gh-pages/demo.gif b/gh-pages/demo.gif new file mode 100644 index 0000000..a5f77d3 Binary files /dev/null and b/gh-pages/demo.gif differ diff --git a/gh-pages/index.html b/gh-pages/index.html index d6b97fc..50cad31 100644 --- a/gh-pages/index.html +++ b/gh-pages/index.html @@ -3,7 +3,93 @@ - Tabula - CSV Spreadsheet Language + + Tabula - CSV Spreadsheet Language | Transform CSV with Formulas + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,6 +210,12 @@

/>Tabula - CSV Spreadsheet Language

+ Tabula: save a CSV, formulas recompute in place +

What is Tabula?

Tabula is a command-line tool that lets you transform and manipulate CSV diff --git a/plugins/tabula.vim/README.md b/plugins/tabula.vim/README.md index 80485d5..0560dd2 100644 --- a/plugins/tabula.vim/README.md +++ b/plugins/tabula.vim/README.md @@ -2,6 +2,8 @@ # ![Tabula](./icon.png) Tabula for Vim / Neovim +![Tabula: save a CSV, formulas recompute in place](./demo.gif) + Vim/Neovim plugin for [Tabula](https://github.com/pblazh/tabula) - a spreadsheet-inspired CSV transformation tool. ## Features diff --git a/plugins/tabula.vim/demo.gif b/plugins/tabula.vim/demo.gif new file mode 100644 index 0000000..a5f77d3 Binary files /dev/null and b/plugins/tabula.vim/demo.gif differ diff --git a/plugins/tabula.vscode/README.md b/plugins/tabula.vscode/README.md index f151016..5bbde41 100644 --- a/plugins/tabula.vscode/README.md +++ b/plugins/tabula.vscode/README.md @@ -1,6 +1,9 @@ # ![Tabula](./icon.png) Tabula for Visual Studio Code +![Tabula: save a CSV, formulas recompute in place](./demo.gif) + VS Code extension for [Tabula](https://github.com/pblazh/tabula) - a spreadsheet-inspired CSV transformation tool. +It adds Google spreadsheet / Excel functionality for CSV and markdown files ## Features @@ -15,12 +18,15 @@ VS Code extension for [Tabula](https://github.com/pblazh/tabula) - a spreadsheet ## Prerequisites - **Tabula CLI** must be installed and in your `$PATH` + Download a suitable for your OS/architecture build from the [tabula web site](https://pblazh.github.io/tabula) + +For example for MacOS M1/M... ```bash # Download from GitHub Pages -curl -LO https://pblazh.github.io/tabula/bin/darwin/arm64/tabula # macOS M1/M2 -chmod +x tabula -sudo mv tabula /usr/local/bin/ +curl -LO https://pblazh.github.io/tabula/bin/darwin/arm64/tabula # fetch +chmod +x tabula # make it executable +sudo mv tabula /usr/local/bin/ # put into path location ``` @@ -28,29 +34,67 @@ Or build from source ## Usage -### Auto-Execution on Save +### Working with Markdown Files -- Open a CSV file in VS Code -- Add **Tabula** script directive: +**Tabula** can also process Markdown files containing tables and CSV blocks, +which makes it useful for note-taking workflows. When the active file is +Markdown, the extension automatically passes the `-m` flag to **Tabula**. -```csv -#tabula #include "process.tbl" -A,B,C -1,2,3 -4,5,6 -``` +Supported data blocks: + +- **Markdown tables** - standard pipe-delimited syntax with header and separator rows +- **CSV code blocks** - fenced code blocks tagged with `csv` + +There are two ways to attach a **Tabula** script to a data block: -- Create your **Tabula** script (`process.tbl`): +- A `tabula` code block placed immediately after the table or CSV code block: + +````markdown +| A | B | AB | +| -- | -- | -- | +| 10 | 30 | 40 | +| 20 | 40 | 0 | ```tabula -// Calculate sum -let D1 = "Total"; -let D2 = A2 + B2 + C2; -let D3 = A3 + B3 + C3; +let C1 = A1 + B1; +let C2 = A2 + B2; ``` +```` + +- An inline `#tabula` directive inside a CSV block (also supports `#include`): -- Save the CSV file (Ctrl+S / Cmd+S) -- **Tabula** runs automatically and updates the file! +````markdown +```csv +10, 30, 0 +20, 40, 0 +#tabula #include "script.tbl" +``` + + +```` + +Save the Markdown file (Ctrl+S / Cmd+S) and **Tabula** updates the tables in place. +Any errors are written as HTML comments (``) next to the affected +block, so they remain invisible in rendered Markdown and disappear once the +script is fixed. + +See the [Tabula Markdown documentation](https://github.com/pblazh/tabula/blob/main/doc/markdown.md) +for the full specification. + +### Working with CSV Files + +CSV files behave like a Markdown file containing a single data block, with a +few differences: + +- No `-m` flag is passed - the whole file is treated as one table +- Errors are surfaced as VS Code notifications rather than written into the file + +```markdown +#tabula #include "process.tbl" +A,B,C +1,2,3 +4,5,6 +```` ## How It Works @@ -65,7 +109,7 @@ let D3 = A3 + B3 + C3; Access commands via Command Palette (Ctrl+Shift+P / Cmd+Shift+P): - **Tabula: execute** - Manually run Tabula on the active markdown file -- **Tablua: toggle auto-execution: Toggle auto-execution on Save** - Enable/disable automatic execution +- **Tabula: toggle auto-execution: Toggle auto-execution on Save** - Enable/disable automatic execution ### Configuration @@ -175,7 +219,7 @@ npm run compile ## Recommended Companion Extensions -For a better CSV editing experience, do recommend installing a CSV formatting extension: +For a better CSV editing experience, we recommend installing a CSV formatting extension: This extension provides: - 📊 **Table view** - View CSV files in a formatted table @@ -229,3 +273,4 @@ If you find this plugin useful, consider: - ⭐ Starring the [GitHub repository](https://github.com/pblazh/tabula) - 🐛 Reporting issues or suggesting features - 📖 Contributing to the documentation +```` diff --git a/plugins/tabula.vscode/demo.gif b/plugins/tabula.vscode/demo.gif new file mode 100644 index 0000000..a5f77d3 Binary files /dev/null and b/plugins/tabula.vscode/demo.gif differ diff --git a/plugins/tabula.vscode/package.json b/plugins/tabula.vscode/package.json index 2c5c700..21ab180 100644 --- a/plugins/tabula.vscode/package.json +++ b/plugins/tabula.vscode/package.json @@ -1,8 +1,8 @@ { "name": "tabula", - "displayName": "Tabula", - "description": "Tabula - CSV transformation with spreadsheet-inspired scripting language", - "version": "0.2.21", + "displayName": "Tabula — CSV & Markdown Formulas", + "description": "Run spreadsheet-style formulas inside CSV and Markdown files. Recompute on save.", + "version": "0.2.22", "icon": "icon-128.png", "publisher": "tabula", "repository": { @@ -15,16 +15,27 @@ "categories": [ "Data Science", "Formatters", + "Notebooks", "Other" ], "keywords": [ "csv", + "markdown", "tabula", "spreadsheet", - "data" + "formulas", + "datascience", + "tables", + "notes", + "obsidian", + "excel", + "numbers", + "calc", + "notebook" ], "activationEvents": [ - "onLanguage:csv" + "onLanguage:csv", + "onLanguage:markdown" ], "main": "./out/main.js", "contributes": { @@ -79,7 +90,7 @@ "tabula.autoExecution": { "type": "boolean", "default": true, - "description": "Automatically execute Tabula scripts when saving CSV files" + "description": "Automatically execute Tabula scripts when saving CSV or Markdown files" }, "tabula.executablePath": { "type": "string", diff --git a/plugins/tabula.vscode/src/main.test.ts b/plugins/tabula.vscode/src/main.test.ts index c3d8409..e25251c 100644 --- a/plugins/tabula.vscode/src/main.test.ts +++ b/plugins/tabula.vscode/src/main.test.ts @@ -50,7 +50,10 @@ suite('Tabula Extension Tests', () => { const packageJSON = extension!.packageJSON assert.strictEqual(packageJSON.name, 'tabula') - assert.strictEqual(packageJSON.displayName, 'Tabula') + assert.strictEqual( + packageJSON.displayName, + 'Tabula — CSV & Markdown Formulas', + ) assert.ok(packageJSON.version) assert.ok(packageJSON.description) diff --git a/plugins/tabula.webstorm/README.md b/plugins/tabula.webstorm/README.md index db7675a..f2a832f 100644 --- a/plugins/tabula.webstorm/README.md +++ b/plugins/tabula.webstorm/README.md @@ -2,6 +2,8 @@ # ![Tabula](./icon.png) Tabula for Web Storm +![Tabula: save a CSV, formulas recompute in place](./demo.gif) + How to use Tabula with **Web Storm** ## Features @@ -48,6 +50,7 @@ A,B,C 1,2,3 4,5,6 ``` + 1. Create your Tabula script (`process.tbl`): @@ -83,7 +86,7 @@ Set up an auto execution on file save for `*.csv` and `*.md` files. For Markdown - **Numbers**: `42`, `3.14` - **Strings**: `"text"`, `'text'` - **Comments**: `// line comment`, `/* block comment */` -- **Functions**: `EXEC`, `SUM`, `ADD`, `PRODUCT`, `AVERAGE`, `MAX`, `MAXA`, `MIN`, `MINA`, `ABS`, `CEILING`, `FLOOR`, `ROUND`, `POWER`, `INT`, `MOD`, `SQRT`, `CONCATENATE`, `LEN`, `LOWER`, `UPPER`, `TRIM`, `EXACT`, `FIND`, `LEFT`, `RIGHT`, `MID`, `SUBSTITUTE`, `VALUE`, `IF`, `NOT`, `AND`, `OR`, `TRUE`, `FALSE`, `TODATE`, `FROMDATE`, `DAY`, `HOUR`, `MINUTE`, `MONTH`, `SECOND`, `YEAR`, `WEEKDAY`, `NOW`, `DATE`, `DATEDIF`, `DAYS`, `DATEVALUE`, `COUNT`, `COUNTA`, `ISNUMBER`, `ISTEXT`, `ISLOGICAL`, `ISBLANK`, `ADDRESS`, `ROW`, `COLUMN`, `REF`, +- **Functions**: `EXEC`, `SUM`, `ADD`, `PRODUCT`, `AVERAGE`, `MAX`, `MAXA`, `MIN`, `MINA`, `ABS`, `CEILING`, `FLOOR`, `ROUND`, `POWER`, `INT`, `MOD`, `SQRT`, `CONCATENATE`, `LEN`, `LOWER`, `UPPER`, `TRIM`, `EXACT`, `FIND`, `LEFT`, `RIGHT`, `MID`, `SUBSTITUTE`, `VALUE`, `IF`, `NOT`, `AND`, `OR`, `TRUE`, `FALSE`, `TODATE`, `FROMDATE`, `DAY`, `HOUR`, `MINUTE`, `MONTH`, `SECOND`, `YEAR`, `WEEKDAY`, `NOW`, `DATE`, `DATEDIF`, `DAYS`, `DATEVALUE`, `COUNT`, `COUNTA`, `ISNUMBER`, `ISTEXT`, `ISLOGICAL`, `ISBLANK`, `ADDRESS`, `ROW`, `COLUMN`, `REF`, ## Links diff --git a/plugins/tabula.webstorm/demo.gif b/plugins/tabula.webstorm/demo.gif new file mode 100644 index 0000000..a5f77d3 Binary files /dev/null and b/plugins/tabula.webstorm/demo.gif differ