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 for tables text-align not working #804

Closed
mentor-dyun opened this issue Apr 15, 2019 · 2 comments
Closed

Markdown for tables text-align not working #804

mentor-dyun opened this issue Apr 15, 2019 · 2 comments
Labels
Milestone

Comments

@mentor-dyun
Copy link

ContentFormatter strips out the text-align attributes created by the markdown:

sanitize =>

Added config/initializer/thredded.rb:
Thredded::ContentFormatter.whitelist[:elements] += %w[text-align]

But the text-align is still being ignored.

Here is an example of the markdown post. In github preview, it renders the text-align correctly. In Thredded, all the text-align is stripped.

Tables Are Cool
col 3 is left-aligned right-align
@glebm glebm added the bug label Apr 15, 2019
@glebm
Copy link
Collaborator

glebm commented Apr 15, 2019

Marked as a bug, because we should have text-align whitelisted on th and td by default.

In the meantime, try this workaround:

Thredded::ContentFormatter.whitelist.tap do |w|
  %w[th td].each do |t|
    w[:attributes][t] ||= []
    w[:attributes][t] += %w[style]
  end
  w[:css] ||= {}
  w[:css][:properties] ||= []
  w[:css][:properties] += %w[text-align]
end

@mentor-dyun
Copy link
Author

Workaround is perfect! Thanks glebm.

@glebm glebm added this to the v0.16.11 milestone Apr 27, 2019
@glebm glebm closed this as completed in a417053 Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants