使用Markdown寫Blogger
在Blogger版面配置新增HTML/Javascript小工具, 增加以下CODE
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.6.4/showdown.min.js"></script> <script> var converter = new showdown.Converter(); var posts = document.querySelectorAll(".post-body,.snippet-item"); Array.prototype.forEach.call(posts, function(el, i){ if(el.innerHTML.indexOf("markdown") <= 1){ el.innerHTML = converter.makeHtml(el.innerHTML.replace("markdown","")); } }); var pres = document.querySelectorAll("pre"); Array.prototype.forEach.call(pres, function(el, i){ el.classList.add("prettyprint"); }); </script> <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sunburst"></script>
就可以在Blogger的HTML模式寫Markdown語法了。
※ 實測後, 發現若Markdown Code是包含<script>...</script>或可能有使用到特殊的語法, Markdown解析會失敗
ref web:
https://etrex.blogspot.com/2017/03/blogger-code-markdown-prettyprint.html
https://hackmd.io/@CynthiaChuang/Using-Markdown-to-Write-Blog-Posts
留言
張貼留言