gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
31.68k stars 2.36k forks source link

Support Markdown footnotes #7880

Open OnionKiller opened 4 months ago

OnionKiller commented 4 months ago

I am trying to use footnotes in Markdown to have references to sources. It looks like, that the current version of Gradio doesn't supports this extra Markdown feature.

The footnote support could make the creation of big blocks of text with references more beautiful[^1].

Describe the solution you'd like
The footnote implementation looks failry easy, as marked already has an extension for footnote support: as mentioned here, marked will not implement it, but this extension

Additional context
The reason why marked didn't implemented it, is UX conserns, and accessibility issues. This may applie here as well, and possibly needs consideration as well.

[^1]: Hopefully someting similar like this.

OnionKiller commented 4 months ago

If implemented permanently, then the following implementation would be possible in js/markdown/shared/utils.ts:

import { type Renderer, Marked } from "marked";
import { footnote } from '@marked-extensions/footnote';
...
const marked = new Marked([footnote]);

    marked.use(
        {
            gfm: true,
            pedantic: false,
            breaks: line_breaks
        },