Skip to content
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

Fix error message from linting a docx file with invalid syntax #470

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ghostwriter/modules/reportwriter/base/docx.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ def lint(cls, template_loc: str, p_style: str | None) -> Tuple[List[str], List[s
)
logger.info("Template loaded for linting")

for variable in exporter.word_doc.get_undeclared_template_variables(exporter.jinja_env):
undeclared_variables = ReportExportError.map_jinja2_render_errors(
lambda: exporter.word_doc.get_undeclared_template_variables(exporter.jinja_env),
"the DOCX template"
)
for variable in undeclared_variables:
if variable not in lint_data:
warnings.append("Potential undefined variable: {!r}".format(variable))

Expand Down