Add HTML title, lets you add <i>
and <b>
and a couple other tags to titles.
#166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the HTML title module. This allows you to put a short list of markup in your node titles.
Allowed Tags
<br><sup><sub><i><b>
Why
<i>
not<em>
?From the HTML reference:
My main use case for this improvement is taxonomic names, a frequent occurrence in theses.
Why
<b>
not<strong>
?Also from the HTML reference:
Reviews of books are commonly held in repositories.
Why
<sup>
and<sub>
?Math and chemistry markup. However, we're not going as far as adding mathjax to titles (that'll be a recipe, since it's a little more niche).
Why
<br>
?I'm not sure, it came enabled. I think it's the most problematic one as the content editor has to remember to put a space on one side of the tag, or else when it gets stripped (as it does in several places, such as the tab title) you'll have words abutted against each other. It also does a poor job of signalling a subtitle since the font treatment is still h1. I'd be happy to take it out.
How it works across the repository
Node page
Title displays in h1 with all its marked up glory, rendered nicely.
Views
Content views: Title displays with html rendered nicely. Unless you strip it out with "Strip HTML tags".
Search API views: The markup is stored in Solr. With the default "plain text" field render formatter, the raw markup is visible to the user and "Strip HTML tags" does not work. With the alternate "HTML title text" field render formatter, the markup renders nicely in the output, encodes into XML properly (see OAI-PMH) and "Strip HTML tags" works.
JSONLD
Markup is raw, unescaped tags in JSONLD. I think this is okay, as the JSON-LD spec only mentions escaping HTML entities in a section specifically about embedding JSONLD into a <script> tag in HTML. Outside the HTML context, unescaped entities should be fine.
OAI-PMH
DC: The HTML is present in the XML. In a browser you see
<i>
and in a text editor you see<i>
. This is correct for XML. I can't find information on whether it's ok for dublin core. PKP does not allow title italics; Omeka does. I assume it's fine. However, I think we would need to add a "strip tags" feature in code if we wanted to remove tags here.MODS: With "plain text" as the field formatter, the HTML is doubly encoded into the XML. In a browser you see
<
and in the XML in a text editor you see&lt;
. No good!This assumes harvesters can accept HTML in titles.
Otherwise, we can set the field formatter to "HTML title text" AND "Strip HTML tags" to have an HTML-less OAI experience.
Sorting
You'll probably have a bad time if you're trying to sort on title and you have some that start with markup.