Home Forums DITA and XMetaL Discussion Spaces in the URL Reply To: Spaces in the URL

Derek Read

Reply to: Spaces in the URL

Ah, now I think I understand.

Yes, this stuff is generated by JavaScript (the anchor portion of the URL that comes after the # sign) is based on document titles, which often have spaces in them. Because the IETF spec for URLs (referenced in the code comments) says you should not use actual spaces in URLs the code escapes them as %20 so that the URLs are legal.

I'm still a little confused because I'm not sure why having the %20 in the URL is a concern. Did your website people give a reason? You say the project manager doesn't allow spaces. So, because there are no spaces in the URL I'm not sure what the issue is. Or are they saying the %20 and space are identical (ie: it is not that the URL is illegal, it is that they think %20 is ugly)?

The thing that might be confusing everyone here is that different browsers display %20 differently in the address bar. In some browsers if a URL contains %20 it is rendered as %20 (IE is one) and some browsers “help” you by rendering the %20 as a space (presumably because this is easier to read and understand). Our code is telling the browser to use %20, it is the browser that is rendering a space, not us (this is true for FireFox). If you have both browsers installed and open the same output in each you should see what I mean.

To show that this is a browser behavior you can visit any website that has %20 in the URL (or set up your own test). You will see different rendering behavior in different browsers. In FireFox (which shows %20 as a space) if you copy such a URL from FireFox and paste it into a text editor you will see the %20 magically appear there, because under the covers FireFox actually knows it is there and puts the %20 on the clipboard, it is just rendering it as a space in the address bar.

If the website people do have an issue with what the JavaScript is doing then I think as part of their code review (assuming they are reviewing the JavaScript before they put it on the website) they could make changes to it so that it does what they want it to do.

The alternative might be to simply generate output using the standard DITA OT transtype 'XHTML' (which we expose in our Generate Output dialog as “Multiple HTML”) and then let the website people integrate those HTML files into the website, creating their own framework around them (if they want frames or not, TOC, searching, etc).

Reply

Products
Downloads
Support