node-html-to-text
node-html-to-text copied to clipboard
I can't use unorderedListItemPrefix for orderedList
Hello there, I want to remove the ordered list prefix item: Turn this
1. abc
2. abcd
3. abcde
into
abc
abcd
abcde
I tried to use
- the
formatterto achieve what I wanted but had no luck. selectors: [ { selector: 'ol', options: { itemPrefix: ' ' } } ]
selector ul will work, but ol won't work.
This worked for me.
selectors: [ { selector: 'ol', options: { itemPrefix: ' ' } } ]
So I am wondering is it supported already? Or, is there any workaround I can follow to achieve my goal?
As per Readme, itemPrefix is only taken into account by unorderedList default formatter.
orderedList formatter has no own options and only looks into index type attribute of HTML element.
I'll consider adding some options to orderedList formatter in the future.
To get what you want, you can assign a different formatter to ol selector.
- adding
format: 'unorderedList'toolselector should work and allow the use ofitemPrefix(not intended use but simple enough); - or you can define a custom formatter, albeit in this case it would require copying a significant chunk of code responsible for list formatting that is not exposed.
Thank you for the quick reply; it worked! Thank you!