Hello,
UPDATE: phpdocx 10 Premium and newer releases include the stylesReplacementType option in replaceVariableByHTML to use placeholder styles (or mix HTML and placeholder styles if needed).
replaceVariableByHTML adds default styles to the imported contents, existing placeholder styles are replaced by the new ones. Using other replacement methods with inline replacements keep the styles from the placeholders, such as replaceVariableByText.
You need to apply the styles to be used to replaceVariableByHTML through CSS when transforming the HTML. You can get styles applied to contents using getWordStyles: https://www.phpdocx.com/api-documentation/docx-path/get-styles-word-contents-in-docx
You can also use custom styles when generating the DOCX from HTML: https://www.phpdocx.com/documentation/introduction/html-to-word-PHP (Using native Word formatting with HTML section).
If you send a DOCX sample to contact[at]phpdocx.com we'll generate a custom script to illustrate how to accomplish this task.
Regards.