How can I embed a YouTube video in a Markdown enab

2019-06-26 06:34发布

问题:

This is the code I'm trying to embed:

<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jJECepNeCJ0&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jJECepNeCJ0&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

The interesting thing is that this code seems to display the embedded video in the Preview immediately below the form. Once the form is saved, the code snippet is rendered as text.

回答1:

It works fine for me.
Make sure your code snippet doesn't have four spaces before it.



回答2:

You're probably going to have to extend whatever markdown filter you're using (assuming django.contrib.markup) to ignore <object> tags.

If you're using some sort of Javascript editor in your form, it may be converting the < to &lt; before it is saved into your database. In this case, you may have to change the editor.