2018年3月26日星期一

START


  • 一定,每个星期都要写个心得(flag在此立下)
  • 不过,这blog的代码如何插入呢。。。。研究一下

这是google-code-prettify解决方案:

    直接导入样式
    <script src='https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js'/>
    <script src='https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?lang=js&skin=sons-of-obsidian'/>

    之后就可以在标签下使用了
    class Main(object):
        def test(name):
            print('hello world %s'% name)
    
    if __name__ == '__main__':
        m = Main
        m.test(name='kaisen')
    from time import time
    
    
    class Camera(object):
        """An emulated camera implementation that streams a repeated sequence of
        files 1.jpg, 2.jpg and 3.jpg at a rate of one frame per second."""
    
        def __init__(self):
            self.frames = [open(f + '.jpg', 'rb').read() for f in ['1', '2', '3']]
    
        def get_frame(self):
            return self.frames[int(time()) % 3]
   <pre class="prettyprint lang-* linenums> 参数意义
    lang-* : 接语言
    linenums : 显示行号


心得:

    1.干特娘的排版布局,以后写时,注意布局,而且先写文,后插入代码
    2.google-code-prettify在这里无法表现出html文本,可能是模板的原因


引用:

    官方给出的skin方案:
     https://rawgit.com/google/code-prettify/master/styles/index.html
    指导blog:
    1. https://fantasticnote.blogspot.com/2016/08/blogger-code-highlight.html
    2. https://blog.csdn.net/u011127019/article/details/77165062

没有评论:

发表评论