ActionText is a power-packed tool to easily build WYSIWYG editors for your Rails applications. It comes with an array of editor options and transformers. One of them is the Plain Text transformer which converts HTML input to plain text output.
Before
As with any editors,
some wonkiness is expected!
When using to_plain_text
on an ActionText content containing nested lists,
the output does not meet expectations.
For example,
when using indentations to indicate nested list levels,
converting to plain text does not preserve the indentation.
However, the expected output is close to:
After
With recent changes in Rails 7 ActionText,
it adds a two-space indentation per nested level for ul
and ol
when using to_plain_text
on action text content!
Which looks like,
To know more about the fix checkout this PR.