Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [issue] Special HTML characters (<, >, &) in article titles
That won’t help with existing page titles.
Obviously true. Shouldn’t be an obstacle to introduce this from now on. I strongly believe that Textile (or any other markup generator) is generally preferrable over HTML markup, as far as content authors are concerned.
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
I want to share a little trick that can be useful for including HTML tags in article titles.
<a href=“http://forum.textpattern.com/viewtopic.php?pid=83109#p83109”>using HTML tag in article title and stripping it in browser title tag</a>
Please, let me know if this work for you.
BTW, I want to ask something: when I include an ampersand in the article title, I do it by typing <code>&amp;</code>.
Then, I save my article.
But if I’m going to edit the article again, in the article title field, the <code>&amp;</code> has been removed and simple replace by &.
The problem is: if I dont notice that my article title has been modified and save the article without correcting again the ampersand, then my site will ouput invalid code (unescaped ampersands).
Last edited by maniqui (2005-10-27 20:21:57)
Offline
#15 2005-11-05 14:03:25
- loid
- Member
- Registered: 2005-03-09
- Posts: 38
Re: [issue] Special HTML characters (<, >, &) in article titles
Up until 4.01, or possibly even 4.02, I used page break and italic/emphasis mark-up in article titles without problem. Now that shows up in the headlines (article titles) instead of creating a page break or italic text.
Last edited by loid (2005-11-05 14:04:22)
Offline
#16 2005-11-05 14:19:53
- igner
- Plugin Author
- Registered: 2004-06-03
- Posts: 337
Re: [issue] Special HTML characters (<, >, &) in article titles
loid – It’s a matter of entity encoding, and has been discussed here and elsewhere.
And then my dog ate my badger, and the love was lost.
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
In this issue, 4.0.2 breaks backward compatibility.
I’m thinking loud:
For future releases
- if someone wants to use special characters (like <, >, &) in article titles, he/she should type it directly as an html entity (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>), and dont expect that TXP does the conversion if they are typed as <, > or &.
- allow the use of HTML elements in article titles (and in section/category titles). This adds more flexibility to TXP, and also doesnt break backward compatibility.
Finally, I quote myself:
<blockquote>when I include an ampersand in the article title, I do it by typing <code>&amp;</code>.
Then, I save my article.
But if I’m going to edit the article again, in the article title input field, the <code>&amp;</code> has been removed and simple replace by &.</blockquote>
If I input a <code>&amp;</code>, then, when re-editing the article, I get a & (not encoded, as I typed it before). My question: is this a “fault” of TXP, or the database or the browser?
I mean, who is the responsible of changing what I typed originally (<code>&amp;</code>) to another thing (&)?
Thanks.
Last edited by maniqui (2005-11-05 15:18:00)
Offline
#18 2005-11-05 21:47:51
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: [issue] Special HTML characters (<, >, &) in article titles
if someone wants to use special characters (like <, >, &) in article titles, he/she should type it directly as an html entity (<, >, &), and dont expect that TXP does the conversion if they are typed as <, > or &.
That’s the opposite of most user’s expectations. It’s different to the behaviour of other fields like excerpt and body. It means that we rely on the user for RSS and Atom validity. And there are many named entities that are valid XHTML but invalid in an XML feed.
Alex
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
maniqui wrote:
if someone wants to use special characters (like <, >, &) in article titles, he/she should type it directly as an html entity (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>), and dont expect that TXP does the conversion if they are typed as <, > or &.
As Zem said, we want the opposite. The simplest way. That’s if we want a >, we type a >. If that’s is not valid for some technico-geeky-mysterious reason, let the software encode it properly (should I remember that most user don’t know what is a XML boundary character, and more don’t care ?).
allow the use of HTML elements in article titles (and in section/category titles). This adds more flexibility to TXP, and also doesnt break backward compatibility.
If that doesn’t break anything, yep why not. I more enclined to allow Textile in title (I personnaly heavily use book title in article title, and miss the appropriate tag —??cite??).
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
> Etz Haim wrote:
<blockquote>For example, and article is titled “a > b is a conditional”, and<txp:page_title separator=" :: " />
outputs:
<title> My Site Name :: a > b is a conditional </title>
which is invalid XHTML.
</blockquote>
I have tested (using a 4.0.1, but sure it’s also the same in 4.0.2) that the above is valid XHTML. I didnt receive any error when using > or < in titles. I also included an &, but it was correctly escaped to an html numeric entity.
When I run the page through the validator.w3.org, it says: “This Page Is Valid XHTML 1.0 Strict!”
OK, I must admit I receive some warnings, but it doesnt means “invalid”, or it does?
Quoted from the Mark-up Validation Service:
<blockquote> Warning Line 14 column 43: character “<” is the first character of a delimiter but occurred as data.< title>A > B & C < D | < /title>
This message may appear in several cases:
- You tried to include the “<” character in your page: you should escape it as “<”
- You used an unescaped ampersand “&”: this may be valid in some contexts, but it is recommended to use “&”, which is always safe.
- Another possibility is that you forgot to close quotes in a previous tag.</blockquote>
The HTML Tidy for Firefox shows those nice green icons that read “0 errors / 0 warnings”
But it’s very possible that I’m wrong and that “warning” message in the validation service deserves more attention and respect.
Or maybe not, and it just means nothing dangerous, and we can keep using > and < in our page titles without the need of escaping them to html entities.
So, in the meanwhile, maybe HTML elements in article/section/category titles can be restored, and also, < and > can be used without escaping them.
If behaviour is reverted
- if someone wants to use < and >, he can use them and still have valid code.
- if someone wants to include HTML elements in article/section/category titles, he can also use them (but remember to follow the tip above to remove it from the < title> tag by using the sab_striphtml plugin).
Am I missing something? (I have no doubt I am missing something)
Last edited by maniqui (2005-11-08 12:18:07)
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
Yes, it is invalid. Just think what a combination of < and > could do, ie. in a more complex formula.
Last edited by Etz Haim (2005-11-08 09:05:21)
VC3 :: weblog :: my wishlist
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
Etz Haim wrote:
<blockquote>Yes, it is invalid. Just think what a combination of < and > could do, ie. in a more complex formula.</blockquote>when you say “a more complex formula”, are you talking about math formulae and logical formulae as the “a > b” you put as example in the first post?
My argument
if you need to write more complex formulae, surely you will need more symbols than simple <, > and =.
For sure, you will want to use formulae symbols like:
<big>*⊇ ≥ ≡ ≠ φ ∞ ƒ ↔*</big> and many other symbols.
Do you have those symbols in your keyboard? I suppose you dont, so, how will you put them in your article title?
You will do the same I did to display those symbols in this post:
you will type them as HTML entities:
<code>&supe; &ge; &equiv; &ne; &phi; &infin; &fnof; &harr;</code>
So, this is my logic: if you need to type those symbols as HTML entities, why wont you type the < and > also as HTML entities? wont you type them as entities because you have them in your keyboard?. Lazy boy! ;)
Well, as a second argument, I would ask: arent math/logical formulae out of the scope of a simple article title? I want to mean: arent formulae a very rare case in article titles? wont be the need of formulae in titles just to a very small niche of txp users?
Is it very common to have “a > b”-like titles in your posts? I dont know, I’m just asking.
One counterargument to my argument
Sure, many users will use > and < in a context that is not a math formulae.
Article titles like “It’s my birthday > buy me a present!” ¿are of common use? (I dont know).
If user wants to type > and < directly from the keyboard, they should accept they will have invalid code in their <code><title></code> and also in his site.
Finally, I ask, have we lost the power of using HTML elements in our article/section/category titles just for escaping <, > and &?
I’m asking standing at my own ignorance, because I dont know how dangerous could be to have a few unescaped characters in our code.
And there is no need to expect that TXP do the job of escaping those characters: just learn to type <code>&lt;</code>, <code>&gt;</code> and that’s all you need to know.
Thanks <small>and excuse my barbarian english and some lack of consistency behind my logic</small>
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
That’s why unicode is for. Title are supposed to handle complex glyph.
How to type them ? Well the same way you type them everywhere… if one needs help, upm_quicktags does this wonderfully.
Offline
#24 2005-11-13 23:31:07
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: [issue] Special HTML characters (<, >, &) in article titles
maniqui: it’s still not clear to me what you’re proposing. Send us some code that does what you’re suggesting and we’ll take a look at it.
Otherwise, I think this has strayed a long way from being a bug report.
Alex
Offline