Author Build Commit PR
flavorjones 16692 96aeac6 n/a
Repo Branch
rails/rails main
Message
Improve character escaping in Action Text markdown generation (#56873) Text nodes in HTML that contain CommonMark metacharacters (like `*`, `[`, `]`, `#`, `<`, `>`, etc.) now have those characters backslash-escaped so markdown renderers treat them as literal text rather than formatting. So, for example, Rich Text content like this:

## Look at *this*

does not become a markdown-formatted heading, instead it renders as ordinary text: \## Look at \*this\* To preserve markdown generated by attachments' `attachable_markdown_representation` method, `Content#to_markdown` wraps the representation in elements. The tree walker recognizes these and passes their content through without escaping. Captions and filenames in `ActiveStorage::Blob` and `RemoteImage` attachment representations are also escaped, and `MarkdownConversion#escape_markdown_text` is now public for use by application custom attachables. This PR is likely escaping Markdown metacharacters where it's not absolutely necessary. We tried to avoid escaping in some obvious cases, but we can continue to refine this in the future by making the regular expression more complex. Co-authored-by: Jeremy Daer

/api

Reference documentation

/guides

In-depth tutorials