在科学网写博客,最痛苦的事莫过于排版了。以前写博客都是先在OneNote中码好字,插好图片,排好版,再Ctrl+C, Ctrl+V粘贴到科学网的富文本编辑器中。科学网自带的编辑器对微软文档编辑软件的兼容性还好,排好版的字体格式基本都能保持原样。可是图片就麻烦了,必须再一个一个手动添加到编辑器中。如果图片少的话倒还好,大不了麻烦一下,动动手添加几张图片,而如果文章中的图片多的话,那可就不能忍了,加图片加的都想吐,对人的耐性简直是极大的考验。 好在混迹科学网的人,大部分都是重内容而轻形式的,并且许多人对科学网博客文本编辑器的用户体验也都有一些了解,对排版的要求也就不那么高了,只要将就着能看也就行了。 可是,对于追求完美主义(其实就是强迫症ヾノ≧∀≦)o)的我而言,排版太烂的文章,简直不忍直视。那么,有没有什么方法,能让我的博客排版比较精致,同时又不需要花费太多精力在排版上呢(懒癌又犯了ヾノ≧∀≦)o)?另外,最近在自学生物信息学,有时候会在科学网博客上分享一些学习笔记,而科学网的编辑器对计算机代码的支持不太好,显示非常不美观,有什么方法能改善代码在博客上的显示效果呢? 我一直在寻找解决这两个问题的方法,直到我发现了Markdown和Markdown Here这一对最佳搭档。Markdown语法和Markdown Here插件的结合,完美解决了我的科学网博客排版问题。 1. 什么是Markdown Markdown 是一种轻量级标记语言,创始人为约翰·格鲁伯(John Gruber)。它允许人们「使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档 」—— 维基百科 虽然称作 「标记语言」,但简单理解 Markdown 就是在文本前增加符号来表示文本格式。你不需要关心标题多大号,列表缩进多少,是否对齐,只要使用了同一种符号标记,Markdown 已经帮你做好了排版。——为知笔记 Markdown 新手指南 刚开始接触Markdown时,我对语法记忆是非常抗拒的,感觉要花费脑细胞记忆什么语法规则,好像学习成本很高的样子。 其实,我们常用的标记也就十几个,记忆好的话五分钟就能记住,再加上写一篇博客的练习,就能轻松掌握常用语法了。相对于更为复杂的HTML 标记语言来说,Markdown 可谓是十分轻量的,学习成本也不需要太多,且一旦熟悉这种语法规则,会有一劳永逸的效果。 关于Markdown常用的标记,可参考 为知笔记 Markdown 新手指南 。 2. Markdown编辑器 就像我们平常写东西习惯用Word一样,Markdown也有专用的编辑器。这里提供一个参考: 好用的Markdown编辑器一览 ,可以根据自己的操作系统,选择适合自己的Markdown编辑器。 我用的操作系统是Windows,使用的编辑器是 为知笔记 ,可以在线同步自己的文章,在实验室和家里都能方便地进行创作。这也是一个全平台的软件,我在电脑上写的东西,也可以非常方便地在我的iPhone和iPad上查看。另外,另一款国产笔记类软件 有道云笔记 也支持Markdown,用户体验也不错。网页版编辑器,推荐 简书 ,可以在网页中进行创作,不用安装任何软件,也支持云端存储。 如果你是一个极客,当然也可以使用最简单的记事本等纯文本处理软件进行Markdown的写作,写作完成后,复制-粘贴到博客的编辑器中,可以得到同样的渲染效果。 3. 使用新浪微博图床 Markdown有一点比较特殊,就是图片不能直接插入到文本中,我们需要把要插入的图片先存储在图床上,再以链接的形式插入到文本中。在这里推荐新浪 微博图床 ,和其他图床比,相对稳定和可靠,而且结合Chrome插件使用,可以直接将要使用的图片拖拽到微博图床插件中,自动生成链接,复制粘贴到文本中即可,非常方便。在这里查看 微博图床使用教程。 4. Markdown Here 科学网博客不支持Markdown语法,我们需要借助Markdown Here对Markdown文本进行渲染,得到我们想要的排版格式。 Markdown Here 是个浏览器插件(Chrome/Firefox/Safari),可以将浏览器中编辑器里的 Markdown 文本转换成渲染过后的 HTML。 最初,Markdown here是为在email中排版Markdown而开发的,可是现在已经被广泛应用于微信公众号、知乎专栏等众多写作平台的排版中。 5. Markdown Here渲染CSS的修改 Markdown Here非常人性化的一点就是,我们可以根据自己的喜好,对其渲染的CSS进行修改,可以修改渲染的字体、颜色、行间距等,形成自己独特的风格。 我个人非常喜欢 李笑来的Markdown Here 渲染风格 ,并且李笑来老师已经公开了 源代码 。不过,由于其排版方式是专门为微信公众号优化的,有些地方不太适合电脑网页浏览,并且不支持代码块。因此,我在李笑来老师代码的基础上,进行了修改,使标题的显示更加适合电脑网页,并添加了代码块的支持,目前的渲染结果我还是比较满意的。 经Markdown Here渲染,科学网博客不仅支持常规的文字加粗、斜体、链接等格式,还支持Markdown的表格,并且可以完美支持代码块的显示。 我修改后的CSS渲染代码放在文章末尾,可直接替换Markdown Here 的CSS渲染代码使用。 6. 如何使用Markdown Here 关于如何使用Markdown here进行排版,这里有一篇 简单的教程 ,我就不再重复造轮子了。 简单说就是: 1. 将文章在Markdown 编辑器中编辑好; 2. 复制-粘贴到科学网博客的编辑器中; 3. 点击浏览器中的Markdown Here图标或使用快捷键Ctrl+Alt+M进行一键渲染; 4. 渲染成功,并检查无误后,直接发布。 5. 具体的渲染结果,可参考本文。 注:本文以Markdown语法写作,并经Markdown Here渲染而成。 附: 我修改后的Markdown Here CSS渲染代码,可直接替换Markdown Here基本渲染CSS的代码: /* 说明: 1.本CSS在李笑来老师的Markdown Here的CSS代码的基础上修改而来。 2.修改过程还参考了Markdown Here的默认渲染CSS。 主要做了如下调整。 (1)标题由居中改为靠左 (2)增加了Markdown Here默认渲染CSS的代码块 ————曹务强 2017.11.19 */ /* * NOTE: * - The use of browser-specific styles (-moz-, -webkit-) should be avoided. * If used, they may not render correctly for people reading the email in * a different browser than the one from which the email was sent. * - The use of state-dependent styles (like a:hover) don't work because they * don't match at the time the styles are made explicit. (In email, styles * must be explicitly applied to all elements -- stylesheets get stripped.) */ /* This is the overall wrapper, it should be treated as the `body` section. */ . markdown - here - wrapper { font - size : 16px ; line - height : 1.8em ; letter - spacing : 0.1em ; } /* To add site specific rules, you can use the `data-md-url` attribute that we add to the wrapper element. Note that rules like this are used depending on the URL you're *sending* from, not the URL where the recipient views it. */ /* .markdown-here-wrapper ul { color: red; } */ pre , code { font - size : 14px ; font - family : Roboto , 'Courier New' , Consolas , Inconsolata , Courier , monospace ; margin : auto 5px ; } code { margin : 0 0.15em ; padding : 0 0.3em ; white - space : pre - wrap ; border : 1px solid #EAEAEA; background - color : #F8F8F8; border - radius : 3px ; display : inline ; /* added to fix Yahoo block display of inline code */ } pre { font - size : 1em ; line - height : 1.2em ; } pre code { white - space : pre ; overflow : auto ; /* fixes issue #70: Firefox/Thunderbird: Code blocks with horizontal scroll would have bad background colour */ border - radius : 3px ; border : 1px solid #CCC; padding : 0.5em 0.7em ; display : block ! important ; /* added to counteract the Yahoo-specific `code` rule; without this, code blocks in Blogger are broken */ } strong , b { color : #BF360C; } em , i { color : #009688; } hr { border : 1px solid #BF360C; margin : 1.5em auto ; } /* In edit mode, Wordpress uses a `* { font: ...;} rule+style that makes highlighted code look non-monospace. This rule will override it. */ . markdown - here - wrapper code span { font : inherit ; } /* Wordpress adds a grey background to `pre` elements that doesn't go well with our syntax highlighting. */ . markdown - here - wrapper pre { background - color : transparent ; } /* This spacing has been tweaked to closely match Gmail+Chrome paragraph (two line breaks) spacing. Note that we only use a top margin and not a bottom margin -- this prevents the blank line look at the top of the email (issue #243). */ p { /* !important is needed here because Hotmail/Outlook.com uses !important to kill the margin in p. We need this to win. */ margin : 0 0 1.2em 0 ! important ; } table , pre , dl , blockquote , q , ul , ol { margin : 1.2em 0 ; } ul , ol { padding - left : 2em ; } li { margin : 0.5em 0 ; } /* Space paragraphs in a list the same as the list itself. */ li p { /* Needs !important to override rule above. */ margin : 0.5em 0 ! important ; } /* Smaller spacing for sub-lists */ ul ul , ul ol , ol ul , ol ol { margin : 0 ; padding - left : 1em ; } /* Use Roman numerals for sub-ordered-lists. (Like Github.) */ ol ol , ul ol { list - style - type : lower - roman ; } /* Use letters for sub-sub-ordered lists. (Like Github.) */ ul ul ol , ul ol ol , ol ul ol , ol ol ol { list - style - type : lower - alpha ; } dl { padding : 0 ; } dl dt { font - size : 1em ; font - weight : bold ; font - style : italic ; } dl dd { margin : 0 0 1em ; padding : 0 1em ; } blockquote , q { border - left : 4px solid #DDD; padding : 0 1em ; color : #777; quotes : none ; } blockquote :: before , blockquote :: after , q :: before , q :: after { content : none ; } h1 , h2 , h3 , h4 , h5 , h6 { margin : 1.3em 0 1em ; padding : 0 ; font - style : bold ! important ; color : #009688 !important; text - align : left ! important ; } h1 { font - size : 24px ! important ; border - bottom : 1px solid #ddd !important; } h2 { font - size : 20px ! important ; border - bottom : 1px solid #eee !important; } h3 { font - size : 18px ; } h4 { font - size : 16px ; } table { padding : 0 ; border - collapse : collapse ; border - spacing : 0 ; font - size : 1em ; font : inherit ; border : 0 ; margin : 0 auto ; } tbody { margin : 0 ; padding : 0 ; border : 0 ; } table tr { border : 0 ; border - top : 1px solid #CCC; background - color : white ; margin : 0 ; padding : 0 ; } table tr : nth - child ( 2n ) { background - color : #F8F8F8; } table tr th , table tr td { font - size : 16px ; border : 1px solid #CCC; margin : 0 ; padding : 5px 10px ; } table tr th { font - weight : bold ; color : #eee; border : 1px solid #009688; background - color : #009688; } p code { color : rgb ( 217 , 33 , 66 ); };
## Welcome to MarkdownPad 2 ## MarkdownPad is a full-featured Markdown editor for Windows. Built exclusively for Markdown Enjoy first-class Markdown support with easy access to Markdown syntax and convenient keyboard shortcuts. Give them a try: Bold (Ctrl+B) and Italic (Ctrl+I) Quotes (Ctrl+Q) Code blocks (Ctrl+K) Headings 1, 2, 3 (Ctrl+1, Ctrl+2, Ctrl+3) Lists (Ctrl+U and Ctrl+Shift+O) Chinese Support 中文 Equation \(E=mc^2\) (\\(E=mc^2\\) or $$E=mc^2$$) use script type=text/javascript src=http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default/script to enable Tex-like mathematical expression. $$ E=mc^2 $$ import sysprint sys.pathSee your changes instantly with LivePreview Don't guess if your hyperlink syntax is correct; LivePreview will show you exactly what your document looks like every time you press a key. Make it your own Fonts, color schemes, layouts and stylesheets are all 100% customizable so you can turn MarkdownPad into your perfect editor. A robust editor for advanced Markdown users MarkdownPad supports multiple Markdown processing engines, including standard Markdown, Markdown Extra (with Table support) and GitHub Flavored Markdown. With a tabbed document interface, PDF export, a built-in image uploader, session management, spell check, auto-save, syntax highlighting and a built-in CSS management interface, there's no limit to what you can do with MarkdownPad.