nextcloud / text

📑 Collaborative document editing using Markdown
GNU Affero General Public License v3.0
546 stars 88 forks source link

Allow line breaks in table rows #2725

Closed theroch closed 1 year ago

theroch commented 2 years ago

Is your feature request related to a problem? Please describe. We want to have line breaks in table rows to format the text. Othe markdown viewers/editors allow this by using <br> or <br /> tags.

Describe the solution you'd like Support <br> tags or other formating tags to allow line breaks in table rows like this:

| **Org** | **Name** | **Contact** |
|-----|------|--------------|
| Org | Name | E-Mail: my@mail.com <br> Tel: 01/ 123456789 |

Describe alternatives you've considered We already tested with double spaces, \, \n,
nothing works.

Additional context See also https://stackedit.io/app#

juliushaertl commented 2 years ago

Sounds reasonable to support that, even if that is not something that makes the output markdown table very readable.

Any thoughts @max-nextcloud ?

susnux commented 2 years ago

We should support the <br> syntax as this is the most common one, \ is only supported by pandoc (as far as I know).

mejo- commented 1 year ago

Not sure about the <br> syntax as that feels like a first step to introduce HTML into our markdown set. What do others think? @vinicius73, @max-nextcloud, @juliushaertl, @juliushaertl, @jancborchardt?

juliushaertl commented 1 year ago

My main concern about HTML would be that we properly need to ensure to purify/sanitize it, though I think tiptap/prosemirror might already take care of that quite well.

max-nextcloud commented 1 year ago

The security recommendations of markdown-it say:

markdown-it provides 2 possible strategies to produce safe output:

  1. Don't enable HTML. Extend markup features with plugins. We think it's the best choice and use it by default.
    • That's ok for 99% of user needs.
    • Output will be safe without sanitizer.
  2. Enable HTML and use external sanitizer package.

I'd like to avoid enabling HTML. But I think we could support <br> without enabling it. It would require us to parse <br> and <br /> inside a table as a token of it's own and turn it into a <br> tag when parsing the markdown. I think tiptap would handle that <br> tag just fine.

We'd also need to serialize <br> tags in tables to that token in the toMarkdown function of table cells or so.