CollectionBuilder / collectionbuilder-csv

CollectionBuilder-CSV is a "stand alone" template for creating digital collection and exhibit websites using Jekyll and a metadata CSV.
MIT License
21 stars 16 forks source link

Newline character in the description #29

Closed pvperez1 closed 2 years ago

pvperez1 commented 2 years ago

I am searching stackoverflow on how to add a newline character in utf-8 csv but to no avail. I have tried the \n but it is not working. Is it possible to insert a newline character in the description metadata?

evanwill commented 2 years ago

@pvperez1 yes--> when the metadata is feed into the item pages, it is used as HTML, so a new line doesn't change the display (HTML ignores extra white space). So if you want content in your metadata to display with some format, you can use html in your metadata spreadsheet. An easy way to get a line break is to just add <br> in your metadata (replace your \n with <br>). But you could also do more fancy formatting, such as wrapping the parts of the description in paragraph tags <p>.

For example:

title,description
Example Item,"Line one.<br>Line two"
Another Item,"<p>First paragraph.</p><p>Second paragraph, some <strong>bold text</strong>, and a <a href='https://example.com'>link</a>.</p>"

^This will work out of the box. If you want to do more customizing, we have sometimes added a filter to the item layout to parse the metadata fields as Markdown, so that you can write markdown in your spreadsheet. In that case your csv would look like:

title,description
Example Item,"Line one.

Line two"
Another Item,"First paragraph.

Second paragraph, some **bold text**, and a [link](https://example.com)"

Notice, you don't use \n, you just actually put in new lines, but they are inside quoted cells in the csv, so will be interpreted as new lines. In the template, the place where the metadata will be displayed you add the Liquid filter | markdownify to render the markdown to html.

Let me know if that is of interest and I can help set it up!

pvperez1 commented 2 years ago

Ahhh, thank you so much, adding the HTML tags works

evanwill commented 2 years ago

@pvperez1 i just copied my responses over to the CB Discussions since I think these might be useful for others to find!