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

Enhancement: Dynamic title attribute on Markdown Footnote links #27387

Open
edent opened this issue Nov 14, 2022 · 0 comments · May be fixed by #27388
Open

Enhancement: Dynamic title attribute on Markdown Footnote links #27387

edent opened this issue Nov 14, 2022 · 0 comments · May be fixed by #27388
Labels
[Feature] Markdown [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Comments

@edent
Copy link
Contributor

edent commented Nov 14, 2022

Impacted plugin

Jetpack

What

Footnote links' titles say "Read footnote." This would make the attribute display the content of the footnote.

How

At the moment, if a user hovers over a footnote, the title attribute displays this tool tip:

Screenshot of a pop up which says 'read the footnote'


I think it would be nice if JetPack showed users the full text of the footnote. For example:

The pop up now displays the full note


This is controlled by :

function _appendFootnotes_callback($matches) {

Specifically:

if ($this->fn_link_title != "") {
	$title = $this->fn_link_title;
	$title = $this->encodeAttribute($title);
	$attr .= " title=\"$title\"";
}

The change is relatively straightforward:

if ($this->fn_link_title != "") {
	$title = trim( wp_strip_all_tags($this->footnotes[$node_id], true) );
	$title = $this->encodeAttribute($title);
	$attr .= " title=\"$title\"";
}

That takes the text of the footnote, sanitises it, and adds it as the title element.

This builds on the work I did in #21371

@edent edent added the [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Nov 14, 2022
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Nov 14, 2022
edent added a commit to edent/jetpack that referenced this issue Nov 14, 2022
Fixes Automattic#27387 

Quick conformance test:

```
Lorem ipsum dolor sit amet[^latin]. These footnotes support Markdown[^md] and HTML[^html]. They don't choke on entities[^ent]! And quote marks are fine[^q]. What about very long footnotes[^long]? Fully multilingual[^zh] and Unicode[^🥰] compatible.

[^latin]: Other Latin texts are available
[^md]: Some Markdown *emphasis* and a [link](https://example.com)
[^html]: Using <em>HTML</em>
[^ent]: Entity support & or &amp;? < or &lt;
[^q]: "
[^long]: Sensors indicate no shuttle or other ships in this sector. According to coordinates, we have travelled 7,000 light years and are located near the system J-25. Tractor beam released, sir. Force field maintaining our hull integrity. Damage report? Sections 27, 28 and 29 on decks four, five and six destroyed. Without our shields, at this range it is probable a photon detonation could destroy the Enterprise.
[^zh]: 威廉 莎士比亚
[^🥰]: 🥰
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Markdown [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants