markdown option for creating new comics

This commit is contained in:
mi
2025-11-12 11:23:05 +10:00
parent 8abb185c02
commit bf8ed23bc4
2 changed files with 48 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ Script to add a new comic entry to comics_data.py with reasonable defaults
"""
import sys
import os
import argparse
from datetime import datetime
# Add parent directory to path so we can import comics_data
@@ -11,8 +12,46 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from comics_data import COMICS
def create_markdown_file(date_str, parent_dir):
"""Create a markdown file for author notes"""
author_notes_dir = os.path.join(parent_dir, 'content', 'author_notes')
# Create directory if it doesn't exist
os.makedirs(author_notes_dir, exist_ok=True)
markdown_file = os.path.join(author_notes_dir, f'{date_str}.md')
# Check if file already exists
if os.path.exists(markdown_file):
print(f"Warning: Markdown file already exists: {markdown_file}")
return markdown_file
# Create file with template content
template = f"""# Author Note
Write your author note here using markdown formatting.
**Example formatting:**
- *Italic text*
- **Bold text**
- [Links](https://example.com)
- `Code snippets`
"""
with open(markdown_file, 'w') as f:
f.write(template)
print(f"Created markdown file: {markdown_file}")
return markdown_file
def main():
"""Add a new comic entry with defaults"""
parser = argparse.ArgumentParser(description='Add a new comic entry to comics_data.py')
parser.add_argument('-m', '--markdown', action='store_true',
help='Generate a markdown file for author notes')
args = parser.parse_args()
# Get next number
number = max(comic['number'] for comic in COMICS) + 1 if COMICS else 1
@@ -51,6 +90,10 @@ def main():
print(f"Added comic #{number}")
# Create markdown file if requested
if args.markdown:
create_markdown_file(comic['date'], parent_dir)
if __name__ == '__main__':
main()