-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support mixed 'strong' and 'italic' form in the Markdown processor #276
Comments
What you're saying is that, even though the forms Then the regex should be modified so that, instead of having Here's a fix proposal: $str=preg_replace_callback(
'/(?<=\s|^)(?<!\\\\)([*_])([*_]?)([*_]?)(.*?)(?!\\\\)\3\2\1(?=[\s[:punct:]]|$)/',
function($expr) {
if ($expr[3])
return '<strong><em>'.$expr[4].'</em></strong>';
if ($expr[2])
return '<strong>'.$expr[4].'</strong>';
return '<em>'.$expr[4].'</em>';
},
preg_replace(
'/(?<!\\\\)~~(.*?)(?!\\\\)~~(?=[\s[:punct:]]|$)/',
'<del>\1</del>',
$tmp=$str
)
); |
@xfra35 yes it's exactly the issue I've tried to describe, glad you understood because sometimes I'm not clear enough... 👍 but I can't say "it should be supported" as it's to the devs to decide what should be supported but it might be really useful for those who use a client side library that don't give the possibility to specify what characters to use as 'strong' and 'italic'. And this still respect the original Markdown spec that I know you devs want's to follow. |
@xfra35 I've tested your regex on regex101, it took me times to understand how it works but it does the job ! 🤘 well done! |
Hint: I had some similar issues recently (parsing MarkDown e.g. from GitHub with F3s Markdown parser). The final result can be seen here https://www.pathfinder-w.space/ . Click the version number in the header. |
Hello and sorry to disturbing.
If I've understood correctly the code from file
/lib/markdown.php
, to process strong and italic you're counting the recurrence of '_' and '*' characters but you can't mix them, I mean use**_word_**
and get<strong><em>word</em></strong>
in return.So is there a way to support the mixed form?
It took me times to understand the regex used in the code with the website regex101 but I'm lacking skills to support the "mixed" way...
The text was updated successfully, but these errors were encountered: