Youtube shortcode problem when the id contains underscore "_"


#1

Hi there,
I try to embed a YouTube video that contains an underscore to his ID ({{< youtube yia_OqRAlRs >}}) here is the video (https://www.youtube.com/watch?v=yia_OqRAlRs) and I am taking the error:

unrecognized character in shortcode action: U+003C ‘<’. Note: Parameters with non-alphanumeric args must be quoted

My youtube.html file is the following:

<div style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
<iframe src="//www.youtube.com/embed/{{ index .Params 0 }}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>

Any help?

Thanks in advance
Aris


#2

I just tried that with the internal Youtube shortcode (just using your {{< youtube yia_OqRAlRs >}} and it works. So there must be something with your setup.


#3

Thanks for your reply. You are right. It was the export from org-mode to markdown. It was export it like:

{{< youtube yia<sub>OqRAlRs</sub> >}}

Any suggestions about that?

Thanks in advance
Aris


#4

A general remark: If you have problems with shortcode params chars, quote it. This should, however, not be an issue with YouTube ids.


#5

You are right Bjørn. How can I quote this post as an org-mode export issue?


#6

I’d mark this as solved and create a new thread about the org-mode export.


#7

You need to set org-export-with-sub-superscripts to {}. That way a_b will remain as a_b on export; only a_{b} will export to a<sub>b</sub>.

From the Org Manual section (org) Export settings:

‘^:’
     Toggle TeX-like syntax for sub- and superscripts.  If you write
     "^:{}", ‘a_{b}’ will be interpreted, but the simple ‘a_b’ will be
     left as it is (‘org-export-with-sub-superscripts’).

So if you choose not to customize org-export-with-sub-superscripts globally (I’d stronger recommend that you do that though :slight_smile:), you can set this per Org file by adding this to the top of the file:

#+OPTIONS: ^:{}

Update: BTW I just updated ox-hugo (check it out if you haven’t yet! :slight_smile:) to require wrapping to-be-sub/superscripted-text in braces.