1.添加matlab語言高亮
在highlight
的官網https://highlightjs.org/download/,將matlab
勾選,生成下載文件,找到highlight.pack.js
文件,將其引入到博客園頁腳。
這里我已經將該文件上傳至博客園,你可以直接引入:
<script src="https://blog-static.cnblogs.com/files/gshang/highlight.pack.js"></script>
2.調用
在頁腳添加代碼
<script type="text/javascript">
//高亮
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
</script>
3.驗證
在編寫markdown時,仍然可以使用原來的語法
```matlab
% 為輸出創建文件
!touch testFile.txt
fid = fopen('testFile.txt','w');
for i = 1:10
frprintf(fid,'%6.2f \n',i);
end
```
效果如下
% 為輸出創建文件
!touch testFile.txt
fid = fopen('testFile.txt','w');
for i = 1:10
frprintf(fid,'%6.2f \n',i);
end
上述方法適用於其他任意被highlight支持的語言,勾選上對應語言導入js,其他步驟一樣。