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

Markdown not rendering correctly #5135

Closed
coslajohn opened this issue Jun 20, 2023 · 2 comments · Fixed by #5136
Closed

Markdown not rendering correctly #5135

coslajohn opened this issue Jun 20, 2023 · 2 comments · Fixed by #5136

Comments

@coslajohn
Copy link
Contributor

Description

Type: Bug

Current Behavior

When using the text editor in Collaborative Legislation the markdown for a table renders correctly in the preview part of the text editor.
image

When the process is published and viewed in the process the table doesn't render and the markdown commands are shown as text

image

The opposite behaviour happens with the markdown code for header # It renders correctly in the process but doesn't render in the text editor preview

image
image

Expected Behavior

Markdown elements to render consistently

@karim-semmoud
Copy link
Contributor

Hi @coslajohn
I hope you are doing great.

It looks like the gem Redcarpet has tables: false by default

Can you try this changes
in lib/admin_legislation_sanitizer.rb add tr th td table thead tbody

class AdminLegislationSanitizer < WYSIWYGSanitizer
  def allowed_tags
    super + %w[img h1 h4 h5 h6 tr th td table thead tbody]
  end

  def allowed_attributes
    super + %w[alt src id]
  end
end

in app/models/legislation/draft_version.rb add tables: true

  def body_html
    renderer = Redcarpet::Render::HTML.new(with_toc_data: true)

    Redcarpet::Markdown.new(renderer, tables: true).render(body)
  end

This this changes you can now see the tables
Screenshot from 2023-06-21 10-27-01
Screenshot from 2023-06-21 10-26-30

@coslajohn
Copy link
Contributor Author

Thanks @karim-semmoud that seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants