thephpleague / html-to-markdown

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

Lists not converting to *, but - instead #135

Closed bkuhl closed 7 years ago

bkuhl commented 7 years ago

I think I must be missing a step.

$htmlConverter = new HtmlConverter();
$markdown = $htmlConverter->convert($html);

This HTML:

<li>Item1</li><li>Item2</li><li>Item3</li>

Is converting to:

- Item1
- Item2
- Item3

I'm expecting it to come out as:

* Item1
* Item2
* Item3

Are my expectations correct or am I misunderstanding something?

andreskrey commented 7 years ago

Latest commonmark specs says that lists must start with a "bullet list marker" which can be -, + or *.

http://spec.commonmark.org/0.28/#list-items

So I guess html-to-markdown behaves as expected, but giving you less options. Maybe we should have a config param to set the marker type? Is that what you want?

bkuhl commented 7 years ago

Ah, common mark. Wasn't aware that was a thing. Yes, * is needed in my scenario.

andreskrey commented 7 years ago

You can instantiate your own ListConverter and use * instead of -

colinodell commented 7 years ago

Maybe we should have a config param to set the marker type?

I think that's a great idea!

manavo commented 7 years ago

Will try and do this one

colinodell commented 7 years ago

This feature is now available in 4.5.0: https://github.com/thephpleague/html-to-markdown/releases/tag/4.5.0 Thank you @manavo for implementing it!

bkuhl commented 7 years ago

Wow, thanks