轻松记录您
灵感和创意

用markdown制作简单的个人主页

学校为每个研究者提供一个空间,用于存放个人学术主页,但只能是静态页面。搜了一下,没找到自己满意的模板。后来就想,用Markdown编辑好,再转换成html。事实上,这样做还有一个好处,主页可以在不同设备上显示得很好。动手弄了一个,效果还不错,欢迎围观:Qiankun SU at INP-ENSEEIHT.

1. 使用Python

使用pypandoc,示例代码如下:

#!/usr/bin/env python# -*- coding: utf-8 -*- import pypandoc # With an input file: it will infer the input format from the filenameoutput = pypandoc.convert_file(‘index.md’, ‘html’, outputfile=’index-2.html’)

这样做,只是简单地将Markdown转换成html,我的Markdown文档包含一些法语字符,不能正常显示,需要手动在html文件指定字符编码,即在html文件头部添加如下一行:

encoding = ”

2. 使用命令行

直接在命令行使用pandoc命令,使用-s选项为输出文档添加header和footer,举例如下:

# An example pandoc -f Markdown index.md -t html -Ss > index.html # Parameters-f formatSpecify input format -t formatSpecify output format -S, –smartProduce typographically correct output, converting straight quotes to curly quotes, — to em-dashes, — to en-dashes, and … to  ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as “Mr.” -s, –standaloneProduce output with an appropriate header and footer (e.g.  a standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option is set automatically for pdf, epub, epub3, fb2, docx, and odt output.

这样就会在生成的html文档添加如下内容:

….

再自己手动添加title和icon,举例如下:

3. 转换bibtex

比如我一篇论文的bibtex如下:

@INPROCEEDINGS{su2015xor, author={Q. Su and K. Jaffres-Runser and G. Jakllari and C. Poulliat}, booktitle={2015 IEEE/CIC International Conference on Communications in China (ICCC)}, title={XOR network coding for data mule delay tolerant networks}, year={2015}, pages={1-6}, keywords={Base stations;Delays;Network coding;Protocols;TV;Throughput;Urban areas;Delay tolerant networks;XOR;data mules;network coding;village communication networks}, doi={10.1109/ICCChina.2015.7448634}, month={Nov},}

用上述的方法转换得到的html,得到的是一行,可读性差。使用hard_line_breaks选项,把段落内的newlines转换成换行,而不是空格,举例如下:

pandoc -f Markdown+hard_line_breaks MSWiM16.md -t html -Ss > MSWiM16.html # hard_line_breaksExtension: hard_line_breaksCauses all newlines within a paragraph to be interpreted as hard line breaks instead of spaces.

4. 上传到服务器

把做好的html打包,用scp上传到服务器,举例如下:

qsu@pc-irt18:~/Téléchargements$ scp su_homepage.tar.gz qsu@su.perso.enseeiht.fr:/var/www/su.persoqsu@su.perso.enseeiht.fr’s password: su_homepage.tar.gz                             100% 9475KB   9.3MB/s   00:00

登录到服务器,解压就可以了,举例如下:

ssh su.perso.enseeiht.fr

至此,一个简洁的个人学术主页就有了:-)

未经允许不得转载:坚果云Markdown » 用markdown制作简单的个人主页
分享到: 更多 (0)

坚果云Markdown轻松记录您 灵感和创意

坚果云Markdown下载坚果云Markdown介绍