Page MenuHomePhabricator

Leading spaces in section titles should be removed from HTML
Open, Needs TriagePublicFeature


Currently, it is possible to start section titles on a wiki page with a space. This happens e.g. when using an anchor at the beginning of the title (see this module doc: the first two section titles start with a space, the last two do not). Such leading spaces appear to be invisible in Chrome (and probably most other browsers). However, they are present in the HTML and are displayed in Safari (tested with iOS 15), which gives affected section titles a little indentation. This is very visible in the mobile version when all sections are collapsed.

11A3582B-3306-4626-A864-A8452B2CCCA1.jpeg (739×735 px, 122 KB)

I cannot imagine a use case for section titles with leading spaces. They are also ignored in section IDs and linking. To avoid such unwanted layout quirks, it would be best if the spaces were simply removed from the HTML.

Event Timeline

Actually, it is a browser bug.

An empty <span></span> shall be removed from text flow, and remaining whitespace shall be shrinked to a single space, and a leading space within an <h2> shall be ignored.

That is what HTML says about whitespace when pouring ot text.