Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
markup
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
21 Feb 2012 at 04:59 UTC
Updated:
29 Jul 2014 at 20:24 UTC
Jump to comment: Most recent file
Comments
Comment #1
jessebeach commentedSimple one-liner that replaces
<em>with<span>.Comment #3
jessebeach commented#1: 1447678_drupal-placeholder_1.patch queued for re-testing.
Comment #5
heine commentedIsn't this desired / by design?
From the function's PHPDOC:
Emphasis added.
For non-emphasized display, @ can be used.
Comment #6
jessebeach commentedHeine, the @ case doesn't provide a placeholder wrapper
So the only choice without this change is a semantically-incorrect wrapper, or no wrapper. Changing
<em>to<span>makes this function more generic and doesn't force a themer to unitalicize the .placeholder class in their theme.I'll change the function comment in a future patch with some work on those failing tests as well.
Comment #7
jacineI agree with @jessebeach on this. em is definitely not right for this. Also, tagging this for the current HTML5 sprint.
Comment #8
jacineAlso, technically this is a markup issue.
Comment #9
Snugug commentedIf we're deciding to use non-semantic markup for this, I know the favorite of some of the Big Names in Front End™ like Divya and Lea Verou is the
<b>tag as it's short, sweet, and to the point. Thoughts on that instead of<span>?Comment #10
dave reidDoesn't this cause a regression in the actual message display though since the text would no longer be highlighted?
Comment #11
jessebeach commentedDave, which 'this' do you mean? Using
<b>or using<span>?This came up with this string that I encountered in the aggregator module:
<em>X days Y min</em> oldWrapping with
<em>creates a weird visual italicizing in the middle of the string, leaving "old" unitalicized. Also, in this context,<em>is unnecessary and semantically wrong. We're not trying to redefine the meaning ofX days Y minin displaying the published date of an item. We're trying to create a hook for themers to hang styles on if they choose.If the italicized styling is desired in some cases, then we can achieve the styling with CSS, not markup, to address styling regressions.
Comment #12
heine commentedSo, wouldn't adding a placeholder span for @, ! and an extra emphasized equivalent of ! be the way forward? Once again, it seems to me that emphasis, NOT styling is the purpose of the % placeholder.
An alternative approach would be to ditch % altogether and simply add desired HTML to the string.
Comment #13
jessebeach commentedIf this one function is meant to wrap text in
<em>, then why not call ittheme_em? This would suggest that we also have functions or cases for<strong>,<i>, and<b>.Taking such a route complicates what should be a simple, generic, inline text wrapping function that utilizes a
<span>because it has the widest applicability and no semantic assumptions associated with it.Comment #14
jacineI agree with this as well.
We should look at the examples in core where this is being used and evaluate from that. If only I could figure out regex I would paste a list.
Comment #15
jhr commentedHope the attachment helps. Colons(:) around the line # show that drupal_placeholder is in it.
grep crashcourse:
grep command
grep
drupal_placeholder (find this string, fyi: escape spaces like 'function\ drupal_placeholder')
* (in any file)
-r = recursive (sub directories)
-n = show line numbers
-20 = show +/- 20 lines
<Druplicon> grep -rinC3 "string to find" /folder/to/search/recursively (where -Cn is how many lines to display around the text, -r is recursive, -i is case-insensitive, and -n prints the line numbers)Comment #16
jacineAww, thank you so much @jhr! You rock. :o)
Is there a way to only search for occurrences of % inside t()?
Comment #17
jessebeach commented@jhr, thank you! This is really helpful.
I realize that if this patch is going o work, I'll need to replace the structure-styling of the
<em>tag with CSS for the place (like text formats) where one currently expects italicized text.If we could find the % variables in t functions that Jacine suggested, that would really get this effort springboarded. Thank you!
Comment #18
heine commentedWouldn't it be better to just replace % with @ ?
Comment #19
jhr commentedThis file has 858 lines, but with some false positives.
grep -rn -E "\Wt\([^\)%]*%" * > .percent_grep.txt
The grep is just searching for a '%' after a 't(', and then writes the output to a hidden file (.percent_grep.txt) to keep from falling into an infinite loop by searching for text in the file that it's currently writing to.
Also, it's limited to one line at a time. So if % shows up after a line-break, it won't detect it.
ex: t( "lorem ipsum doloret " .
"%var lorem ipsum etc", etc.. );
Comment #20
jessebeach commentedHeine, perhaps. I'm bent on determining if
<em>is indeed semantically correct in all the instances that it's used in core or if this function is more useful with a generic tag like<span>.If we are using this function to wrap text to represent "stress emphasis of its contents", then we're using it correctly. Otherwise, the inertia of past practice is simply keeping us from improving.
Comment #21
jhr commentedManually changing this would be a nightmare, but programmatically it's manageable. A whole bunch of review in a mega patch.
Try giving this <em> tag a special class, <em class=1447678> and changing the text-color & background to make it stand out.Comment #22
johnalbinCan I say that the thought of Drupal outputting
<span class="placeholder">text</span>makes me want to stab my eyes? Replacing a semantic element with an unsemantic one because some strings are using it incorrectly is a bad idea. Its the strings that need to change, not drupal_placeholder().From the docs from format_string():
The purpose of %variable is to wrap it in an em. Otherwise, you'd just use @variable.
Or you'd add the element you actually want and put it around the actual text you want wrapped. For example, taking the
<em>X days Y min</em> oldsnippet from aggregator above, it seems clear that aggregator is simply calling t() incorrectly. It should bet('<em>@time old</em>', array('@time' => $time))instead oft('%time old', array('%time' => $time)). It's not the $time text snippet that deserves semantic distinction; its the entire phrase.So, I oppose changing the HTML element used by t() and format_string(). It's <em> by design.
It’s the strings that need to be fixed, not the function.
Comment #23
jessebeach commentedConceded.