プロジェクト

全般

プロフィール

Vote #81374

完了

Markdown text sections broken by thematic breaks (horizontal rules)

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

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
168
issue_org_id:
35036
author_id:
12098
assigned_to_id:
332
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
152
ステータス-->[Closed]

説明

A "thematic break":https://spec.commonmark.org/0.29/#thematic-breaks composed of hyphens (e.g. "@---@") breaks the division of Markdown text into individually editable sections.

h2. Steps to reproduce

Configure @markdown@ text formatting, create a Wiki page in a web browser and enter the following content:


# Title
## Heading 2
Preceding CRLF is the default for web-submitted data.

---

End of thematic breaks.

## Heading 2
Nulla nunc nisi, egestas in ornare vel, posuere ac libero.

More in the unit tests in the enclosed patch.

h2. Cause

The reason is that it is confused with a "setext heading":https://spec.commonmark.org/0.29/#setext-headings. Although the current regexp in @extract_sections@ actually tries to restrict setext headings in a way that it must follow a non-empty line, it does not account for a whitespace-only line or even plain CRLF. And as long as the text originates from a web browser, there is always a CRLF. So the problem is pretty common even for carefully formated text.

h2. Fix

Attaching a patch with a fix and corresponding unit tests.

h2. Broader context

The current approach to section extraction is inherently fragile - as shown in the other (skipped) unit test enclosed in the patch. I'd suggest to keep the skipped test there to mark it as a known issue. Will create a dedicated issue for this.


journals

--------------------------------------------------------------------------------
Just to make it clear - the skipped test address an already existing error, which is probably not worth fixing with the current approach in @extract_sections@ implementations. See #35037 for more details.

But the particular and common error in thematic break mistreatment is solved by the patch "as is", it can be just applied. :)
--------------------------------------------------------------------------------
Setting the target version to 4.1.4.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the fix. Thank you for your contribution.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,New,35037,Make wiki text section extraction less fragile

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン4.2.2_168 にセット

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

いいね!0
いいね!0