How can I embed a YouTube video in a Markdown enabled text field?

回眸只為那壹抹淺笑 提交于 2019-12-23 13:34:06

问题


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.



来源:https://stackoverflow.com/questions/3265534/how-can-i-embed-a-youtube-video-in-a-markdown-enabled-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!