from typing import Optional
import re


def parse_task(content: str) -> tuple[str, Optional[str]]:
    """Removes unneeded markdown and finds a due date, if present
    
    If a due date is returned, it is in the format YYYY-MM-DD.
    """
    if content.startswith('*'):
        content = content.lstrip('*').strip()
    elif content.startswith('- [ ]'):
        content = content.lstrip('- [ ]').strip()
    elif content.startswith('-'):
        content = content.lstrip('-').strip()

    due_date = None
    match = re.search(r'\[\d{6}\]$', content)
    if match:
        due_date = match[0].lstrip('[').rstrip(']')
        due_date = f'20{due_date[:2]}-{due_date[2:4]}-{due_date[4:]}'
        content = content.removesuffix(match[0]).strip()
    
    return content, due_date