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

Allow customizing the table separator #1003

Merged
merged 1 commit into from
Nov 3, 2022
Merged

Conversation

kevinmcconnell
Copy link
Contributor

@kevinmcconnell kevinmcconnell commented Oct 27, 2022

When tables are converted into plain text, Trix inserts a pipe symbol between cells.

In some cases we may want to change how this formatting happens. To allow this, we add some new parser-specific config options, under config.parser:

  • tableCellSeparator (default " | ")
  • tableRowSeparator (default "\n")
  • removeBlankTableCells (default false)

Copy link
Contributor

@afcapel afcapel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, very much worth adding.

Left some comments about some implementation details.

src/trix/config/theme.js Outdated Show resolved Hide resolved
src/trix/models/html_parser.js Outdated Show resolved Hide resolved
src/trix/models/html_parser.js Outdated Show resolved Hide resolved
src/test/unit/html_parser_test.js Outdated Show resolved Hide resolved
@kevinmcconnell
Copy link
Contributor Author

@afcapel Thanks for the review. I've updated this per your feedback, if you fancy taking another look?

Copy link
Contributor

@afcapel afcapel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

When parsing HTML with tables, Trix converts the table contents into a
simple plain text version, using separators between cells and rows. By
default, pipes and newlines are used to format tables like:

    one | two
    three | four

In some cases we may want to change how this formatting happens. To
allow this, we add some new parser-specific config options, under
`config.parser`:

- `tableCellSeparator` (default `" | "`)
- `tableRowSeparator` (default `"\n"`)
- `removeBlankTableCells` (default `false`)
@kevinmcconnell kevinmcconnell merged commit d497d81 into v2 Nov 3, 2022
@kevinmcconnell kevinmcconnell deleted the customise-table-separator branch November 3, 2022 11:52
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 this pull request may close these issues.

None yet

2 participants