Defect #23341

Markdown Table formatting breaks with redmine wiki links

Added by Ben Blanco over 3 years ago. Updated 4 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:Candidate for next minor release
Resolution: Affected version:3.2.3

Description

When formatting a table in markdown, and inserting internal wiki links via [[wiki_page_name|custom name]], such as:

| header | [[FAQ]] | [[Plugins|List of Plugins]] |
|--------|---------|-----------------------------|
| aaa    | bbb     | ccc                         |

The [[Plugins|List of Plugins]] will get incorrectly truncated at | which is interpreted as signaling the end of that column, and hence the URL link is not generated as it breaks off before reaching the ]].

redmine_3.4.2.png (3.87 KB) Ben Blanco, 2017-10-11 17:14

23341.patch Magnifier (1.27 KB) Takenori TAKAKI, 2018-11-14 14:19

23341-fixed-regexp.patch Magnifier (1.45 KB) Martin Cizek, 2019-08-01 16:11


Related issues

Related to Redmine - Defect #29852: Cannot use Wiki link with a different name in the table o... Closed

History

#1 Updated by Ben Blanco over 3 years ago

FWIW, in the meantime, the following workaround is available:

Instead of [[wiki_page_name|custom name]] one can write [custom name](wiki_page_name).

Updating the above table example:

| header | [[FAQ]] | [List of Plugins](Plugins) |
|--------|---------|----------------------------|
| aaa    | bbb     | ccc                        |

Disclaimer: I don't know if this workaround would work for cross-project-wiki references...

#2 Updated by Ben Blanco about 2 years ago

FYI - This problem remains in latest redmine v3.4.2 (and its updated redcarpet gem)

In redmine 3.3.x and 3.4.x, it renders as such:

Could this problem be due to redcarpet gem itself, vs. redmine's integration of redcarpet..?

#3 Updated by Go MAEDA about 1 year ago

  • Related to Defect #29852: Cannot use Wiki link with a different name in the table of markdown added

#4 Updated by Takenori TAKAKI about 1 year ago

I confirmed that redcarpet gem cannot distinguish '|'.
To solve this problem, It is necessary to replace '|', before and after redcarpet is formatting Markdown to HTML.
So, I made a patch that overrides Redcarpet::Render::HTML#preprocess and #postprocess methods and replace '|'.

#5 Updated by Go MAEDA about 1 year ago

  • Target version set to Candidate for next minor release

#6 Updated by Martin Cizek 4 months ago

Thanks Takenori for the patch. I've found out that the regexp does not work when it is trying to replace the | placeholder back with |, as the placeholder is multicharacter and used in a character class.
As a result, it does not work if the name contains e.g. numbers 1, 2 or 4.

The solution is to use this regexp:

          full_document.gsub(/(\[\[(((?![\]\n]|#{pattern}).)+)(#{pattern})(((?![\]\n]|#{pattern}).)+)\]\])/) do |m|
            all, page, separater, title = $1, $2, $4, $5

A new patch is attached (it's against Redmine 3.4 though).

Also available in: Atom PDF