Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistent behaviour between image syntaxes
There was inconsistent behaviour between the different syntaxes used for embedding images. The `!!n` syntax must start on a new line. But the previous line can contain other content (e.g. paragraph text). For example, this is valid: ``` Some example content, immediately followed by an image. !!1 ``` Whereas the `[Image:]` syntax had to be preceded by two newline characters (i.e. a new Markdown paragraph). For example: ``` This does not work: [Image: example.jpg] But this does because it's preceded by two newline characters: [Image: example.jpg] ``` This inconsistent behaviour was spotted by publishers after we implemented support for the `[Image:]` syntax in Whitehall Publisher, since they're used to the `!!n` syntax which is more lenient. We've decided to bring the two in line by adjusting the `[Image:]` syntax so that it only needs to be preceded by one newline. This still avoids the issue identified in 663e099 because it does not allow images to be embedded within a paragraph. I've tweaked the `[Image:]` regex and adding extra tests to cover the desired behaviour. I've also added equivalent coverage to the `!!n` syntax tests to explicitly call out this behaviour and ensure the two syntaxes behave consistently.
- Loading branch information