Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add footnote support for wiki markdown #8125

Merged
merged 18 commits into from
Oct 12, 2021
Merged

Conversation

gagahpangeran
Copy link
Contributor

@gagahpangeran gagahpangeran commented Sep 16, 2021

Depends on:

closes #7316

Now without any custom renderers and with simple approach.

How to use

Basic syntax:

Footnote[^ref]

[^ref]: Reference here

And will automatically assign number and render something like this:

Footnote1

  1. Reference here

[1] link will target to the reference list item and ↑ link will go back to [1].

Some caveats

Be careful with exclamation

Valid:

osu! [^ref]

[^ref]: https://osu.ppy.sh

Invalid:

osu![^ref]

[^ref]: https://osu.ppy.sh

Be careful with duplicate reference key

Valid:

First[^ref]

Second[^ref]

[^ref]: Valid shared reference

Invalid:

First[^ref]

Second[^ref]

[^ref]: This become invalid
[^ref]: Valid shared reference

Demo

Use this branch for this example

footnote.mp4

app/Libraries/Markdown/OsuMarkdown.php Outdated Show resolved Hide resolved
resources/assets/lib/core/wiki/reference-link-tooltip.ts Outdated Show resolved Hide resolved
app/Libraries/Markdown/Indexing/Extension.php Outdated Show resolved Hide resolved
</sup>
</p>

<li class="osu-md__list-item osu-md__list-item--footnote" id="osu-fn-test" role="doc-endnote">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this extension sure likes producing weird output. This invalid list item aside, it also accepts [^1]: > aaa and produces blockquote. Similarly with [^1]: 1. aaa 😐

Copy link
Contributor Author

@gagahpangeran gagahpangeran Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wandering around and look at another markdown parser that support footnote, I think this is intentional that they accepts any kind of markdown syntax inside footnote list, for example see markdig footnotes and remark footnotes (now in remark-gfm)

Just do some moderation from wiki-side to not using weird syntax inside footnote list 🙃

I think they only need to use emphasis and link for footnote list in wiki, cc: @TicClick for confirmation.

PS:

Now github also support footnote, let's compare. GFM also render as blockquote for first case. For second case, GFM is dying and not render at all.


Syntax:

Test[^1]

[^1]: > aaa

Result:

Test1

Footnotes

  1. aaa

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yeah. maybe some other basic formatting like bold/underlined, but that's going to be very rare. typical footnote usage is link references or remarks like the one under ¹ at https://osu.ppy.sh/wiki/VCC#criteria

@@ -226,6 +234,20 @@
}
}

&__link {
&--footnote-ref {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed the tooltip arrow is aligned weirdly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's aligned correctly in firefox but not in chrome 🤔

Copy link
Contributor Author

@gagahpangeran gagahpangeran Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are some qtip2 bug in chrome that using first child element as positioning target.

Using this markdown

[*chat* **window**](/wiki/Chat_Console "Chat window")

will produce

<a class="osu-md__link" href="./Chat_Console" title="Chat window"><em>chat</em> <strong>window</strong></a>

In chrome, the tooltip use first child (em element) for its positioning.

image

In firefox, it works as expected and using the whole anchor element for its positioning.

image


I have some options forward to tackle this.

  1. Debug qtip2 fork in https://github.com/notbakaneko/qTip2 and apply some patches.
  2. Use custom renderer to directly add bracket into superscript anchor.
  3. Remove the ::before and ::after element. But without bracket the superscript link is so small in mobile it so hard to click.
  4. Remove the tooltip preview altogether so we don't have to worry about this bug.

Thoughts?

PS: At some point we have to replace qtip2 to another library, it's already abandoned since long time ago.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't see this as a blocker to get this PR merged. Probably fine to create a separate issue tracking it.

@nanaya nanaya enabled auto-merge October 12, 2021 06:33
@nanaya nanaya merged commit e807e37 into ppy:master Oct 12, 2021
@gagahpangeran gagahpangeran deleted the footnote-wiki branch October 12, 2021 06:53
@TicClick TicClick mentioned this pull request Apr 13, 2022
3 tasks
This pull request was closed.
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.

Superscript support for osu! wiki (footnotes)
4 participants