Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions app/controllers/plan_exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 6 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down