Hi,

This is default behavior of docutils' reST parser. It always generates
paragraph node.

>By default docutils removes these `<p>`:

Please try again with html5 writer. It seems you're using old HTML4
writer. It suppresses <p> tag on generating HTML. But HTML5 writer
does not do that.

Thanks,
Takeshi KOMIYA

2020年8月8日(土) 21:37 Yves Chevallier <canard...@gmail.com>:
>
> I am wondering why Sphinx/Docutils add a paragraph around minor text:
>
> The list:
>
> ```rst
> - foo
> - bar
> - baz
> ```
>
> Will be translated in HTML as:
>
> ```html
> <li><p>foo</p></li>
> <li><p>bar</p></li>
> <li><p>baz</p></li>
> ```
>
> In some case it gives bad formatting especially if `<p>` has some margins.
>
> By default docutils removes these `<p>`:
>
> ```python
> >>> from docutils import core
> >>> print(core.publish_parts('''
> - a
> - b
> - c
> ''', writer_name='html')['html_body']))
> <div class="document">
> <ul class="simple">
> <li>a</li>
> <li>b</li>
> <li>c</li>
> </ul>
> </div>
> ```
>
> But behind the scenes they are still there...
>
> ```python
> >>> from docutils import core
> >>> print(core.publish_parts('''
> - a
> - b
> - c
> ''')['whole'])
> <document source="<string>">
>     <bullet_list bullet="-">
>         <list_item>
>             <paragraph>
>                 a
>         <list_item>
>             <paragraph>
>                 b
>         <list_item>
>             <paragraph>
>                 c
> ```
>
> Why is sphinx acting differently? Is there a way to tell Sphinx to not add 
> paragraphs in such cases?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sphinx-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sphinx-users/f85679d1-395c-4f05-b342-d844c0225e19n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/CAFmkQAOtmaSA0Zbc6y29BH0VsDB3m9EcKeGd4xxKQxWspeovig%40mail.gmail.com.

Reply via email to