thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 205 forks source link

Underline and Strikeout #185

Closed StrangerGithuber closed 4 years ago

StrangerGithuber commented 4 years ago

Hello Currently I am using the tinymce and I am trying to convert the 'u' and 'strike' tags to __ and ~~. I am developing for a control panel for my Discord chat bot and the discord using __ and underline markdown and ~~ the strikeout text.

In html it looks like this

<strike>test1</strike> 
<u>test2</u>

In markdown it should look like this:

__test1__ 
~~test2~~

How can I make to possible this? Because the current package doesn't want to convert those 2 html tags. Sorry, I am newbie so therefore I am asking. Thank you for the answer in advance. :)

colinodell commented 4 years ago

The CommonMark spec does not support underline or strikethrough text, which is why this library does not natively support converting them. You'd have to create your own instances of ConverterInterface and register them with this library via $environment->addConverter()

See https://github.com/thephpleague/html-to-markdown/blob/master/src/Converter/EmphasisConverter.php for an example you could probably modify to fit your needs.

LudovicFauchet commented 4 years ago

Hello, i have the same request like @StrangerGithuber ,

So i didn't understand how to implement my new converter for <u>.

Thanks for your help

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.