View Issue Details

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

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.


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.


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.


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


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


There are no notes attached to this issue.

Related Changesets

MantisBT: master 95d687d0

2024-03-13 08:10


Committer: community

Details Diff
Markdown processing code cleanup, step 4 - tests

Issue 0034040, PR

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

MantisBT: master 3aec6e68

2024-03-31 23:15


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
- After the markup is returned from Parsedown, apply mentions and links
- Restore the untouched <code> Blocks back in place.

Fixes 0034040, PR
Also fixes 0022315, 0022320, 0024241, 0024628, 0024810, 0022231, 0023738

Signed-off-by: Damien Regad <>
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