""" Citation Tools for Academic Writing This script provides utilities for managing citations in academic writing: 1. Extract citation keys from Markdown files and create a filtered bibliography 2. Copy cited reference files to a specified directory for backup or sharing Typical usage: python citation-tools.py --extract python citation-tools.py --copy Copyright: © 2025–Present Tom Ben License: MIT License """ import os import re import shutil import argparse import json from pathlib import Path def extract_citation_keys(markdown_file): """Extract citation keys from a markdown file.""" with open(markdown_file, 'r', encoding='utf-8') as f: content = f.read() # Pattern 1: [@key] or [@key1; @key2] format pattern1 = r'\[@([a-zA-Z0-9\-]+)(?:[\s\]\;\,]|$)' # Pattern 2: standalone @key format pattern2 = r'(?