New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem when centering images in bullet list with HtmlModule #655
Comments
Interesting, I see having an "img" inside a "li" tag that has a block property is causing this behavior. It will work if you use the following styleSheet :
|
Using this stylesheet will work, however, I'm not sure whether to do changes here. The possible behaviors would be the following :
|
If
|
Helo @vdechef , I totally agree with you, the point of HTML in general is to be permissive and avoid errors as much as possible, and that also is the direction that we should use for the docxtemplater-html-module specifically. I have just implemented solution 2 and released it in the docxtemplater-html-module version 3.30.2 which I have just released. |
Hello @vdechef , it has something to do with the update from htmlparser2 version 7.x to htmlparser2 version 8.x |
Since htmlparser2 version 8.x, the package.json defines multiple exports fields : Webpack will by default use the "module" entry of the package.json : https://github.com/fb55/htmlparser2/blob/master/package.json#L34 This means that it will load the file from "lib/esm/index.js". I think that in your webpack configuration, you need to have the appropriate loader to be able to parse the "export" statement (and other ESM specific syntax) You most probably currently have something like this :
You should rather use include like this :
I've inspired this answer from here : webpack/webpack#2017 |
Thanks @edi9999. |
Using:
I use the suggestion from #611 and it works well : the images included in my html page are rendered centered.
The problem arises when the image is included in a bullet list: the resulting docx file is corrupted and Word cannot open it.
Below is a minimal script to reproduce this behavior. The resulting docx file will display 2 images : one in a bullet list (wrapped in a text line), and one outside of the bullet list (centered). Notice that removing the
display: block;
line prevents the file to be corrupted, but then no image is centered.The template contains only
{~~html}
.I tried to reproduce this using the demo page, but it seems like stylesheet does not work in this demo for centering image ...
The text was updated successfully, but these errors were encountered: