I'll create a simple local site with HTML/CSS/JS frontend and Python backend that manages Markdown tables. Here's a streamlined solution:
index.html
<!DOCTYPE html>
<html>
<head>
<title>Markdown Table Manager</title>
<style>
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 #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.table-container {
margin-bottom: 30px;
border: 1px solid #eee;
padding: 15px;
border-radius: 5px;
}
.table-title {
margin-top: 0;
}
button {
padding: 5px 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
border-radius: 3px;
}
button:hover {
background-color: #45a049;
}
.copy-btn {
background-color: #2196F3;
margin-top: 10px;
}
.add-table-btn {
background-color: #ff9800;
margin-top: 20px;
padding: 8px 16px;
}
input[type="text"] {
padding: 5px;
width: 70%;
}
.done-cell {
text-align: center;
}
</style>
</head>
<body>
<h1>Markdown Table Manager</h1>
<div id="tables-container"></div>
<button id="add-table-btn" class="add-table-btn">+ Add New Table</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
loadTables();
document.getElementById('add-table-btn').addEventListener('click', function() {
const title = prompt('Enter table title:');
if (title) {
fetch('/add-table', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({title: title})
})
.then(response => response.json())
.then(data => {
if (data.success) loadTables();
});
}
});
});
function loadTables() {
fetch('/get-tables')
.then(response => response.json())
.then(data => {
const container = document.getElementById('tables-container');
container.innerHTML = '';
data.tables.forEach(table => {
const tableDiv = document.createElement('div');
tableDiv.className = 'table-container';
const tableHtml = `
<h2 class="table-title">${table.title}</h2>
<table data-title="${table.title}">
<thead>
<tr>
<th>Task Name</th>
<th>Done</th>
</tr>
</thead>
<tbody>
${table.rows.map(row => `
<tr>
<td>${row.task}</td>
<td class="done-cell">${row.done ? '✅' : '⬜'}</td>
</tr>
`).join('')}
<tr>
<td><input type="text" placeholder="New task name"></td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td colspan="2">
<button class="add-row-btn">+ ADD</button>
</td>
</tr>
</tbody>
</table>
<button class="copy-btn">Copy as Markdown</button>
`;
tableDiv.innerHTML = tableHtml;
container.appendChild(tableDiv);
// Add event listeners
const addRowBtn = tableDiv.querySelector('.add-row-btn');
addRowBtn.addEventListener('click', function() {
const tableElement = this.closest('table');
const title = tableElement.dataset.title;
const taskInput = tableElement.querySelector('input[type="text"]');
const doneCheckbox = tableElement.querySelector('input[type="checkbox"]');
if (taskInput.value.trim()) {
fetch('/add-row', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
title: title,
task: taskInput.value,
done: doneCheckbox.checked
})
})
.then(response => response.json())
.then(data => {
if (data.success) loadTables();
});
}
});
const copyBtn = tableDiv.querySelector('.copy-btn');
copyBtn.addEventListener('click', function() {
const title = this.previousElementSibling.dataset.title;
fetch(`/get-markdown?title=${encodeURIComponent(title)}`)
.then(response => response.text())
.then(markdown => {
navigator.clipboard.writeText(markdown);
alert('Table copied to clipboard as Markdown!');
});
});
});
});
}
</script>
</body>
</html>
server.py
import http.server
import socketserver
import json
import os
import re
from urllib.parse import parse_qs, urlparse
# Configuration
PORT = 8000
MD_FILE = "tables.md"
# Create the MD file if it doesn't exist
if not os.path.exists(MD_FILE):
with open(MD_FILE, "w") as f:
f.write("## Sample Table\n\n| Task Name | Done |\n|----------|------|\n| Example task | ⬜ |\n")
class TableHandler(http.server.SimpleHTTPRequestHandler):
def _set_headers(self, content_type="text/html"):
self.send_response(200)
self.send_header('Content-type', content_type)
self.end_headers()
def _parse_md_tables(self):
with open(MD_FILE, "r") as f:
content = f.read()
tables = []
# Find all table sections
table_sections = re.findall(r'## (.+?)\n\n\| .+?\n\|.+?\n((?:\|.+?\n)+)', content, re.DOTALL)
for title, rows_text in table_sections:
rows = []
# Skip header and separator rows
row_lines = rows_text.strip().split('\n')[2:]
for line in row_lines:
if '|' in line:
cells = [cell.strip() for cell in line.split('|')[1:-1]]
if len(cells) >= 2:
rows.append({
"task": cells[0],
"done": cells[1] == "✅"
})
tables.append({
"title": title,
"rows": rows
})
return tables
def _save_tables(self, tables):
content = ""
for table in tables:
content += f"## {table['title']}\n\n"
content += "| Task Name | Done |\n|----------|------|\n"
for row in table['rows']:
done_mark = "✅" if row['done'] else "⬜"
content += f"| {row['task']} | {done_mark} |\n"
content += "\n"
with open(MD_FILE, "w") as f:
f.write(content)
def _get_table_markdown(self, title):
tables = self._parse_md_tables()
for table in tables:
if table['title'] == title:
md = f"## {title}\n\n"
md += "| Task Name | Done |\n|----------|------|\n"
for row in table['rows']:
done_mark = "✅" if row['done'] else "⬜"
md += f"| {row['task']} | {done_mark} |\n"
return md
return ""
def do_GET(self):
parsed_path = urlparse(self.path)
path = parsed_path.path
if path == "/get-tables":
tables = self._parse_md_tables()
self._set_headers("application/json")
self.wfile.write(json.dumps({"tables": tables}).encode())
return
elif path == "/get-markdown":
query = parse_qs(parsed_path.query)
if 'title' in query:
title = query['title'][0]
markdown = self._get_table_markdown(title)
self._set_headers("text/plain")
self.wfile.write(markdown.encode())
return
# Serve static files
return super().do_GET()
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length).decode('utf-8')
data = json.loads(post_data)
if self.path == "/add-table":
title = data.get('title', '').strip()
if title:
tables = self._parse_md_tables()
# Check if table with this title already exists
if not any(t['title'] == title for t in tables):
tables.append({
"title": title,
"rows": []
})
self._save_tables(tables)
self._set_headers("application/json")
self.wfile.write(json.dumps({"success": True}).encode())
return
elif self.path == "/add-row":
title = data.get('title', '').strip()
task = data.get('task', '').strip()
done = data.get('done', False)
if title and task:
tables = self._parse_md_tables()
for table in tables:
if table['title'] == title:
table['rows'].append({
"task": task,
"done": done
})
self._save_tables(tables)
self._set_headers("application/json")
self.wfile.write(json.dumps({"success": True}).encode())
return
self.send_response(400)
self.end_headers()
self.wfile.write(json.dumps({"success": False, "error": "Invalid request"}).encode())
# Start the server
with socketserver.TCPServer(("", PORT), TableHandler) as httpd:
print(f"Server running at http://localhost:{PORT}")
httpd.serve_forever()
How to use:
- Save both files in the same directory
- Run the Python server:
python server.py
- Open your browser and go to:
http://localhost:8000
Features:
- View all tables from the Markdown file
- Add new tables with custom titles
- Add new rows to existing tables with task names and done/not done status
- Copy any table as Markdown to clipboard
- All changes are saved to a single Markdown file (tables.md)
- "+ ADD" button in each table for adding new rows
- Simple, clean UI with no external dependencies
The server parses the Markdown file to extract tables and their contents, and the frontend displays them in an editable format. When you make changes, they're saved back to the Markdown file.
Would you like me to explain any specific part of the implementation?