Stardown-app / Stardown

Copy the web as markdown
Apache License 2.0
29 stars 1 forks source link

Some list items are missing in the output #110

Closed wheelercj closed 2 months ago

wheelercj commented 2 months ago

When copying markdown of a list, Stardown sometimes omits some of the list items.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://en.wikipedia.org/wiki/Shanti_Kumar_Morarjee
  2. Select the entire page by pressing Ctrl+A
  3. Press Alt+C
  4. Paste into a text editor
  5. See that in the references section, all but the last list item are missing

When the return value of getSelectionHtml is printed, you can see that it also omits those list items. Below is the entire contents of the references list; notice that it starts at reference 21, the last one.

<ol class="references">
  <li id="cite_note-21">
    <span class="reference-text">
      <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222">
      <cite class="citation book cs1">
        <a rel="nofollow" class="external text" href="https://books.google.com/books?id=o-YGAQAAIAAJ">
          <i>Oceanite</i>
        </a>
        . Maritime Union of India. 1982. p.&nbsp;6
        <span class="reference-accessdate">
          . Retrieved
          <span class="nowrap">
            23 March
          </span>
          2016
        </span>.
      </cite>
      <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Oceanite&amp;rft.pages=6&amp;rft.pub=Maritime+Union+of+India.&amp;rft.date=1982&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Do-YGAQAAIAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee" class="Z3988">
      </span>
    </span>
  </li>
</ol>

The problem is with the selection somehow even though the selection starts before and ends after the list.

Expected behavior All list items should be copied.

Environment

wheelercj commented 2 months ago

Looking through more of the selection's HTML, I found that the references missing from Stardown's output are present in the HTML after all, but they are very different from the last reference. Below is all of the HTML for the entire references list. The last reference is different from the others in that for some reason its data is also wrapped with a few div elements, a main element, many more div elements, another ol element, and another li element.

<div class="mw-heading mw-heading2">
                <h2 id="References">References</h2>
            </div>
        </div>
    </div>
</div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
    .mw-parser-output .reflist {
        margin-bottom: 0.5em;
        list-style-type: decimal
    }

    @media screen {
        .mw-parser-output .reflist {
            font-size: 90%
        }
    }

    .mw-parser-output .reflist .references {
        font-size: 100%;
        margin-bottom: 0;
        list-style-type: inherit
    }

    .mw-parser-output .reflist-columns-2 {
        column-width: 30em
    }

    .mw-parser-output .reflist-columns-3 {
        column-width: 25em
    }

    .mw-parser-output .reflist-columns {
        margin-top: 0.3em
    }

    .mw-parser-output .reflist-columns ol {
        margin-top: 0
    }

    .mw-parser-output .reflist-columns li {
        page-break-inside: avoid;
        break-inside: avoid-column
    }

    .mw-parser-output .reflist-upper-alpha {
        list-style-type: upper-alpha
    }

    .mw-parser-output .reflist-upper-roman {
        list-style-type: upper-roman
    }

    .mw-parser-output .reflist-lower-alpha {
        list-style-type: lower-alpha
    }

    .mw-parser-output .reflist-lower-greek {
        list-style-type: lower-greek
    }

    .mw-parser-output .reflist-lower-roman {
        list-style-type: lower-roman
    }
</style>
<style class="darkreader darkreader--sync" media="screen"></style>
<div class="reflist">
    <div class="mw-references-wrap mw-references-columns">
        <ol class="references">
            <li id="cite_note-India2015-1"></li>
        </ol>
    </div>
</div>
<li id="cite_note-India2015-1"> <span class="reference-text">
        <style data-mw-deduplicate="TemplateStyles:r1238218222">
            .mw-parser-output cite.citation {
                font-style: inherit;
                word-wrap: break-word
            }

            .mw-parser-output .citation q {
                quotes: "\"" "\"" "'" "'"
            }

            .mw-parser-output .citation:target {
                background-color: rgba(0, 127, 255, 0.133)
            }

            .mw-parser-output .id-lock-free.id-lock-free a {
                background: url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat
            }

            .mw-parser-output .id-lock-limited.id-lock-limited a,
            .mw-parser-output .id-lock-registration.id-lock-registration a {
                background: url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat
            }

            .mw-parser-output .id-lock-subscription.id-lock-subscription a {
                background: url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat
            }

            .mw-parser-output .cs1-ws-icon a {
                background: url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat
            }

            body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,
            body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,
            body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,
            body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,
            body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a {
                background-size: contain;
                padding: 0 1em 0 0
            }

            .mw-parser-output .cs1-code {
                color: inherit;
                background: inherit;
                border: none;
                padding: inherit
            }

            .mw-parser-output .cs1-hidden-error {
                display: none;
                color: var(--color-error, #d33)
            }

            .mw-parser-output .cs1-visible-error {
                color: var(--color-error, #d33)
            }

            .mw-parser-output .cs1-maint {
                display: none;
                color: #085;
                margin-left: 0.3em
            }

            .mw-parser-output .cs1-kern-left {
                padding-left: 0.2em
            }

            .mw-parser-output .cs1-kern-right {
                padding-right: 0.2em
            }

            .mw-parser-output .citation .mw-selflink {
                font-weight: inherit
            }

            @media screen {
                .mw-parser-output .cs1-format {
                    font-size: 95%
                }

                html.skin-theme-clientpref-night .mw-parser-output .cs1-maint {
                    color: #18911f
                }
            }

            @media screen and (prefers-color-scheme:dark) {
                html.skin-theme-clientpref-os .mw-parser-output .cs1-maint {
                    color: #18911f
                }
            }
        </style>
        <style class="darkreader darkreader--sync" media="screen"></style><cite id="CITEREFPenguin_Books_India2015"
            class="citation book cs1">Penguin Books India (15 May 2015). <a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=Uf2dCAAAQBAJ&amp;pg=PT89"><i>The Portfolio Book of Great Indian Business
                    Stories: Riveting Tales of Famous Business Leaders and Their Times</i></a>. Penguin Books Limited. p.&nbsp;89.
            <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<a
                href="/wiki/Special:BookSources/978-93-5214-021-3"
                title="Special:BookSources/978-93-5214-021-3"><bdi>978-93-5214-021-3</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=The+Portfolio+Book+of+Great+Indian+Business+Stories%3A+Riveting+Tales+of+Famous+Business+Leaders+and+Their+Times&amp;rft.pages=89&amp;rft.pub=Penguin+Books+Limited&amp;rft.date=2015-05-15&amp;rft.isbn=978-93-5214-021-3&amp;rft.au=Penguin+Books+India&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DUf2dCAAAQBAJ%26pg%3DPT89&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-a-2"></li>
<li id="cite_note-a-2"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            class="citation book cs1"><a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=_voYAQAAIAAJ"><i>International Shipping &amp; Shipbuilding
                    Directory</i></a>. Benn Brothers Limited. 1958. pp.&nbsp;195, 525, 529<span class="reference-accessdate">.
                Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=International+Shipping+%26+Shipbuilding+Directory&amp;rft.pages=195%2C+525%2C+529&amp;rft.pub=Benn+Brothers+Limited&amp;rft.date=1958&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3D_voYAQAAIAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-3"></li>
<li id="cite_note-3"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            class="citation book cs1"><a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=l883AQAAIAAJ"><i>Indian Armed Forces Year Book</i></a>. 1961.
            p.&nbsp;761<span class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span>
                2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Indian+Armed+Forces+Year+Book&amp;rft.pages=761&amp;rft.date=1961&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dl883AQAAIAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-4"></li>
<li id="cite_note-4"> <span class="reference-text"><a rel="nofollow" class="external text"
            href="http://www.morarjeetextiles.com/history.html">Morarjee Textiles -journey</a></span>
</li>
<li id="cite_note-(Mahatma)1952-5"></li>
<li id="cite_note-(Mahatma)1952-5"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFGandhi_(Mahatma)1952" class="citation book cs1">Gandhi (Mahatma) (1952). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=gm4EAQAAIAAJ"><i>To Ashram sisters: from 6-12-1926
                    to 3-12-1929</i></a>. Navajivan Pub. House. p.&nbsp;18<span class="reference-accessdate">. Retrieved <span
                    class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=To+Ashram+sisters%3A+from+6-12-1926+to+3-12-1929&amp;rft.pages=18&amp;rft.pub=Navajivan+Pub.+House&amp;rft.date=1952&amp;rft.au=Gandhi+%28Mahatma%29&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dgm4EAQAAIAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-NarayanPrasad2000-6"></li>
<li id="cite_note-NarayanPrasad2000-6"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFJayaprakash_NarayanBimal_PrasadNehru_Memorial_Museum_and_Library2000"
            class="citation book cs1">Jayaprakash Narayan; Bimal Prasad; Nehru Memorial Museum and Library (2000). <a
                rel="nofollow" class="external text" href="https://books.google.com/books?id=vXoMAQAAMAAJ"><i>Jayaprakash
                    Narayan: 1954-1960</i></a>. Manohar. p.&nbsp;65. <a href="/wiki/ISBN_(identifier)" class="mw-redirect"
                title="ISBN (identifier)">ISBN</a>&nbsp;<a href="/wiki/Special:BookSources/978-81-7304-712-1"
                title="Special:BookSources/978-81-7304-712-1"><bdi>978-81-7304-712-1</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Jayaprakash+Narayan%3A+1954-1960&amp;rft.pages=65&amp;rft.pub=Manohar&amp;rft.date=2000&amp;rft.isbn=978-81-7304-712-1&amp;rft.au=Jayaprakash+Narayan&amp;rft.au=Bimal+Prasad&amp;rft.au=Nehru+Memorial+Museum+and+Library&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DvXoMAQAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-7"></li>
<li id="cite_note-7"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            class="citation book cs1"><a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=QUMdAQAAMAAJ"><i>The Illustrated Weekly of India</i></a>. April 1988.
            p.&nbsp;47<span class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span>
                2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=The+Illustrated+Weekly+of+India&amp;rft.pages=47&amp;rft.date=1988-04&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DQUMdAQAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Gandhi1994-8"></li>
<li id="cite_note-Gandhi1994-8"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFMahatma_Gandhi1994" class="citation book cs1">Mahatma Gandhi (January 1994). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=pjN3jZQ74AoC&amp;pg=PA414"><i>The Gandhi Reader: A
                    Sourcebook of His Life and Writings</i></a>. Grove Press. p.&nbsp;414. <a href="/wiki/ISBN_(identifier)"
                class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<a
                href="/wiki/Special:BookSources/978-0-8021-3161-4"
                title="Special:BookSources/978-0-8021-3161-4"><bdi>978-0-8021-3161-4</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=The+Gandhi+Reader%3A+A+Sourcebook+of+His+Life+and+Writings&amp;rft.pages=414&amp;rft.pub=Grove+Press&amp;rft.date=1994-01&amp;rft.isbn=978-0-8021-3161-4&amp;rft.au=Mahatma+Gandhi&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DpjN3jZQ74AoC%26pg%3DPA414&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Prabhu1944-9"></li>
<li id="cite_note-Prabhu1944-9"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFRamachandra_Krishna_Prabhu1944" class="citation book cs1">Ramachandra Krishna Prabhu (1944). <a
                rel="nofollow" class="external text" href="https://books.google.com/books?id=BA5LAAAAMAAJ"><i>Sati
                    Kasturba</i></a>. Hind Kitabs. p.&nbsp;47<span class="reference-accessdate">. Retrieved <span
                    class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Sati+Kasturba&amp;rft.pages=47&amp;rft.pub=Hind+Kitabs&amp;rft.date=1944&amp;rft.au=Ramachandra+Krishna+Prabhu&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DBA5LAAAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Ghose1991-10"></li>
<li id="cite_note-Ghose1991-10"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFSankar_Ghose1991" class="citation book cs1">Sankar Ghose (1991). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=5l0BPnxN1h8C&amp;pg=PA298"><i>Mahatma
                    Gandhi</i></a>. Allied Publishers. p.&nbsp;298. <a href="/wiki/ISBN_(identifier)" class="mw-redirect"
                title="ISBN (identifier)">ISBN</a>&nbsp;<a href="/wiki/Special:BookSources/978-81-7023-205-6"
                title="Special:BookSources/978-81-7023-205-6"><bdi>978-81-7023-205-6</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Mahatma+Gandhi&amp;rft.pages=298&amp;rft.pub=Allied+Publishers&amp;rft.date=1991&amp;rft.isbn=978-81-7023-205-6&amp;rft.au=Sankar+Ghose&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3D5l0BPnxN1h8C%26pg%3DPA298&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Grover1994-11"></li>
<li id="cite_note-Grover1994-11"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFVerinder_Grover1994" class="citation book cs1">Verinder Grover (1 January 1994). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=KBCd9ZKzbUUC&amp;pg=PA706"><i>Constitutional
                    Schemes and Political Development in India: Towards Transfer of Power</i></a>. Deep &amp; Deep Publications.
            p.&nbsp;706. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<a
                href="/wiki/Special:BookSources/978-81-7100-539-0"
                title="Special:BookSources/978-81-7100-539-0"><bdi>978-81-7100-539-0</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Constitutional+Schemes+and+Political+Development+in+India%3A+Towards+Transfer+of+Power&amp;rft.pages=706&amp;rft.pub=Deep+%26+Deep+Publications&amp;rft.date=1994-01-01&amp;rft.isbn=978-81-7100-539-0&amp;rft.au=Verinder+Grover&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DKBCd9ZKzbUUC%26pg%3DPA706&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Basu2001-12"></li>
<li id="cite_note-Basu2001-12"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFAparna_Basu2001"
            class="citation book cs1">Aparna Basu (1 January 2001). <a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=0P9ahUa7wrgC&amp;pg=PA118"><i>G.L. Mehta, a Many Splendoured
                    Man</i></a>. Concept Publishing Company. pp.&nbsp;118–. <a href="/wiki/ISBN_(identifier)" class="mw-redirect"
                title="ISBN (identifier)">ISBN</a>&nbsp;<a href="/wiki/Special:BookSources/978-81-7022-891-2"
                title="Special:BookSources/978-81-7022-891-2"><bdi>978-81-7022-891-2</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=G.L.+Mehta%2C+a+Many+Splendoured+Man&amp;rft.pages=118-&amp;rft.pub=Concept+Publishing+Company&amp;rft.date=2001-01-01&amp;rft.isbn=978-81-7022-891-2&amp;rft.au=Aparna+Basu&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3D0P9ahUa7wrgC%26pg%3DPA118&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Prasad1946-13"></li>
<li id="cite_note-Prasad1946-13"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFRajendra_Prasad1946" class="citation book cs1">Rajendra Prasad (1946). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=D9FzePpOA60C&amp;pg=PR12"><i>India
                    Divided</i></a>. Penguin Books India. p.&nbsp;12. <a href="/wiki/ISBN_(identifier)" class="mw-redirect"
                title="ISBN (identifier)">ISBN</a>&nbsp;<a href="/wiki/Special:BookSources/978-0-14-341415-5"
                title="Special:BookSources/978-0-14-341415-5"><bdi>978-0-14-341415-5</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=India+Divided&amp;rft.pages=12&amp;rft.pub=Penguin+Books+India&amp;rft.date=1946&amp;rft.isbn=978-0-14-341415-5&amp;rft.au=Rajendra+Prasad&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DD9FzePpOA60C%26pg%3DPR12&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-14"></li>
<li id="cite_note-14"> <span class="reference-text">Collected works, Volume 58 Gandhi (Mahatma)
        Publications Division, Ministry of Information and Broadcasting, Govt. of India, 1974</span>
</li>
<li id="cite_note-15"></li>
<li id="cite_note-15"> <span class="reference-text">Collected Works, Volume 89 Mahatma Gandhi
        Publications Division, Ministry of Information and Broadcasting, Government of India, 1983</span>
</li>
<li id="cite_note-Prasad1984-16"></li>
<li id="cite_note-Prasad1984-16"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFRajendra_Prasad1984" class="citation book cs1">Rajendra Prasad (1984). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=8WJuAAAAMAAJ"><i>Dr. Rajendra Prasad,
                    correspondence and select documents: Volume seventeen. Presidency period January 1954 to december
                    1955</i></a>. Allied. <a href="/wiki/ISBN_(identifier)" class="mw-redirect"
                title="ISBN (identifier)">ISBN</a>&nbsp;<a href="/wiki/Special:BookSources/978-81-7023-002-1"
                title="Special:BookSources/978-81-7023-002-1"><bdi>978-81-7023-002-1</bdi></a>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Dr.+Rajendra+Prasad%2C+correspondence+and+select+documents%3A+Volume+seventeen.+Presidency+period+January+1954+to+december+1955&amp;rft.pub=Allied&amp;rft.date=1984&amp;rft.isbn=978-81-7023-002-1&amp;rft.au=Rajendra+Prasad&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3D8WJuAAAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-Bhaskaran1999-17"></li>
<li id="cite_note-Bhaskaran1999-17"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFKrishnan_Bhaskaran1999" class="citation book cs1">Krishnan Bhaskaran (1999). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=ayJuAAAAMAAJ"><i>Quit India movement: a people's
                    revolt in Maharashtra</i></a>. Himalaya Pub. House. p.&nbsp;152<span class="reference-accessdate">. Retrieved
                <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Quit+India+movement%3A+a+people%27s+revolt+in+Maharashtra&amp;rft.pages=152&amp;rft.pub=Himalaya+Pub.+House&amp;rft.date=1999&amp;rft.au=Krishnan+Bhaskaran&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DayJuAAAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-India1962-18"></li>
<li id="cite_note-India1962-18"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFKasturba_Gandhi_National_Memorial_Trust,_Indore,_India1962" class="citation book cs1">Kasturba Gandhi
            National Memorial Trust, Indore, India (1962). <a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=F2RuAAAAMAAJ"><i>Kasturba memorial</i></a>. s.n. pp.&nbsp;229, 237,
            242<span class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Kasturba+memorial&amp;rft.pages=229%2C+237%2C+242&amp;rft.pub=s.n.&amp;rft.date=1962&amp;rft.au=Kasturba+Gandhi+National+Memorial+Trust%2C+Indore%2C+India&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DF2RuAAAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span><span class="cs1-maint citation-comment"><code
                class="cs1-code">{{<a href="/wiki/Template:Cite_book" title="Template:Cite book">cite book</a>}}</code>: CS1
            maint: multiple names: authors list (<a href="/wiki/Category:CS1_maint:_multiple_names:_authors_list"
                title="Category:CS1 maint: multiple names: authors list">link</a>)</span>
    </span>
</li>
<li id="cite_note-BHAVNANI2014-19"></li>
<li id="cite_note-BHAVNANI2014-19"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            id="CITEREFNANDITA_BHAVNANI2014" class="citation book cs1">NANDITA BHAVNANI (29 July 2014). <a rel="nofollow"
                class="external text" href="https://books.google.com/books?id=n_8aBAAAQBAJ&amp;pg=PT100"><i>THE MAKING OF EXILE:
                    SINDHI HINDUS AND THE PARTITION OF INDIA</i></a>. Westland. p.&nbsp;100. <a href="/wiki/ISBN_(identifier)"
                class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<a
                href="/wiki/Special:BookSources/978-93-84030-33-9"
                title="Special:BookSources/978-93-84030-33-9"><bdi>978-93-84030-33-9</bdi></a><span
                class="reference-accessdate">. Retrieved <span class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=THE+MAKING+OF+EXILE%3A+SINDHI+HINDUS+AND+THE+PARTITION+OF+INDIA&amp;rft.pages=100&amp;rft.pub=Westland&amp;rft.date=2014-07-29&amp;rft.isbn=978-93-84030-33-9&amp;rft.au=NANDITA+BHAVNANI&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dn_8aBAAAQBAJ%26pg%3DPT100&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-20"></li>
<li id="cite_note-20"> <span class="reference-text">
        <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
            class="citation book cs1"><a rel="nofollow" class="external text"
                href="https://books.google.com/books?id=p7xXAAAAMAAJ"><i>Gandhi Birth Centenary Postage Stamps, 1969</i></a>.
            Mani Bhavan Gandhi Sangrahalaya. 1972. p.&nbsp;7<span class="reference-accessdate">. Retrieved <span
                    class="nowrap">23 March</span> 2016</span>.</cite><span
            title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Gandhi+Birth+Centenary+Postage+Stamps%2C+1969&amp;rft.pages=7&amp;rft.pub=Mani+Bhavan+Gandhi+Sangrahalaya&amp;rft.date=1972&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Dp7xXAAAAMAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
            class="Z3988"></span>
    </span>
</li>
<li id="cite_note-21"></li>
<div class="mw-page-container">
    <div class="mw-page-container-inner">
        <div class="mw-content-container">
            <main id="content" class="mw-body">
                <div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer"
                    aria-labelledby="firstHeading" data-mw-ve-target-container="">
                    <div id="mw-content-text" class="mw-body-content">
                        <div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
                            <div class="reflist">
                                <div class="mw-references-wrap mw-references-columns">
                                    <ol class="references">
                                        <li id="cite_note-21"> <span class="reference-text">
                                                <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite
                                                    class="citation book cs1"><a rel="nofollow" class="external text"
                                                        href="https://books.google.com/books?id=o-YGAQAAIAAJ"><i>Oceanite</i></a>. Maritime Union of
                                                    India. 1982. p.&nbsp;6<span class="reference-accessdate">. Retrieved <span class="nowrap">23
                                                            March</span> 2016</span>.</cite><span
                                                    title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Oceanite&amp;rft.pages=6&amp;rft.pub=Maritime+Union+of+India.&amp;rft.date=1982&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3Do-YGAQAAIAAJ&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3AShanti+Kumar+Morarjee"
                                                    class="Z3988"></span>
                                            </span>
                                        </li>
                                    </ol>
                                </div>
                            </div>
wheelercj commented 2 months ago

When I open the HTML inspector for the site and choose the "Copy Outer HTML" option on the reference section's div, the resulting HTML is simple and does not have any of those extra elements.

wheelercj commented 2 months ago
let endRange = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
let endNode = endRange.endContainer;

endNode contains the document's <body> element for some reason. The other ranges before the last one don't.

The Range.endContainer read-only property returns the Node within which the Range ends.

Range: endContainer property - Web APIs | MDN

wheelercj commented 2 months ago

Apparently, this bug is only present in Firefox.

Note: Currently only Firefox supports multiple selection ranges, other browsers will not add new ranges to the selection if it already contains one.

Selection: addRange() method - Web APIs | MDN

With the selection described in the original post here in Chrome, selection.rangeCount is 1, but in Firefox it's 29. Firefox seems to create a new range for each list item in the references list. I don't think Firefox usually does this for list items.

Although the last range of the references list has been unusual, it doesn't necessarily relate to why the other reference don't make it into Stardown's output. What might be more likely to be the cause is that it's not only the last range that has some duplicate elements. Every time Firefox creates another range, the range duplicates some of its context. The last range duplicates a lot, but the preceding ranges each have a duplicate list item element:

...
<li id="cite_note-BHAVNANI2014-19">
</li>
<li id="cite_note-BHAVNANI2014-19">
    <span . . .
        (one reference's data is here) . . .
    </span>
</li>
...

I hope there's a way with Firefox to make selections always have one range or to combine all the ranges into one without keeping any duplicate elements.

wheelercj commented 2 months ago

I replaced getSelectionHtml with getSelectionFragment to remove unnecessary steps, but the bug persists.

Selection - Web APIs | MDN

wheelercj commented 2 months ago

Some Wikipedia pages have multiple reference lists. This bug is present for each reference list. Example: English modal auxiliary verbs - Wikipedia.