Open edoardob90 opened 2 days ago
One way to fix it during import is a function like:
def convert_inline_superscripts_to_markdown(text):
# Map superscripts
superscript_map = {
"¹": "1", "²": "2", "³": "3", "⁴": "4", "⁵": "5",
"⁶": "6", "⁷": "7", "⁸": "8", "⁹": "9", "⁰": "0"
}
# Pattern to match footnote anchors and footnote bodies
anchor_pattern = re.compile(r"([¹²³⁴⁵⁶⁷⁸⁹⁰])")
body_pattern = re.compile(r"([¹²³⁴⁵⁶⁷⁸⁹⁰])\s+(.+?)(?=\s[¹²³⁴⁵⁶⁷⁸⁹⁰]|$)")
markdown_footnotes = {}
# Find and replace footnote bodies
def replace_body(match):
sup = match.group(1)
normal_digit = superscript_map[sup]
footnote_text = match.group(2).strip()
markdown_footnotes[normal_digit] = footnote_text
return "" # Remove the inline footnote body
# Process footnote bodies first
text = re.sub(body_pattern, replace_body, text)
# Replace superscript anchors in text
def replace_anchor(match):
sup = match.group(1)
normal_digit = superscript_map[sup]
return f"[^{normal_digit}]"
text = re.sub(anchor_pattern, replace_anchor, text)
print(markdown_footnotes)
# Append footnote definitions in Markdown format
for number, body in sorted(markdown_footnotes.items(), key=lambda x: int(x[0])):
text += f"\n[^{number}]: {body}"
return text
Day One doesn't support footnotes. They are replaced with superscript numbers, while the content of the footnote remains at the bottom.
A valid Markdown file like:
Get exported as: