[英]Write html tag with Markdown?
在tumblr中,支持降价。 我尝试在我的tumblr中添加一个高亮度 ( highlight.js )的语法,但是遇到了一些问题。
highlight.js需要在HTML代码标记中添加一个类属性。
我试着在我的tumblr中写一篇这样的文章:
<pre class="test">
<code class="html">
function A(){ return "hello world"; }
</code>
</pre>
实际页面中的结果:
<pre>
<code>
function A(){ return "hello world"; }
</code>
</pre>
class属性消失了......是否有可能在Markdown中添加HTML属性?
如果你使用google-code-prettify ,你可以这样做(我目前正在这样做):
$(document).ready(function() {
$('pre').addClass('prettyprint');
prettyPrint();
});
基本上,您加载所有文件:
prettify.css
sunburst.css // optional styles
prettify.js
添加上面的代码片段,并调用prettyPrint
onLoad
: onload="prettyPrint()"
。
上面的代码片段应该在所有文件之前。 它找到所有pre
元素,并将prettyprint
类附加到它,以便脚本知道它的样式。
但是,如果您想使用当前语法高亮显示器,则可以执行以下操作(使用jQuery):
$(document).ready(function() {
$('pre').addClass('test');
$('code').addClass('html');
// code to intialize highlight.js
});
我刚试过,这并不困难。
http://softwaremaniacs.org/soft/highlight/en/description/在第一个代码片段中描述了插入tumblr页面的html以使其工作所需的内容。 在预览模式下,代码段不会加载突出显示。
为了能够使用荧光笔,您需要能够链接样式表和javascript。 如果你没有托管,那么highlight.js的人就可以免费提供托管解决方案。
在<head>...</head>
标记内添加这3行
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.2/styles/default.min.css">
<script src="http://yandex.st/highlightjs/7.2/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
我添加到tumblr上的代码中的所有内容都是
<pre><code class="language-python">
...your code here...
</code></pre>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.