From bd884e608cd7adb0100876371c2852814b618441 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Thu, 18 Sep 2025 13:37:12 +0200 Subject: [PATCH] fix(html2pdf): Narrative rules: no-hanging meta when no title, no-break node when no multiline fields --- .../templates/components/node/readonly.jinja | 21 ++++++++++++++- .../components/node_content/index.jinja | 27 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/strictdoc/export/html/templates/components/node/readonly.jinja b/strictdoc/export/html/templates/components/node/readonly.jinja index 45963d8fd..866c971c1 100644 --- a/strictdoc/export/html/templates/components/node/readonly.jinja +++ b/strictdoc/export/html/templates/components/node/readonly.jinja @@ -2,6 +2,22 @@ {% set node_type_string = sdoc_entity.get_node_type_string() %} +{# + dev tag: #narrative_meta_hanging + + Html2pdf4doc rules for `Narrative` requirement style: + * If no multi-line content: + the node is not split at all (with or without a title) + -> add .html2pdf4doc-no-break to node. + * PROBLEM: + We assume that the number of single-line strings is no greater than the height of the page + + FIXME: Review this rules after upgrading html2pdf4doc to 0.2.4+ +#} +{% set _user_requirement_style = sdoc_entity.get_requirement_style_mode() %} +{% set _has_multiline_fields = sdoc_entity.has_multiline_fields() %} +{% set _narrative_has_no_multiline_fields = not _has_multiline_fields and _user_requirement_style == 'narrative' %} + diff --git a/strictdoc/export/html/templates/components/node_content/index.jinja b/strictdoc/export/html/templates/components/node_content/index.jinja index 08858900c..7f225b2d6 100644 --- a/strictdoc/export/html/templates/components/node_content/index.jinja +++ b/strictdoc/export/html/templates/components/node_content/index.jinja @@ -17,12 +17,35 @@ #} {% set user_requirement_style = sdoc_entity.get_requirement_style_mode() %} +{# + dev tag: #narrative_meta_hanging + + Html2pdf4doc rules for `Narrative` requirement style: + * If no title: + “meta” does not hang + -> add .html2pdf4doc-no-hanging to .node_fields_group-secondary. + * If no multi-line content: + the node is not split at all (with or without a title) + -> add .html2pdf4doc-no-break to node. + * PROBLEM: + We assume that the number of single-line strings is no greater than the height of the page + + FIXME: Review this rules after upgrading html2pdf4doc to 0.2.4+ +#} +{% set _no_title = not sdoc_entity.reserved_title %} +{% set _has_multiline_fields = sdoc_entity.has_multiline_fields() %} +{% set _narrative_has_multiline_fields = _has_multiline_fields and user_requirement_style == 'narrative' %} +{% set _narrative_has_no_multiline_fields = not _has_multiline_fields and user_requirement_style == 'narrative' %} + @@ -37,12 +60,12 @@ #} {% if user_requirement_style == 'narrative' %} - + {% include "components/node_field/meta/index.jinja" %} {% include "components/node_field/links/index.jinja" %} {% include "components/node_field/files/index.jinja" %} - {% if sdoc_entity.has_multiline_fields() %} + {% if _narrative_has_multiline_fields %} {% include "components/node_field/statement/index.jinja" %} {% include "components/node_field/rationale/index.jinja" %}