Pushing hyperlinks into text

Preserving style with regex in Coda

A solution to merge variables with a template preserving style

Christiaan Huizer
6 min readDec 28, 2023

--

In my previous blog I showed that Regex removes the layout of your texts.

Regex standardly flattens text, it is the way it operates.

In this blog we show the application of a pack preserving the lay out. It is not an easy thing. We are not going to explain the pack (or how we created it). Instead we show why you may need a solution as shown when working with documents like contracts.

The idea is that it should be simple to create variables and that you are even allowed to make small mistakes in your doc like forgetting a capital or a white space, or putting two white spaces instead of one. These variables are matched. One part is living in the template, the counter part in a table together with the related values, like:

  • first name — Christiaan
  • family name — Huizer
  • city — Ghent
  • Country-Belgium

It is all about easy of use. Certainly in a Coda users can feel overwhelmed by the many options. We try to reduce stress by only showing a few tables.

  • tables with the templates living inside the a canvas column
  • tables with key — value pairs (like first name — Christiaan)

I wrote before about the need for hiding tables. You may want to check it out to understand why I work with only a few visible pages.

Pages & formulas

You have to know that although a page in Coda is a canvas, we have no programmatic access to a page. We have no tools to ask for all the text on a (sub) page to do something with it. In our context of mainly large legal documents, it would be nice to have a page like ‘Memorandum of understanding’ we could work with directly. That is not possible.

[Memorandum of understanding].RegexExtract() // Not possible

Instead we put text in a canvas column and manipulate it there, because we can relate to a row in a table, but — as said — not to the content of any page.

Link documents to

Tables you need — natural language for variables

I already mentioned the need for flexibility and easy of use. When you want to replace a date with for example Jan 03, 2024 then the easiest way for a non technical user is using the variable ‘date’ and not [date] or {date} or _date or {1}. The idea is that it should be intuitive and simple to name a variable. There is of course a consequence. When you use the word date various times in a text, each time it will be replaced with the date value like Jan 03, 2024. The best way to move forwards is to make sure that the variable you apply is unique in your text. Writing a text about ‘dating’ with phrases as: “she had a date” ask for a different variable like thedate or something else you easily remember.

In general I would advice to apply a naming convention that you can apply consequently in most of your texts.

Below the text as it looks without filled out variables in the column named source.

variables inside a template

The text above is the base text and we want to replace keys with values, how that goes you see below.

example of the variables

The great thing about the followed approach is that we can rework the template a bit like by adding bold to the ‘date’, ‘type of transaction’ and red to the payment terms.

This results in what what you see below. We are able to preserve the layout.

The set up

When you want to manage multiple documents for the same parties (like your company and a client or a supplier) you can create multiple templates and you benefit from a table storing these values.

the set up

The remaining question is how to bring in the specific variables. That is not something you want to do manually. Mainly to make sure all details are and remain correct. It would take too long to explain the complete logic. In short you have a tables linked to other docs via cross doc or webhooks and these tables you use to fill out the data. This assumes that the text values become part of a an item database. In the screenshot above I did not go that far to keep the logic simple. In the demo doc however, it is set up in this way, also to prevent that we have for example two ‘date’ variations. Relations make it possible to disable this option by applying a filter in the option settings.

This template shows how you easily can fill out a template, using normal words while you can preserve the style. You can show these filled out contracts and documents to employees, clients, suppliers etc. The print to PDF logic in Coda only got the bear minium of attention of the team. I use the setting ‘legal’ to have create a pdf that looks more or less okay. Alternatively I copy paste all values into a word doc and work from there. I know, it is weird, but the platform offers no proper solution for this long standing issue yet and it seems not on their road map either.

My name is Christiaan and blog about Coda. Since the summer of 2023 mainly about how to Coda with AI to support organisations dealing with texts and templates. The latest Coda AI update was on Dec 7, 2023.

Why I focus on Coda AI you can read here: ⤵️

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. You find my (for free) contributions to the Coda Community and on Twitter.

Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

--

--

Christiaan Huizer
Christiaan Huizer

Written by Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!

No responses yet