gristlabs / grist-core

Grist is the evolution of spreadsheets.
https://www.getgrist.com/
Apache License 2.0
7.14k stars 319 forks source link

Formatting in Grist Cells #1161

Open georgegevoian opened 2 months ago

georgegevoian commented 2 months ago

Describe the problem to be solved

Grist cells don't currently support formatted text (e.g. headings, lists, bold, italic). Custom widgets are available that can display the contents of cells with such formatting (Markdown, Notepad), but there isn't native support in Grist to display the contents of cells as formatted text.

Describe the solution you would like

The document below contains a proposal for a new cell format for Text columns that renders markup as formatted text.

https://docs.google.com/document/d/1-NmB880GjtsyILz2QYkHEHclvC8038xt537XpAqA5NY/edit?usp=sharing

Comments and feedback are welcome.

tayflo commented 2 days ago

Hello there 👋 I've seen that in-cell Markdown is now supported thanks to 292c894b931e4bba77b1ba6ef6a2a625f4704564 (so it puts an end to the old issue #168 which stands out when browsing the history).

I've tested it a bit, it's great! Very handy, including for bold and multi-hyperlinks in a single cell – it was a feature I sought for, thanks a lot for the implementation.

However, two thoughts came to me about about the implementation (if you prefer I open a new issue, or two new issues, for those topics, let me now):

Line breaks

I was wondering about sticking to the original Markdown specification regarding line breaks, i.e. requiring two spaces at the end of the line for an actual line break.

It might arise to be confusing or cumbersome especially for some non-technical users, and especially since it's not the same behavior in the TextBox model. Right now, if I have a TextBox column with some "standard" newlines (just \n) and that I convert the colum to Markdown, all my paragraphs will be displayed as a single line; to fix that, I would have to convert all \n to \n (or \n\n which would add an empty line between paragraphs).

The requirement for two whitespaces is not implemented in some Markdown-style text input areas of other softwares, for instance here in GitHub comments, or in HedgeDocs.

I'm not saying it should necessarily be ruled out, but I'm wondering about it.

Trimming whitespaces

Multi/leading/trailing-whitespaces characters are now stripped out:

  1. In code blocks, which removes proper indentation.
  2. In code spans, which is not what I would usually expect – it does not happen if word-wrapping is activated on the column tho.

In constrast, the GitHub implementation of Markdown works the way I would expect for those two cases.

Example 1

The code-block:

my_list = [1, 2, 3, 4, 5]
def print_items(list):
  for item in my_list:
    print(item)
print_items(my_list)

is rendered as:

2024-10-19T21-48

Example 2

The code-span:

a b c

is rendered as:

2024-10-19T21-52

and when word-wrapping is activated on the column, it's rendered as:

2024-10-20T16-54

Cheers :-)