Passing .Summary to jsonify transforms single quotes

I am running into this issue. I have goldmark set as my markdown handler. I am not clear on the solutions proposed to fix it.

In my case I am generating a JSON file and these two field are getting single quotes replaced with \u0026rsquo;

"description": {{ .Summary | plainify | jsonify }},
      "content": {{ .Plain | jsonify }},

The output:

{
  "url": "/2021/10/savage-1899-reloaded/",
  "title": "Savage 1899 - Reloaded",
  "date_published": "2021-10-14T16:10:49-05:00",
  "date_published_display": "Thursday, October 14, 2021 4:10 PM",
  "description": "I know it\u0026rsquo;s been a while since I last posted. We\u0026rsquo;ve ...",
  "content": "I know it\u0026rsquo;s been a while since I last posted. We\u0026rsquo;ve been ...",
  "tags": ["Savage 1899","Rifle","Reloading"]
},

Keep in mind that .Summary depends on the method used to define it. See this issue.

This will render the same regardless of which of the three methods you use to define the summary.

{{ .Summary | plainify | htmlUnescape | chomp | jsonify }}

You can do the same when rendering .Plain, though the plainify bit is superfluous.

{{ .Plain | htmlUnescape | chomp | jsonify }}

The other way to handle this is to disable Goldmark’s typographer extension. See:

2 Likes

Thanks @jmooring I’ll have a look. I am getting the same issue with .Plain so I’ll test out the options you mention.

Thank You.

Thank you for the solution @jmooring.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.