-
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add customizable heading styles configuration #116
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
Conversation
Thanks @DemoMacro ! Someone will QA this soon |
PR Review: feat: add customizable heading styles configurationOverviewThis PR adds comprehensive customizable heading styles configuration to the html-to-docx library. The changes allow users to configure font family, font size, formatting, spacing, and outline levels for headings 1-6. ✅ Strengths
🔍 Issues & SuggestionsCritical Issues
Code Quality Issues
Minor Issues
🛠️ Recommended Fixes
📝 Code Suggestions// Fix spacing logic (line 112+)
<w:spacing w:before="${config.heading1.spacing.before}" ${
config.heading1.spacing.after !== undefined ? `w:after="${config.heading1.spacing.after}"` : ''
} />
// Fix font size handling
${config.heading1.fontSize !== null ? `<w:sz w:val="${config.heading1.fontSize}" />` : ''} 🎯 Overall AssessmentStatus: Needs work before merge The feature is well-designed and useful, but has several implementation issues that should be addressed:
The PR adds valuable functionality but needs refinement to meet production quality standards. |
@DemoMacro - Claude did the above review. The null thing looks wrong to me, but, after doing DRY make sure we handle this properly. |
@nicolasiscoding Thanks for the thorough review! I've made adjustments in my latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR @DemoMacro.
Requested one change
src/schemas/styles.js
Outdated
${generateHeadingStyleXML('Heading1', config.heading1)} | ||
${generateHeadingStyleXML('Heading2', config.heading2)} | ||
${generateHeadingStyleXML('Heading3', config.heading3)} | ||
${generateHeadingStyleXML('Heading4', config.heading4)} | ||
${generateHeadingStyleXML('Heading5', config.heading5)} | ||
${generateHeadingStyleXML('Heading6', config.heading6)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should iterate over it using a map instead of writing like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, I have changed the content to the mapping method.
Code Review - Technical Issues FoundFound several technical issues that should be addressed: 🚨 Runtime Error Risk - Missing Null Safety// src/schemas/styles.js:22-23 - Will crash if heading.spacing is undefined
const spacingAfterXml = heading.spacing.after !== undefined ? `w:after="${heading.spacing.after}"` : '';
const spacingXml = `<w:spacing w:before="${heading.spacing.before}" ${spacingAfterXml} />`; Fix: Add null/undefined checks: const spacingXml = heading.spacing
? `<w:spacing w:before="${heading.spacing.before || 0}" ${heading.spacing.after !== undefined ? `w:after="${heading.spacing.after}"` : ''} />`
: '<w:spacing w:before="0" />'; 🔒 XML Injection Vulnerability// User font names inserted directly into XML without escaping
`<w:rFonts w:ascii="${heading.font}" w:eastAsiaTheme="minorHAnsi" w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi" />` Fix: Escape XML special characters in user inputs
|
Code Review - Technical Issues FoundFound several technical issues that should be addressed: 🚨 Runtime Error Risk - Missing Null Safety// src/schemas/styles.js:22-23 - Will crash if heading.spacing is undefined
const spacingAfterXml = heading.spacing.after \!== undefined ? `w:after="${heading.spacing.after}"` : '';
const spacingXml = `<w:spacing w:before="${heading.spacing.before}" ${spacingAfterXml} />`; Fix: Add null/undefined checks for heading.spacing before accessing properties 🔒 XML Injection Vulnerability// User font names inserted directly into XML without escaping
`<w:rFonts w:ascii="${heading.font}" ...` Fix: Escape XML special characters in user inputs
|
@DemoMacro , kindly rebase against develop and address the final pass of claude code and we should be good to merge and release this. Thank you for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See AI Code review feedback, nice work!
I will test, and if good, we will merge this, then after merging will fix the feedback around:
|
Hey @DemoMacro
|
Add heading configuration options to document options with support for:
I created issues #115