Open PAvel00m opened 1 month ago
Thanks for the report!
I haven't anticipated this use case as template
in your example is not a fragment, but a complete HTML. However, returning an empty string is confusing indeed. Not sure if it would be better to return an error on non-fragment inputs or just fall back to something like this automatically:
css_inline.inline(template, extra_css="""
body {
font-family: Arial, sans-serif;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
""")
# <html><head></head>
# <body style="font-family: Arial, sans-serif;">
# <table style="border: 1px solid black;border-collapse: collapse;">
#
# <tbody><tr>
# <th style="border: 1px solid black;border-collapse: collapse;">Test</th>
# <td style="border: 1px solid black;border-collapse: collapse;">text</td>
# </tr>
# </tbody>
# </table>
#
#
# </body></html>
In any event, I think the behavior of inline_fragment
should be changed + docs should be updated to reflect this case.
it's just that I use inline_fragment after rendering the jinja2 template and not always the template is html and I then don't have to wrap in tags like BeautifulSoup does
Makes sense! Then, I'd add some fallback for non-fragments to avoid whitespace-only output
I did, it's just the blank line is really confusing. thanks for the reply!
I did, it's just the blank line is really confusing. thanks for the reply!
You are very welcome! To clarify, I meant that I am going to implement it directly in css-inline
, so there is no need to put such conditions in your code. I don't have an ETA, but it should be a relatively simple change, so maybe in a few weeks I'll make a patch release :)
Great, thank you!
Hi, when passing valid html to a function, an empty string is returned
Python 3.8.18 MacOS Sequoia 15.0