CenterForOpenScience / pydocx

An extendable docx file format parser and converter
Other
183 stars 55 forks source link

Paragraph inside listing #227

Open botzill opened 7 years ago

botzill commented 7 years ago

Currently if we want to do smth like this:

screen shot 2017-02-07 at 8 15 52 pm

We end up with:

screen shot 2017-02-07 at 8 16 54 pm

Because currently, when we parse listings, we just add the paragraphs separated by <br/>.

Generated html is:

<p>Paragraph 1</p>
<ul>
    <li>AAA</li>
    <li>BBB <br/>Paragraph 2</li>
    <li>CCC</li>
    <li>DDD</li>
</ul>

Of course we may have other more complex cases including nested lists and so on.

One solution for this would be to properly detect such cases and add some negative margin left to the paragraph depending on the position of the paragraph in the lists hierarchy. For this we need also to take into account the default <li> left margin and properly adjust it for the paragraphs(I did similar to listing margins here #225).

Let me know, please, what you think about this and maybe you have a better alternative.

Thx!