-
-
Save creyer/656e572eb9e3cdea3034b821aecd061e to your computer and use it in GitHub Desktop.
Convert HTML string to Slack's own markup language (https://slack.zendesk.com/hc/en-us/articles/202288908-Formatting-your-messages)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Strip out un-supported HTML tags */ | |
| $content = strip_tags($content, '<strong><em><del><li><code><pre>'); | |
| /* Properly format message */ | |
| $content = str_replace(array('<strong>', '</strong>'), array('*', '*'), $content); | |
| $content = str_replace(array('<em>', '</em>'), array('_', '_'), $content); | |
| $content = str_replace(array('<del>', '</del>'), array('~', '~'), $content); | |
| $content = str_replace(array('<li>', '</li>'), array('•', ''), $content); | |
| $content = str_replace(array('<code>', '</code>'), array('`', '`'), $content); | |
| $content = str_replace(array('<pre>', '</pre>'), array('```', '```'), $content); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment