OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
feat(fields): include fields label into markdown, so it is included into the "non-dangling header before page break" check
as-opa5f17ab2d8f6
diff --git a/Gemfile b/Gemfileindex 0dc24326f2d..838c28d6e43 100644--- a/Gemfile+++ b/Gemfile@@ -154,7 +154,7 @@ gem 'airbrake', '~> 13.0.0', require: falsegem "hexapdf", "~> 0.32.0"gem 'prawn', '~> 2.2'gem 'prawn-markup', '~> 0.3.0'-gem 'md_to_pdf', git: 'https://github.com/opf/md-to-pdf', ref: '92e4cd63c322d8e27ae6a9e0811f948493732aa4'+gem 'md_to_pdf', git: 'https://github.com/opf/md-to-pdf', ref: '64936d9c8b3f3d558b6da7ca5b09d9a1b10cef53'# prawn implicitly depends on matrix gem no longer in ruby core with 3.1gem 'matrix', '~> 0.4.2'diff --git a/Gemfile.lock b/Gemfile.lockindex 8576234c810..cbeca426f29 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -1,16 +1,16 @@GITremote: https://github.com/opf/md-to-pdf- revision: 92e4cd63c322d8e27ae6a9e0811f948493732aa4- ref: 92e4cd63c322d8e27ae6a9e0811f948493732aa4+ revision: 64936d9c8b3f3d558b6da7ca5b09d9a1b10cef53+ ref: 64936d9c8b3f3d558b6da7ca5b09d9a1b10cef53specs:md_to_pdf (0.0.15)- commonmarker (~> 0.23.6)+ commonmarker (~> 0.23)front_matter_parser (~> 1.0)matrix (~> 0.4)- nokogiri (~> 1.13)+ nokogiri (~> 1.14)prawn (~> 2.4)prawn-table (~> 0.2)- text-hyphen (~> 1.4)+ text-hyphen (~> 1.5)GITremote: https://github.com/opf/omniauthdiff --git a/app/models/work_package/pdf_export/markdown.rb b/app/models/work_package/pdf_export/markdown.rbindex df05ec4a855..a29423e7d5e 100644--- a/app/models/work_package/pdf_export/markdown.rb+++ b/app/models/work_package/pdf_export/markdown.rb@@ -34,6 +34,7 @@ module WorkPackage::PDFExport::Markdowndef initialize(styling_yml)@styles = MarkdownToPDF::Styles.new(styling_yml)+ init_options({ auto_generate_header_ids: false })# @hyphens = Hyphen.new('en', false)end@@ -44,7 +45,7 @@ module WorkPackage::PDFExport::Markdowncm_parse_option = %i[FOOTNOTES SMART LIBERAL_HTML_TAG STRIKETHROUGH_DOUBLE_TILDE UNSAFE VALIDATE_UTF8]root = CommonMarker.render_doc(markdown, cm_parse_option, cm_extentions)begin- draw_node(root, pdf_root_options(@styles.page))+ draw_node(root, pdf_root_options(@styles.page), true)rescue StandardError => eRails.logger.error "Failed to draw markdown pdf: #{e}"end@@ -60,10 +61,6 @@ module WorkPackage::PDFExport::Markdowntext # @hyphens.hyphenate(text)end- def auto_generate_header_ids?- false- end-def handle_unknown_inline_html_tag(tag, _node, opts)result = []case tag.name@@ -116,7 +113,8 @@ module WorkPackage::PDFExport::Markdownstyles: [:bold]},header_1: {- size: 10+ size: 10,+ padding_bottom: 4},header_2: {size: 10diff --git a/app/models/work_package/pdf_export/markdown_field.rb b/app/models/work_package/pdf_export/markdown_field.rbindex 91f2fc1e73f..a8e3c008d37 100644--- a/app/models/work_package/pdf_export/markdown_field.rb+++ b/app/models/work_package/pdf_export/markdown_field.rb@@ -32,25 +32,14 @@ module WorkPackage::PDFExport::MarkdownFielddef write_markdown_field!(work_package, markdown, label)return if markdown.blank?- # TODO: move page break threshold const to style settings and implement conditional break with height measuring- write_optional_page_break(100)- write_field_label! label- write_markdown! work_package, markdown- end-- def write_field_label!(label)- with_margin(label_margins_style) do- pdf.formatted_text([label_style.merge({ text: label })])+ with_margin(margins_style) do+ write_markdown! work_package, "# <font size=\"12\">#{label}</font>\n\n#{markdown}"endendprivate- def label_margins_style+ def margins_style{ margin_top: 12, margin_bottom: 8 }end-- def label_style- { size: 11, styles: [:bold] }- endend