Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip trailing space from the lines of an address
There's a feature in the Kramdown parser (i.e. the library that the Govspeak parser is built on top of) where two or more trailing spaces at the end of a line of Govspeak will be converted into an additional line break in the output HTML. Until recently, the contents of address blocks weren't "reparsed" in the Govspeak parser, meaning that they weren't subject to this Kramdown feature. But the Govspeak parser code was recently updated and the contents of address blocks are now reparsed. This has resulted in unintentional additional line spacing being made visible in some addresses that have been rendered by this new version Govspeak. A typical example of the issue looks like: | Name | | Street | | Town | | Postcode | where it would've previously looked like: | Name | Street | Town | Postcode By stripping the trailing space from Govspeak lines within address blocks, we effectively disable the Kramdown feature and prevent unintentional line breaks in addresses going forward. BTW, it's still straightforward to introduce additional line breaks deliberately. _A note on the move to handling the last line of the address separately from the rest:_ In Govspeak, address blocks don't necessarily have a line break between the last line of the address and its closing tag. Until now, where the input Govspeak did have a line break, the output HTML replaced it with a <br>. When there wasn't a line break, the output had no <br>. This difference didn't seem to me to have any impact on the final rendered page in the browser, so I've gone ahead and stopped those <br>s from appearing (as can be seen in the changes we've made here to existing tests). So now, while trailing spaces and backslashes are being stripped from all address lines, in addition to that, for the very last line of the address, trailing line break characters are also being stripped.
- Loading branch information