View Issue Details

IDProjectCategoryView StatusLast Update
0034040mantisbtmarkdownpublic2024-04-03 12:37
Reporterhotzeplotz Assigned Tocommunity  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Target Version2.27.0Fixed in Version2.27.0 
Summary0034040: Markdown processing code cleanup (part 2)
Description

Track remaining changes in 0030919 that were not implemented in 2.26.0.

4. cleanup the blockHeader part

The Tests testHashLetters, testHashNumberAny and testHashLettersAny failing.

  • invert the logic, do not search for a valid markdown heading, search for a valid "buglink" instead.
  • Change regex to be more generous with the use of colons.
  • Add test for the regular expression.

The Tests testHashLetters, testHashNumberAny and testHashLettersAny are successfully again afterward.

todo: Clarify what a valid issue mention is.

| input            | is issue mention     |
|------------------|----------------------|
| `#1`          | true                 |
| `#123 `          | true                 |
| ` #123 `         | true                 |
| `#123 `          | true                 |
| `#123 summary`   | true                 |
| `#123: summary`  | true                 |
| `#123:summary`   | true                 |
| `#123:: summary` | true but should not? |
| `#123summary`    | false                |
| `# 123:summary`  | false                |
| `# summary `     | false                |
| `# 123`          | false                |

Modify the regex to meet the mantis requirements.

see https://github.com/mantisbt/mantisbt/pull/1929

5. cleanup formatting process

  • Rearrange the processing. Moving the Markdown part before ON == $s_text, return the result and do not doing further processing.
  • Make MantisMarkdown know about the plugin config and process the links and mentions within the parser context
  • mark all the methods that make use of $this->processAmpersand() as deprecated, because the output is no loger messed up.
  • remove all methods which marked as "deprecated"

Parsedown provides a usefull method called unmarkedText, which make all "unmarked" strings accessible. Seems the right place to process the links.

see https://github.com/mantisbt/mantisbt/compare/master...grummbeer:mantisbt:markdown-cleanup-05-formatting

After that and merging all parts together the whole part looks very nice and its a huge impact for user experience.

The branches are all independent but could make it a cascading series. What do you think about? I am not experienced in contributing, so this may look strange to you, but I have no idea what the right approach is.

todo

  • the tests are now failing because MantisMarkdown.php is getting the plugin config using plugin_config_get, which is not available inside the unit tests. Make it possible to pass a configuration to the MantisMarkdown?
  • emails still not proceed with markdown. hidden deep inside string_insert_hrefs make a new api function to catch them?
  • add prism to raise up the user experience.

Fixing this todos would be a really nice finishing point.

TagsNo tags attached.

Relationships

related to 0030919 closeddregad Markdown processing code cleanup 
related to 0034124 assignedcommunity Add syntax highlighting to markdown codeblocks 
related to 0034393 closeddregad Incorrect handling of HTML hexadecimal character references &#xNNN; 

Activities

There are no notes attached to this issue.

Related Changesets

MantisBT: master 95d687d0

2024-03-13 08:10

grummbeer

Committer: community


Details Diff
Markdown processing code cleanup, step 4 - tests

Issue 0034040, PR https://github.com/mantisbt/mantisbt/pull/1929

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0034040
mod - plugins/MantisCoreFormatting/tests/MarkdownTest.php Diff File

MantisBT: master 3aec6e68

2024-03-31 23:15

grummbeer

Committer: dregad


Details Diff
Clean up markdown processing

- Process input via Markdownparser and return the result, no further
text processing.
- During parsing, catch all <code> blocks and replace them with a hash
value.
- After the markup is returned from Parsedown, apply mentions and links
- Restore the untouched <code> Blocks back in place.

Fixes 0034040, PR https://github.com/mantisbt/mantisbt/pull/1976
Also fixes 0022315, 0022320, 0024241, 0024628, 0024810, 0022231, 0023738

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0022231, 0022315, 0022320, 0023738, 0024241, 0024628, 0024810, 0034040, 0034393
mod - plugins/MantisCoreFormatting/MantisCoreFormatting.php Diff File
mod - plugins/MantisCoreFormatting/core/MantisMarkdown.php Diff File