markdown-it / markdown-it-footnote

Footnotes plugin for markdown-it markdown parser
https://markdown-it.github.io/
MIT License
212 stars 59 forks source link

Foot notes appear repeated #53

Open rliberoff opened 4 months ago

rliberoff commented 4 months ago

Hello!

I'm using the latest version, and for the following markdown:

The key to succeeding in Asia-Pacific is to strongly engage with Chinese passengers both domestically in China and internationally in neighboring countries such as Thailand, South Korea, and Japan. 
The company already has a solid footprint in this area and plans to further expand in existing and new locations.^[https://stkaitorag7d628.blob.core.windows.net/user-documents/user-documents/r_oyorimfisd/Internal.pdf?sv=2024-05-04&se=2024-07-19T11%3A53%3A56Z&sr=b&sp=r&sig=v3wZ%2FmS8pdn%2BDyEORunEROP6IubKgIxSrmieb5gWfdM%3D]

I'm getting the following render:

<p>
    The key to succeed in Asia-Pacific is to strongly engage with Chinese passengers domestically in China and when they travel internationally to neighboring countries such as Thailand, South Korea and Japan. The company already has a solid footprint in
    this geographic area and plans to further expand in existing and new locations.<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>
</p>
<hr class="footnotes-sep" />
<section class="footnotes">
    <ol class="footnotes-list">
        <li id="fn1" class="footnote-item">
            <p>
                https://stkaitorag7d628.blob.core.windows.net/user-documents/user-documents/r_f16m2hh9sm/Indernal.pdf?sv=2024-05-04&amp;se=2024-07-19T12%3A00%3A51Z&amp;sr=b&amp;sp=r&amp;sig=6DZ9SG10Ee4NDn7yS2aUbwZdWNyZOfBakhy3%2F8ly0qo%3D
                <a href="#fnref1" class="footnote-backref">↩︎</a>
            </p>
        </li>
        <li id="fn2" class="footnote-item">
            <p>
                https://stkaitorag7d628.blob.core.windows.net/user-documents/user-documents/r_f16m2hh9sm/Indernal.pdf?sv=2024-05-04&amp;se=2024-07-19T12%3A00%3A51Z&amp;sr=b&amp;sp=r&amp;sig=6DZ9SG10Ee4NDn7yS2aUbwZdWNyZOfBakhy3%2F8ly0qo%3D
                <a href="#fnref2" class="footnote-backref">↩︎</a>
            </p>
        </li>
    </ol>
</section>

As you can see... I'm getting the footnotes repeated. The expected behavior is just one footnote with the correct number.

This is the code in Javascript:

```html
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/markdown-it@14.1.0/dist/markdown-it.min.js"></script>
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/markdown-it-for-inline@2.0.1/dist/markdown-it-for-inline.min.js"></script>
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/markdown-it-footnote@4.0.0/dist/markdown-it-footnote.min.js"></script>
<script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>

//...

<script>
    (async function () {
    // ...
     const iterarator = markdownitForInline;

     const markdownIt = window.markdownit()
                          .use(markdownitFootnote)
                          .use(iterarator, 'url_new_win', 'link_open', function (tokens, idx) {
                              let aIndex = tokens[idx].attrIndex('target');

                              if (aIndex < 0) {
                                  tokens[idx].attrPush(['target', '_blank']);
                              } else {
                                  tokens[idx].attrs[aIndex][1] = '_blank';
                              }
                          })
                          ;
    //...    
})().catch(err => console.error(err));
</script>

Please help!

BSOFH commented 3 months ago

At best, I confirm this problem. Initial build is fine, any updates to footnote containing markdown files are corrupted. This shouldn't effect production builds of a site as long as EleventyDevServe is not involved. Since it's a EleventyDevServe issue, one work around is just to open another terminal tab and run the build as needed (without --serve of course) and reload the browser.

I'll be back if I find the bug. Thanks for a wonderful plugin.

My dependencies:

    "dependencies": {
        "@11ty/eleventy": "^2.0.1",
        "@11ty/eleventy-img": "^3.1.1",
        "@11ty/eleventy-plugin-bundle": "^1.0.4",
        "@11ty/eleventy-plugin-rss": "^1.2.0",
        "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
        "eleventy-plugin-reading-time": "^0.0.1",
        "eleventy-plugin-wordcount-extended": "^0.2.1",
        "http-server": "^14.1.1", // installed for this bug
        "luxon": "^3.3.0",
        "markdown-it": "^13.0.2",
        "markdown-it-abbr": "^2.0.0",
        "markdown-it-anchor": "^8.6.7",
        "markdown-it-attrs": "^4.1.6",
        "markdown-it-bracketed-spans": "^1.0.1",
        "markdown-it-container": "^4.0.0",
        "markdown-it-deflist": "^3.0.0",
        "markdown-it-emoji": "^3.0.0",
        "markdown-it-footnote": "^4.0.0",
        "markdown-it-for-inline": "^2.0.1",
        "markdown-it-ins": "^4.0.0",
        "markdown-it-mark": "^4.0.0",
        "markdown-it-multimd-table": "^4.2.3",
        "markdown-it-sub": "^2.0.0",
        "markdown-it-sup": "^2.0.0",
        "markdown-it-task-lists": "^2.1.1",
        "npm-run-all": "^4.1.5",
        "rimraf": "^6.0.1"
    }

Screenshot 2024-07-24 at 08-31-01 Markdown Test