-
Notifications
You must be signed in to change notification settings - Fork 0
Support formatting of alert boxes #18
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
Conversation
0dbf128
to
bfcfbd8
Compare
b108464
to
8508105
Compare
8508105
to
d6964b9
Compare
plugin/awesoMD/plugin.js
Outdated
@@ -700,6 +701,62 @@ const plugin = () => { | |||
throw error | |||
} | |||
}, | |||
|
|||
renderMarkdownAlerts: function (content) { | |||
const alertRegex = /> \[!(\w+)]\s*(.*)/gm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this regex will NOT catch these inputs, which GitHub is happily working with:
multi line
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
> an other line
multiple spaces after >
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
But it will catch these inputs, that GitHub does not use as alert boxes:
invalid type
> [!something]
> Advises about risks or negative outcomes of certain actions.
empty line between type and text
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
double >
>> [!CAUTION]
>> Advises about risks or negative outcomes of certain actions.
missing new line
> [!CAUTION] Advises about risks or negative outcomes of certain actions.
I think we need tests here to make sure all those and other cases work correctly
plugin/awesoMD/plugin.js
Outdated
|
||
if (match) { | ||
const type = match[1].toLowerCase() | ||
const message = match[2].replace(/^>\s*/, '').trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about ?
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
Is that a valid input? At least for GitHub it is. But I think the replace will not catch it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
> Advises about risks or negative outcomes of certain actions.
It looks like github only removes >
if only it is in the beginning of the line.
plugin/awesoMD/plugin.js
Outdated
|
||
const alertIcon = document.createElement('span') | ||
alertIcon.classList.add('alert-icon') | ||
alertIcon.innerHTML = alertIcons[type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if alertIcons
does not have an item with the type
?
You could have a check here, then the regex does not need to contain all types. Or you construct a complicated regex dynamically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, i have updated the code and it will be a normal block quote.
4b5b1a7
to
7987abc
Compare
7987abc
to
48b8319
Compare
Description
This PR adds the functionality to support the formatting of alert boxes in the presentation slides.
Screenshot
Input markdown content
Rendered output:
Related WP
https://community.openproject.org/projects/revealjs/work_packages/60582/activity