Skip to content
Snippets Groups Projects

Markdown footnotes not working

Merged Brett Walker requested to merge 26375-markdown-footnotes-not-working into master
All threads resolved!

What does this MR do?

The sanitization filter removes all the footnote classes and ids. We now enable ids for footnotes, and add back the classes for wrapping the footnotes (allowing them to be styled properly).

Footnotes are numbered the same - the first one has id=fn1, the second is id=fn2, etc. In order to allow footnotes when rendering multiple markdown blocks on a page, we need to make each footnote reference unique.

We add a random number to each footnote (the same number can be used for a single render). So you get id=fn1-4335 and id=fn2-4335.

Note to UI/FE: In order to allow for easier styling, classes generated by CommonMark were carried through into the footnotes.

  1. The entire footnote section is wrapped in <section class="footnotes">
  2. The back reference link has the footnote-backref class
  3. The superscripted reference has the footnot-ref class
<p dir="auto">
  one footnote<sup class="footnote-ref"><a href="#fn1-9351" id="fnref1-9351">1</a></sup>
</p>
<section class="footnotes">
  <ol>
    <li id="fn1-9351">
      <p>one <a href="#fnref1-9351" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1"></gl-emoji></a></p>
    </li>
  </ol>
</section>

What are the relevant issue numbers?

Closes #26375 (closed)

Does this MR meet the acceptance criteria?

Edited by Brett Walker

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @digitalmoksha Added a few questions / comments.

    A minor concern is the backref link which is rendered using a

    Screen_Shot_2019-01-09_at_10.51.43_AM

    It doesn't look good for me. What do you think @annabeldunstone? This could be handled in a separate issue though.

  • I wanted to call attention to the new classes I've added (detailed in the description). We could make them anything - these happen to be what CommonMark generates by default, and I don't anticipate any conflicts. But if they need changing, just let me know what they should be.

    @digitalmoksha The class names look good to me. I don't see any footnote related CSS within GitLab so we should be good 👍

  • A minor concern is the backref link which is rendered using a

    This is what we have currently and I think it's fine. Thanks for checking @engwan!

  • Brett Walker added 1 commit

    added 1 commit

    • cc036417 - Updates based on review comments

    Compare with previous version

  • @engwan I made changes for the review comments, can you take a another quick look when you have a chance?

  • assigned to @engwan

  • @annabeldunstone thanks for taking a look 🙇

    We might want to consider a little styling with the footnotes in the future. I can envision a thin line separator, maybe a slightly smaller font (like real footnotes). And I agree with @engwan , maybe different backref icon (or I would even suggest not using an icon, just the actual unicode return character, which would be more sublte).

    But I think that could all be considered under a different issue/MR (I'll open one just to have it), certainly down the road.

  • Heinrich Lee Yu resolved all discussions

    resolved all discussions

  • @godfat I was wondering if you would have time to review this as a maintainer? I think it's ready to go 🚀

  • assigned to @godfat

  • Lin Jen-Shin
  • Lin Jen-Shin resolved all discussions

    resolved all discussions

  • added banzai label

  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • We might want to consider a little styling with the footnotes in the future

    Sure! Feel free to open an issue

  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • Stan Hu
  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • @digitalmoksha Thank you! Although I left a few comments and open discussion, this looks really great to me. I think we can do some of them in the next iteration, not really needed right here. What do you think?

  • mentioned in issue #56272 (moved)

  • Created https://gitlab.com/gitlab-org/gitlab-ce/issues/56272 for styling the footnotes.

  • Brett Walker added 1 commit

    added 1 commit

    • 034f2d67 - Refactoring and addressing review comments

    Compare with previous version

  • @godfat thanks for the review! I think I've addressed most of your comments. Can you take another look when you have a chance?

  • assigned to @godfat

  • Brett Walker added 1 commit

    added 1 commit

    • eda8222f - Refactoring and addressing review comments

    Compare with previous version

  • Lin Jen-Shin
  • Lin Jen-Shin
  • Lin Jen-Shin
  • @digitalmoksha Thank you! Looks great to me. Just a bit few minor stuffs and still need to update nokogiri for QA.

  • Brett Walker added 1 commit

    added 1 commit

    • 7e900ed8 - Refactoring and addressing review comments

    Compare with previous version

  • Brett Walker added 1 commit

    added 1 commit

    Compare with previous version

  • Brett Walker added 1 commit

    added 1 commit

    • 8bf78e39 - Bumping the CACHE_COMMONMARK_VERSION

    Compare with previous version

  • fyi, just bumped the CACHE_COMMONMARK_VERSION from 12 to 13. I was expecting another MR was going to be merged which needed to bump it. But that may not end up getting merged. So doing it here...

  • Stan Hu mentioned in merge request gitaly!1044 (merged)

    mentioned in merge request gitaly!1044 (merged)

  • @godfat I think I've addressed everything. Can you take a final look?

  • assigned to @godfat

  • Lin Jen-Shin resolved all discussions

    resolved all discussions

  • Lin Jen-Shin approved this merge request

    approved this merge request

  • @digitalmoksha Thank you! Looks great. This is a bit behind master but I think it's unlikely to conflict with the others, and unlikely to conflict with EE, and unlikely to break QA so I'll just merge as.

  • merged

  • Lin Jen-Shin mentioned in commit ae0b8880

    mentioned in commit ae0b8880

  • Please register or sign in to reply
    Loading