diff --git a/app/controllers/plan_exports_controller.rb b/app/controllers/plan_exports_controller.rb index b034aa6b51..edb15b3843 100644 --- a/app/controllers/plan_exports_controller.rb +++ b/app/controllers/plan_exports_controller.rb @@ -85,8 +85,8 @@ def show_text def show_docx # Using and optional locals_assign export_format render docx: "#{file_name}.docx", - content: render_to_string(partial: 'shared/export/plan', - locals: { export_format: 'docx' }) + content: clean_html_for_docx_creation(render_to_string(partial: 'shared/export/plan', + locals: { export_format: 'docx' })) end def show_pdf @@ -143,4 +143,11 @@ def export_params :custom_sections, :research_outputs, formatting: [:font_face, :font_size, { margin: %i[top right bottom left] }]) end + + # A method to deal with problematic text combinations + # in html that break docx creation by htmltoword gem. + def clean_html_for_docx_creation(html) + # Replaces single backslash \ with \\ with gsub. + html.gsub(/\\/, '\&\&') + end end diff --git a/db/seeds.rb b/db/seeds.rb index e7a9fbd934..8b4edfc3aa 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -96,10 +96,14 @@ description: '', name: 'English (US)', default_language: false}, - {abbreviation: 'fr', + {abbreviation: 'fr-FR', description: '', - name: 'Français', + name: 'Français (FR)', default_language: false}, + {abbreviation: 'fr-CA', + description: '', + name: 'Français (CA)', + default_language: false}, {abbreviation: 'de', description: '', name: 'Deutsch',