Remove quotes after using markdownify

I have a data file that contains an array of items. Some of the strings have a colon : character. For that reason I’m using double quotes to wrap the string.

    ...
    - item: Root-certificate of the CA for konfidas from Juni 2018
      description: | 
        "This file contains the root certificate of the CA.
        The fingerprint (SHA-256) of the file is:

        ```
        B7 C7 52 4F C8 E2 DB 58 9B 3F DB 86 02 04 B4 92 BD C9 CC 7A 53 32 2D 5A 53 CE 9E 87 B8 93 68 DD
        ```
        "
    ...

In my template, I’m looping through the items like so:

{{  range .Site.Data.filename }}
  ...
  {{ .description | markdownify }}
  ...
{{ end }}

I expected that the markdown engine would automatically remove the quotation marks; unfortunately it doesn't. Kramdown does that by default, in my experience. How do I go about this using black friday?

This renders fine, without the quotes – that is the purpose of the | character in YAML, to escape otherwise meaningful characters.

---
description: |
  This file contains the root certificate of the CA.
  The fingerprint (SHA-256) of the file is:

  ```
  B7 C7 52 4F C8 E2 DB 58 9B 3F DB 86 02 04 B4 92 BD C9 CC 7A 53 32 2D 5A 53 CE 9E 87 B8 93 68 DD
  ```
---

@zwbetz Thanks for the feedback. I was in fact cognizant of what the pipe character does. My problem is that if I omit those quotes in my data file, I will end up with chunks or strings that look like keys. Please see the attached screenshot.

The string The fingerprint (SHA-256) of the file is: looks like an orphan key when it is in fact part of the description string. Surely this does make the file a little hard to read.

Agreed that it makes the file harder to read, but it works. To me this is an issue with syntax highlighting in the text editor.


But if you still wanted to do it your way, you could just strip out the quotes:

{{ $noQuotes := replace .Params.description "\"" "" }}
{{ $noQuotes | markdownify }}
1 Like

I like the second solution better; because it’s easier to think about. Would be bad to confuse my future self :blush: …, thanks.