Here's a simple local web application using HTML , CSS , and Python (with no external dependencies) that meets your requirements. It supports:
Creating and managing Markdown tables .
Adding tasks with a "Done" checkbox .
A "Copy as Markdown" button for each table.
Adding new tables and saving all data in a single .md file.
A "+ ADD" button in the "future" row for dynamic task addition.
📁 File Structure
code Copy code
markdown-table-editor/
├── index.html
├── styles.css
├── script.js
├── server.py
└── data.md
🧩 1. index.html (Frontend)
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Markdown Task Tables</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Markdown Task Tables</h1>
<div id="tables-container"></div>
<button id="add-table">+ ADD TABLE</button>
<script src="script.js"></script>
</body>
</html>
🎨 2. styles.css (Styling)
css Copy code
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
th {
background-color: #f5f5f5;
}
input[type="text"] {
width: 90%;
padding: 5px;
margin: 5px 0;
}
button {
padding: 8px 12px;
margin: 5px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.add-row-btn {
background-color: #4CAF50;
color: white;
}
.copy-btn {
background-color: #2196F3;
color: white;
}
.add-table-btn {
background-color: #FF9800;
color: white;
}
🧠 3. script.js (JavaScript Logic)
javascript Copy code
document.addEventListener("DOMContentLoaded", () => {
const container = document.getElementById("tables-container");
const addTableBtn = document.getElementById("add-table");
// Load and render tables
async function loadTables() {
const response = await fetch("/get-markdown");
const markdown = await response.text();
container.innerHTML = parseMarkdownToHTML(markdown);
}
// Parse markdown into HTML tables
function parseMarkdownToHTML(markdown) {
const lines = markdown.split("\n");
let html = "";
let currentTable = null;
for (let line of lines) {
if (line.startsWith("## ")) {
if (currentTable) {
html += renderTable(currentTable);
}
currentTable = { title: line.slice(3), rows: [] };
} else if (line.startsWith("|")) {
if (currentTable) {
const cells = line
.split("|")
.map(cell => cell.trim())
.filter(cell => cell !== "");
if (cells.length === 2) {
currentTable.rows.push(cells);
}
}
}
}
if (currentTable) {
html += renderTable(currentTable);
}
return html;
}
// Render a single table
function renderTable(table) {
const rows = table.rows.map((cells, index) => {
if (index === 0) {
return `<tr><th>${cells[0]}</th><th>${cells[1]}</th></tr>`;
} else {
const [task, status] = cells;
const checkbox = status === "✅" ? "checked" : "";
return `<tr><td>${task}</td><td><input type="checkbox" ${checkbox}></td></tr>`;
}
});
return `
<h2>${table.title}</h2>
<table>
<thead>${rows[0]}</thead>
<tbody>${rows.slice(1).join("")}</tbody>
</table>
<button class="add-row-btn" onclick="addRow('${table.title}')">+ ADD ROW</button>
<button class="copy-btn" onclick="copyTable('${table.title}')">Copy as Markdown</button>
<hr>
`;
}
// Add a new row to a table
window.addRow = function(tableName) {
fetch("/add-row", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ table: tableName, task: "New Task", done: false }),
}).then(loadTables);
};
// Copy a table as Markdown
window.copyTable = function(tableName) {
fetch(`/get-table?table=${encodeURIComponent(tableName)}`)
.then(res => res.json())
.then(table => {
let md = `## ${table.title}\n| Task | Done |\n|------|------|\n`;
table.rows.forEach(([task, done]) => {
md += `| ${task} | ${done} |\n`;
});
navigator.clipboard.writeText(md).then(() => alert("Copied to clipboard!"));
});
};
// Add a new table
addTableBtn.addEventListener("click", () => {
const title = prompt("Enter table title:");
if (title) {
fetch("/add-table", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ title: title }),
}).then(loadTables);
}
});
loadTables();
});
🐍 4. server.py (Python Backend)
📄 5. data.md (Initial Markdown File)
markdown Copy code
## My First Table
| Task | Done |
|------|------|
| Task 1 | ⬜ |
| Task 2 | ✅ |
✅ How to Use
Save all files in a folder.
Run python server.py in the folder.
Open http://localhost:8000 in your browser.
Add tables, tasks, and use the "Copy as Markdown" button.
🔒 Notes
This is for local use only . Do not expose it to the internet.
No external dependencies. Uses only Python's standard libraries.
Markdown parsing is basic and assumes a simple format.