Use Markdown in Blogger Posts with HTML Editor
Approach
Previously in the URL Shorten Worker for a Markdown Journal solution, the page content
Practice
When creating a new post in Blogger, switch to the HTML view.
Paste the markdown text in. For example,
- 演示视频
https://www.youtube.com/watch?v=DZcXqyIm_R0
- 演示站
https://journal.crazypeace.workers.dev/journaljournal
- Github
https://github.com/crazypeace/url-Shorten-Worker/
- 搭建过程
https://www.nodeseek.com/post-58723-1
最后把这几行改一下就行. 第3行定义了操作页面. 第7行定义了保存key-value时,是否检验已经存在key. 第11行定义了一些系统的行为.

对了, Markdown 要用到图床, 可以用这个 https://www.nodeseek.com/post-60815-1
Publish it as a formal post.
Then check the source of this page and find that the HTML part of the body has a class of post-body entry-content
class='post-body entry-content'
In Blogger, go to Theme - Edit HTML
Add the following JS content.
document.addEventListener('DOMContentLoaded', function() {
// 获取所有具有 "post-body" 类的元素的第1个, 也就是博文的正文
const blogContent = document.getElementsByClassName("post-body")[0];
// 获得markdown文本
const markdownContent = blogContent.textContent;
// 转换为html再放到博文正文内容
blogContent.innerHTML = marked.parse(markdownContent);
});
========
Done
Put it on Github
You can use it like this
========
Postscript
My blog is not pure markdown content; I still want to stick with my original way of using it.
So I created a demo site
https://use-markdown-in.blogspot.com/2024/10/markdown-demo.html
