Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-04-12 05:53:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,161
Website GitHub Mastodon Twitter

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

#2 2025-04-12 12:35:35

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,868
Website GitHub

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

#3 2025-04-12 17:14:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,714
Website GitHub

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

#4 2025-04-12 21:27:12

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,868
Website GitHub

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

#5 2025-04-12 21:38:47

etc
Developer
Registered: 2010-11-11
Posts: 5,358
Website GitHub

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

#6 Yesterday 05:15:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,161
Website GitHub Mastodon Twitter

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

#7 Yesterday 06:29:24

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 315
Website GitHub GitLab Mastodon Twitter

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

#8 Yesterday 08:00:12

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,366
Website

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

#9 Yesterday 13:15:20

etc
Developer
Registered: 2010-11-11
Posts: 5,358
Website GitHub

Re: remove trailing slashes

phiw13 wrote #339508:

What Textpattern serves is text/html anyway.

Can not agree, txp can serve whatever you ask it to serve. And this slashless syntax feels wrong, not to mention that it could break etc_query/smd_xml/so_on parsing.

Offline

#10 Yesterday 23:45:26

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,366
Website

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

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,868
Website GitHub

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

Board footer

Powered by FluxBB