html2text icon indicating copy to clipboard operation
html2text copied to clipboard

Support tri-backquote style code block and fix ordered list indent

Open wetor opened this issue 1 year ago • 3 comments

Implement https://github.com/Alir3z4/html2text/issues/386 testcase: test/backquote_code_style

Fix ordered list indent

<ol start="1">
  <li>
    <span>now with numbers</span>
  </li>
  <li>
    <span>the prisoner</span>
  </li>
  <ol start="1">
    <li>
      <span>not an <i>italic number</i></span>
    </li>
    <li>
      <span>a <b>bold human</b> being</span>
    </li>
  </ol>
  <li>
    <span>end</span>
  </li>
</ol>

now it will be correctly converted into

  1. now with numbers
  2. the prisoner
    1. not an italic number
    2. a bold human being
  3. end

testcase : test/mixed_nested_lists

And, regarding the CLI parameter names and variable names in tri-backquote style, I didn't have a good name, so I used backquote_code_style. What do you think?

wetor avatar Nov 04 '24 11:11 wetor

The implementation still has room for optimization, and discussion is welcome.

wetor avatar Nov 04 '24 11:11 wetor

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.42%. Comparing base (2723f84) to head (5ea5c32). Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #431      +/-   ##
==========================================
+ Coverage   97.36%   97.42%   +0.06%     
==========================================
  Files          11       11              
  Lines        1137     1164      +27     
==========================================
+ Hits         1107     1134      +27     
  Misses         30       30              
Flag Coverage Δ
unittests-3.10 97.42% <100.00%> (+0.06%) :arrow_up:
unittests-3.11 97.42% <100.00%> (+0.06%) :arrow_up:
unittests-3.12 97.42% <100.00%> (+0.06%) :arrow_up:
unittests-3.13 97.42% <100.00%> (+0.06%) :arrow_up:
unittests-3.9 97.42% <100.00%> (+0.06%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Nov 13 '24 20:11 codecov[bot]

Hello author, this function is very practical, I used today, but there is no formal package, I hope to merge and release soon

zeMinng avatar Nov 14 '24 13:11 zeMinng