写公众号有一年半了,从最初用word写到转换为用markdown。在这个过程中,倍受折磨的就是微信公众号的排版,几乎每次的排版都花费写作时间的两倍。
既然公众号排版如此浪费时间,有没有什么办法可以一劳永逸呢?我试了很多种编辑器,用下来都差不多,决定另辟它径。
李笑来在他的“学习学习再学习”里写过他排版的方法,用markhere插件渲染,他把他编写的markhere的css文件放在了github里,可是我一直没有打开他的链接。
我尝试用这个办法,遗憾的是我一直没有学会怎么科学上网,markhere安装不了,在safari上安装了也用不了,还得另想办法。
最后在简书上搜到一篇文章markdown两键排版微信公众号文章,用这个办法我解决了排版的问题。
这篇文章详细介绍了MarkEditor软件的用法,并且给出了排版风格的css文件:
p{font-size:15px; line-height:28px; color:#595959;font-family:微软雅黑}
pre, code{font-size:14px; font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace;}
code{margin:0 3px; padding:0 6px; white-space: pre-wrap; background-color:#F8F8F8; border-radius:2px; display: inline;}
pre{font-size:15px; line-height:20px;}
precode{white-space: pre; overflow:auto; border-radius:3px; padding:5px10px; display: block !important;}
strong, b{color:#BF360C;}
em, i{color:#009688;}
big{font-size:22px; color:#009688; font-weight: bold; vertical-align: middle; border-bottom:1px solid #eee;}
small{font-size:12px; line-height:22px;}
hr{border-bottom:0.05em dotted #eee; margin:10px auto;}
p{margin:15px 5px!important;}
table, pre, dl, blockquote, q, ul, ol{margin:10px 5px;}
ul, ol{padding-left:10px;}
li{margin:5px;}
lip{margin:5px 0!important;}
ulul, ulol, olul, olol{margin:0; padding-left:10px;}
olol, ulol{list-style-type: lower-roman;}
ululol, ulolol, olulol, ololol{list-style-type: lower-alpha;}
dl{padding:0;}
dldt{font-size:1em; font-weight: bold; font-style: italic;}
dldd{margin:0 0 10px; padding:0 10px;}
blockquote, q{border-left:3px solid #009688; padding:0 10px; color:#777; quotes: none;}
blockquote::before, blockquote::after, q::before, q::after{content: none;}
h1, h2, h3, h4, h5, h6{margin:20px 0 10px; padding:0; font-weight: bold; color:#009688;}
h1{font-size:24px; border-bottom:1px solid #ddd;}
h2{font-size:22px; border-bottom:1px solid #eee;}
h3{font-size:18px; text-align: center;}
h4{font-size:18px;}
h5{font-size:16px;}
h6{font-size:16px; color:#777;}
table{padding:0; border-collapse: collapse; border-spacing:0; font-size:1em; font: inherit; border:0;}
tbody{margin:0; padding:0; border:0;}
tabletr{border:0; border-top:1px solid #CCC; background-color: white; margin:0; padding:0;}
tabletr:nth-child(2n){background-color:#F8F8F8;}
tabletrth, tabletrtd{font-size:16px; border:1px solid #CCC; margin:0; padding:5px10px;}
tabletrth{font-weight: bold; background-color:#F0F0F0;}
将此文件复制到MarkEditor软件中的下方空白处——“将需要注入的css样式填入这里”就OK。按照这个样式出来的文章虽然也很漂亮,但我却希望文章显示的时候能够居中一些,不要那么靠边。因此,我在这个css文件的基础上,稍微做了更改。
我增加了这样几行:
p{padding:0 10px 0 17px;}
blockquote q{background-color:#f8f8ff}
同时,将
blockquote, q{border-left:3px solid #009688; padding:0 10px; color:#777; quotes: none;}
改为
blockquote, q{border-left:3px solid #009688; padding:0 3px; color:#777; quotes: none;}
最后的css文件是:
p{padding:0 10px 0 17px}
p{font-size:16px; line-height:28px; color:#595959;font-family:微软雅黑}
pre, code{font-size:14px; font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace;}
code{margin:0 3px; padding:0 6px; white-space: pre-wrap; background-color:#F8F8F8; border-radius:2px; display: inline;}
pre{font-size:15px; line-height:30px;}
precode{white-space: pre; overflow:auto; border-radius:3px; padding:5px10px; display: block !important;}
strong, b{color:#BF360C;}
em, i{color:#009688;}
big{font-size:22px; color:#009688; font-weight: bold; vertical-align: middle; border-bottom:1px solid #eee;}
small{font-size:12px; line-height:22px;}
hr{border-bottom:0.05em dotted #eee; margin:10px auto;}
p{margin:15px 5px!important;}
table, pre, dl, blockquote, q, ul, ol{margin-left:22px; padding-left:0; margin-right:20px;}
ul, ol{padding-left:10px;}
li{margin:5px;}
lip{margin:5px 0!important;}ulul, ulol, olul, olol{margin:0; padding-left:10px;}
olol, ulol{list-style-type: lower-roman;}
ululol, ulolol, olulol, ololol{list-style-type: lower-alpha;}
dl{padding:0;}
dldt{font-size:1em; font-weight: bold; font-style: italic;}
dldd{margin:0 0 10px; padding:0 10px;}
blockquote, q{border-left:3px solid #009688; margin-left:22px; padding-left:0; margin-right:20px;color:#777; quotes: none;}
blockquote,q{background-color:#f8f8ff;}
blockquote::before, blockquote::after, q::before, q::after{content: none;}
h1, h2, h3, h4, h5, h6{margin:20px 0 10px; padding:0; font-weight: bold; color:#009688;}
h1,h2,h3{text-align: center;}
h1{font-size:24px;}
h2{font-size:22px;}
h3{font-size:21px;}
h4{font-size:19px;margin-left:22px; margin-right:20px}
h5{font-size:18px;margin-left:22px; margin-right:20px}
h6{font-size:17px; color:#009688;margin-left:22px; margin-right:20px}
table{padding:0; border-collapse: collapse; border-spacing:0; font-size:15px; font: inherit; border:0;text-align: center;margin-left:22px; margin-right:20px;}
tbody{margin-left:22px; margin-right:20px;}
tabletr{border:0; border-top:1px solid #CCC; background-color: white; margin:0; padding:0;}
tabletr:nth-child(2n){background-color:#F8F8F8;}
tabletrth, tabletrtd{font-size:15px; border:1px solid #CCC; margin:0; padding:5px10px;}
tabletrth{font-weight: bold; background-color:#F0F0F0;}
做了这些调整以后,出来的文本不太靠边,相对要好看一点。
现在一直这样排版,不那么麻烦了。