docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Use Hugo's native support for processing HTML & markdown, not file extension testing

Open chalin opened this issue 3 years ago • 1 comments

Originally posted by @deining in https://github.com/google/docsy/issues/526#issuecomment-823577659 :

I just realized that shortcode lead treats its .Inner content either as markdown or as HTML, depending on the extension of the page that makes use of the the shortcode:

{{ if eq .Page.File.Ext "md" }}
    {{ .Inner | markdownify }}
{{ else }}
    {{ .Inner | htmlUnescape | safeHTML }}
{{ end }}

Does it make sense to implement this for shortcode feature in a similar way?

IMHO, that is the wrong way to do it. When using a shortcode, one needs to use either {{< >}} or {{% %}} instead, depending on the content of the shortcode (HTML and markdown, respectively).

If we all agree that this is the way to go, then a number of files will need to be changed (which mostly were introduced by #378 I believe):

  • [x] #727
  • [x] layouts/shortcodes/alert.html - #941
  • [x] layouts/shortcodes/card.html - #1376
  • [ ] layouts/shortcodes/blocks/cover.html - #1400
  • [x] layouts/shortcodes/imgproc.html - #1522
  • [x] layouts/shortcodes/blocks/lead.html - #1398
  • [x] layouts/shortcodes/blocks/section.html - #1472
  • [ ] And other shortcodes, see the output of the GH search for .Page.File.Ext "md"

Related:

  • #939

chalin avatar Feb 24 '22 13:02 chalin

Hey @trombonehero - this issue is a proposal to revert #378, which you submitted a little while back. Might you be willing to give some more details concerning your use case, possibly illustrating why docsy -- prior to #378 -- didn't seem to address your needs? Thanks!

chalin avatar Feb 24 '22 13:02 chalin