Skip to content

markdown: Don't link URLs in code blocks.

Harald Eilertsen requested to merge markdown/dont-link-urls-in-code-blocks into dev

When passing a content throught the markdown_to_bb function to convert any markdown in the content, any recognized URLs in the content would be converted to BBCode links as a post processing step after the main conversion.

After commit a1ccacb8 this did no longer consider content within code blocks, and would thus convert them as to BBCode links.

Example: The following content

[code]
example url: https://example.com
[/code]

Would be converted to

[code]
example url: [url=https://example.com]https://example.com[/url]
[/code]

Prior to commit a1ccacb8, code blocks would be protected, so this would not happen.

This patch removes the post processing step for converting plain URLs to links completely from this routine. This functionality is in any case covered in the actual BBCode parser where it belongs.

This will have some other side effects as well, such as images and links created using Markdown, will not be converted to [zmg] or [zrl] tags where that would be done automatically before. If you intend to use a [zrl] or [zmg] tag, you now need to do so explicitly.

Merge request reports

Loading