Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
remove trailing slashes
I just checked the demo site, dev version and trailing slashes are still served.
To check
Create a new article and paste
notextile.. <txp:images id="1,2,3,4" sort="rand()" limit="6" >
<txp:image loading="lazy" class="grid_24" /></a>
</txp:images>
testing text
something here
The text renders correctly with <br>
The images
tag produces <br />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: remove trailing slashes
Good find. This goes back to the constant br
, which is defined here. This happens before any functions are available, so you can’t determine the doctype setting at that point. AFAIK, it can’t be redefined later.
The constant is used in several places in the admin, and then for the break
attribute of various front-end tags including:
- search_input
- category_list
- section_list
- images
- image_index
- file_download_list
- recent_comments
What would be best here? Replace all instances of
'break' => br,
with
'break' => '<br' . (get_pref('doctype') === 'html5' ? '>' : ' />'),
Or some other approach? For example, are constants defined anywhere else after certain internal functions (e.g. get_pref or safe_field) are made available?
EDIT: This should really belong in 4.9 where we’ve made a slew of similar changes.
TXP Builders – finely-crafted code, design and txp
Offline
Re: remove trailing slashes
Oooh that is tricky yeah. That constant is actually pretty useless and I’d be fine deprecating it in favour of a neater solution.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: remove trailing slashes
It could be that plugins use it, and it’s used in a few places in the admin panels too. It’s probably not as neat to define at some later point where one can check what doctype is set?
TXP Builders – finely-crafted code, design and txp
Offline
Re: remove trailing slashes
Frankly, I don’t like removing slashes at all. Standard XML parsers might complain. Enhancing <txp:evaluate />
with dom parsing capabilities will be tricky.
Offline
Re: remove trailing slashes
etc wrote #339497:
Frankly, I don’t like removing slashes at all. Standard XML parsers might complain. Enhancing
<txp:evaluate />
with dom parsing capabilities will be tricky.
In that case what about changing the default break attributes?
Also, and this is a question to the community, Should we keep on supporting xhtml? HTML5 has come into effect almost 20 years ago in 2007.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: remove trailing slashes
Is not XHTML deprecated? Not just HTML5, but also HTML4, HTML3.2 — all HTML versions had and still have <br>
. As far as I know, <br />
only applies to XML markup.
Offline
Re: remove trailing slashes
colak wrote #339502:
[…] Should we keep on supporting xhtml? HTML5 has come into effect almost 20 years ago in 2007.
Backwards compatibility and all that… For a TXP.next yeah, drop it, please, pretty please. What Textpattern serves is text/html
anyway.
In that case what about changing the default break attributes?
I don’t remember ever relying on the default value personally. A comma-separated list as substitute – break=", "
? But again BWC… :-(.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Offline
Re: remove trailing slashes
etc wrote #339515:
And this slashless syntax feels wrong, not to mention that it could break
etc_query/smd_xml/so_on
parsing.
Are you talking about <txp:some_tag />
style tags-with-trailing-slashes or HTML tags (<br>, <link rel=alternate …>
, etc)? Nobody’s ever been claiming they want to change the <txp: />
tag syntax as far as I am aware. We’re only talking about HTML tags.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
#11 Today 08:32:14
Re: remove trailing slashes
phiw13 wrote #339524:
Are you talking about
<txp:some_tag />
style tags-with-trailing-slashes or HTML tags (<br>, <link rel=alternate …>
, etc)? Nobody’s ever been claiming they want to change the<txp: />
tag syntax as far as I am aware. We’re only talking about HTML tags.
I’m assuming Oleg means that xml parsers used by etc_query and smd_xml and txp:evaluate potentially have problems with slashless self-closing elements, because they are invalid xml (but valid html5). See, for example, Mat Simon’s post To close or not to close.
etc wrote #339497:
Frankly, I don’t like removing slashes at all. Standard XML parsers might complain. Enhancing
<txp:evaluate />
with dom parsing capabilities will be tricky.
So we end up with a conundrum:
- support slashless void tags to satisfy the W3C HTML5 validator and potentially create problems for tags and functions that rely on xml-based parsing.
- remain with slashed void tags to conform with xml patterns but forever see validator errors / notices in the code output.
For 1, might the parsers catch up at some point?
For 2, we’ve been working towards slashless output for doctype html5 for a while (I did some of that), and the br
constant is a piece I missed back then.
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1