Skip to content

feat: add support for footnotes in markdown parsing#74

Open
akoso wants to merge 2 commits intotryfabric:masterfrom
trilogy-group:support-footnotes
Open

feat: add support for footnotes in markdown parsing#74
akoso wants to merge 2 commits intotryfabric:masterfrom
trilogy-group:support-footnotes

Conversation

@akoso
Copy link
Contributor

@akoso akoso commented Jun 12, 2025

This commit introduces the ability to parse footnotes in markdown content. It includes updates to the parsing logic to handle footnote references and definitions, as well as corresponding tests to ensure functionality. Additionally, the package dependencies have been updated to include remark-footnotes for enhanced markdown processing.

Example

Input:

"Some random text with a reference[^1].  \nAnd with another[^2] one.\n\n[^1]: https://github.com/tryfabric/martian/pull/74\n[^2]: https://www.google.com/"

Output:

[
  {
    object: "block",
    type: "paragraph",
    paragraph: {
      rich_text: [
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "Some random text with a reference",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "[1]",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: ".",
            link: undefined,
          },
        },
      ],
    },
  },
  {
    object: "block",
    type: "paragraph",
    paragraph: {
      rich_text: [
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "And with another",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "[2]",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: " one.",
            link: undefined,
          },
        },
      ],
    },
  },
  {
    object: "block",
    type: "paragraph",
    paragraph: {
      rich_text: [
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "1. ",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "https://github.com/tryfabric/martian/pull/74",
            link: {
              type: "url",
              url: "https://github.com/tryfabric/martian/pull/74",
            },
          },
        },
      ],
    },
  },
  {
    object: "block",
    type: "paragraph",
    paragraph: {
      rich_text: [
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "2. ",
            link: undefined,
          },
        },
        {
          type: "text",
          annotations: {
            bold: false,
            strikethrough: false,
            underline: false,
            italic: false,
            code: false,
            color: "default",
          },
          text: {
            content: "https://www.google.com/",
            link: {
              type: "url",
              url: "https://www.google.com/",
            },
          },
        },
      ],
    },
  },
]

And in Notion:
image

akoso added 2 commits June 12, 2025 10:55
This commit introduces the ability to parse footnotes in markdown content. It includes updates to the parsing logic to handle footnote references and definitions, as well as corresponding tests to ensure functionality. Additionally, the package dependencies have been updated to include `remark-footnotes` for enhanced markdown processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments