CSV Codeblock
approvedby elrindir
Render code blocks with CSV format.
★ 12 stars↓ 5,321 downloadsUpdated 1y agoMIT
CSV Codeblock
This is a plugin for Obsidian (https://obsidian.md). This plugin renders codeblocks with csv format as tables.
Usage
Just put the csv identifyer in a codeblock:
```csv
Pos, Date, Name, Price
1, 2023-09-28, Spices, 150$
2, 2023-02-29, Shovel, 1.25$
```

Stolen Code
I stole the code from https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing#Post-process+Markdown+code+blocks
import { Plugin } from "obsidian";
export default class ExamplePlugin extends Plugin {
async onload() {
this.registerMarkdownCodeBlockProcessor("csv", (source, el, ctx) => {
const rows = source.split("\n").filter((row) => row.length > 0);
const table = el.createEl("table");
const body = table.createEl("tbody");
for (let i = 0; i < rows.length; i++) {
const cols = rows[i].split(",");
const row = body.createEl("tr");
for (let j = 0; j < cols.length; j++) {
row.createEl("td", { text: cols[j] });
}
}
});
}
}
Changelog
v1.1 Added TSV Support
on Jul 18, 2024
Now supports tsv in codeblocks. Thanks mklepaczewski for the request.
v1.0 Initial Release
on Sep 28, 2023
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.