プロジェクト

全般

プロフィール

Vote #77635

未完了

Markdown Table formatting breaks with redmine wiki links

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
33
issue_org_id:
23341
author_id:
2240
assigned_to_id:
0
comments:
6
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
118
ステータス-->[New]

説明

When formatting a table in markdown, and inserting internal wiki links via @custom name@, such as:

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

The @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 @]]@.


journals

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:

<pre>
| header | [[FAQ]] | [List of Plugins](Plugins) |
|--------|---------|----------------------------|
| aaa | bbb | ccc |
</pre>

_Disclaimer: I don't know if this workaround would work for cross-project-wiki references..._
--------------------------------------------------------------------------------
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:

!redmine_3.4.2.png!

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

--------------------------------------------------------------------------------
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 '|'.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Thanks Takenori for the patch. I've found out that the regexp does not work when it is trying to replace the @&amp;#124;@ 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:
<pre>
full_document.gsub(/(\[\[(((?![\]\n]|#{pattern}).)+)(#{pattern})(((?![\]\n]|#{pattern}).)+)\]\])/) do |m|
all, page, separater, title = $1, $2, $4, $5
</pre>

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


related_issues

relates,Closed,29852,Cannot use Wiki link with a different name in the table of markdown

Admin Redmine さんがほぼ2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョンCandidate for next minor release_33 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0