Format() with style

Following the discovery of big buttons, I was tempted to see if something similar was possible with Format() — namely if one could supply a Big Cell formatted content as a template for the Format() function.

Answer: YES! although a bit limited.

What is preserved when the text is pasted into the {1} {2} etc templates:

  • Paragraph formatting: headers, lists, code blocks, text alignment etc

What is NOT preserved:

  • Span formatting: text color and highlight, bold/italic/etc. It gets overwritten with the formatting of the inserted value.
    So if you want to make inserted values e.g. bold, you’ll have to use hidden functions like _Bold() and _Color() to style the template arguments explicitly.

Demo:

4 Likes

Yes I have been experimenting with this. Another thing to note is that you don’t seem to be able to mix and match formatting style on a line, atleast when it comes to Headings - you can’t have an H3 - description text on the same line.

Yeah, you can’t — paragraph styling is stored separately from span (character-level) styling. There’s a way to inspect this by force-rendering cells into their inner object representations

Could you make your demo “play” mode or allow us to copy it, so we can see the formulas. Thank you!

For those wondering why _Bold() is not working on datetime columns, you have to do .ToText()._Bold() first.

1 Like

Not just datetime but any “embed values”: numbers (percents, currencies) and references too. Those have to be converted .ToText() before styling can be applied.

Not at the PC right now, will update sharing settings later. I’m using this trick a lot in my Best Practices Showcase though. Such a ubiquitous solution nowadays, even Codans now use it casually.

Also — not just Big Cell anymore, you can use Canvas columns as templates with extra formatting (namely columns). See my POS interface here:
Prefab Production Doc - YouTube (at about 1:20:00)

1 Like

Created a pack to make this stuff way easier

7 Likes

Hey everyone,

I’m a Product Manager at Coda and I wanted to let you know about the new Compose column type we just launched, which eliminates the need to use the Concatenate() and/or Format() formulas to compose dynamic text.

Compose gives you a freeform editor that lets you write and format text, including references to columns (using @) and formula results (using =). The resulting dynamic content can then be referenced by other columns.

Please give it a try and let us know if it helps address some of these types use cases.
Compose-min

12 Likes

So cool !!! Thanks Ramesh and coda team, it will make it much more efficient !

Hey @Paul_Danyliuk, thanks so so much for all the free guidance you’ve offered here!
This response references “force-rendering cells into their inner object representation.” But I don’t see anything about this in the A somewhat of a documentation of hidden formulas [Added mechanics of nested buttons].

I’m looking for a way to re-build a cell after tearing it apart with merge()+“” The use case here, really, is having ChatGPT respond to a query in the merge()+“” JSON format, then build it back with proper formatting. Right now, ChatGPT through the OpenAI() pack only render as body text. But it would be super helpful if we could have ChatGPT respond in JSON that autoformats in a Coda cell.

Any ideas?
Thanks!