zoukankan      html  css  js  c++  java
  • markdown分享

    markdown分享

    一、内置函数的补充

    slice:构造一个切片对象,用于列表的切片。

    >>> li = ['a','b','c','d','e','f','g']
    >>> li[slice(3)]
    ['a', 'b', 'c']
    >>> li[slice(1, 3)]
    ['b', 'c']
    >>> li[slice(1, None, 2)]
    ['b', 'd', 'f']
    >>> li[slice(1, None, 1)]
    ['b', 'c', 'd', 'e', 'f', 'g']
    

    round:保留浮点数的小数位数,默认保留整数。

    >>> round(0.5)
    0
    >>> round(1.5)
    2
    ##  if two multiples are equally close, rounding is done toward the even choice ## (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). 
    

    二、markdown是什么

    百度百科

    Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标记语法,它可以使普通文本内容具有一定的格式。
    Markdown具有一系列衍生版本,用于扩展Markdown的功能(如表格、脚注、内嵌HTML等等),
    这些功能原初的Markdown尚不具备,它们能让Markdown转换成更多的格式,例如LaTeX,Docbook。
    Markdown增强版中比较有名的有Markdown Extra、MultiMarkdown、Maruku等。这些衍生版本要么基于工具,如Pandoc;
    要么基于网站,如GitHub和Wikipedia,在语法上基本兼容,但在一些语法和渲染效果上有改动。
    

    内部

    5BkZJX.png

    三、哪里用到markdown

    1. github


    前端框架Vue
    PerfectCRM

    2. gitbook

    黑马上课的课件

    3. 博客类

    1)博客园

    • 博客园设置用markdown为编辑器
      博客园设置用markdown为编辑器
    • 博客园用markdown的效果图
      博客园用markdown的效果图

    我的博客链接

    2)简书(推荐用的在线编辑器,手机端也能用)

    简书链接地址

    • 简书设置用markdown为编辑器
      简书设置用markdown为编辑器

    3)廖雪峰的官方网站

    廖雪峰的官方网站


    4. 笔记类

    有道云笔记

    有道云笔记
    对markdown支持好,个人推荐

    为知笔记

    为知笔记
    只免费100天

    四、为什么用markdown

    1. 优点
    • 学习成本低,学习用时短
    • 语法简单,易用
    • 使用范围广,在编程界也是如此
    • 能引用外部图片、链接
    • 代码高亮
    1. 缺点
    • 不支持本地图片
    • 不支持代码折叠
    • 固定样式,不能展示更炫的效果
    1. 能与思维导图相转化
      百度脑图
      展示链接

    五、怎么用markdown

    简书与博客园同样内容效果展示

    简书
    博客园

    1.选择编写平台

    网络平台:

    简书,新手推荐

    简书

    作业部落(全平台),自动生成目录,展示方便,效果好

    作业部落

    本地编辑器

    notepad++, 要装扩展
    sublime,个人常用,要装扩展,个人推荐
    有道云笔记(全平台)

    2.常用语法介绍

    标题(六个级别)

    # 一级标题            最大
    ## 二级标题
    ### 三级标题
    #### 四级标题
    ##### 五级标题
    ###### 六级标题         最小
    

    代码块

    用一对,三个反引号(就是左上角,Esc键下的那个)把代码包起来。类似python的长文本
    若在行内要对关键字(行内代码)标注,可用一对反引号包起来。
    

    对双下划线的方法名的处理:若不在大的代码块里,就必须用一对反引号包起来。
    __init__();若不包会变成这样子__init__()

    加粗,斜体

    *斜体内容*
    **加粗内容**
    

    效果

    斜体内容

    加粗内容

    有序,无序内容

    1. 1111
    2. 2222
    3. 3333
    4. 4444
    
    - aaaa
    - bbbb
    - cccc
    - dddd
    
    1. 1111
    2. 2222
    3. 3333
    4. 4444

    • aaaa
    • bbbb
    • cccc
    • dddd

    链接

    []()
    [百度](https://www.baidu.com/)
    

    百度

    图片,必须上传到网络上,具体的图片地址

    ![]()  比链接前面多了个!
    ![图片介绍,顺便写,没有找到图片会显示此内容](https://s1.ax2x.com/2018/09/03/5BlAzY.jpg)
    

    图片介绍,顺便写,没有找到图片会显示此内容

    推荐个上传图片,用于展示的网站=====》
    imgse

    分隔线

    --- 细分隔线
    *** 粗分隔线
    

    引用一段话

    > 12345678
    >> 987654321
    

    12345678

    987654321

    下面是分隔线


    上面是分隔线

    其他注意事项

    • 两行在编辑器明明是两行,但可能效果是一行的,就把他们间隔空多一行,
    • 用好分隔线,层次更好。
    • 一些更高级的用法如:表格、甘特图、流程图、公式等在博客园里不能展示。
    • 想要在博客园里展示时自动带上目录,要申请开通javascript.

    博客园里展示时自动带上目录

    页面定制CSS代码

    /*生成博客目录的CSS*/
    #uprightsideBar{
        font-size:12px;
        font-family:Arial, Helvetica, sans-serif;
        text-align:left;
        position:fixed;/*将div的位置固定到距离top:50px,right:0px的位置,这样div就会处在最右边的位置,距离顶部50px*/
        top:50px;
        right:0px;
         auto;
        height: auto; 
    }
    #sideBarTab{
        float:left;
        30px; 
        border:1px solid #e5e5e5;
        border-right:none;
        text-align:center;
        background:#ffffff;
    }
    
    #sideBarContents{
        float:left;
        overflow:auto; 
        overflow-x:hidden;!important;
        200px;
        min-height:108px;
        max-height:460px;
        border:1px solid #e5e5e5;
        border-right:none; 
        background:#ffffff;
    }
    #sideBarContents dl{
        margin:0;
        padding:0;
    }
    
    #sideBarContents dt{
        margin-top:5px;
        margin-left:5px;
    }
    
    #sideBarContents dd, dt {
        cursor: pointer;
    }
    
    #sideBarContents dd:hover, dt:hover {
        color:#A7995A;
    }
    #sideBarContents dd{
        margin-left:20px;
    }
    

    页首Html代码

    <script type="text/javascript">
    /*
        功能:生成博客目录的JS工具
        测试:IE8,火狐,google测试通过
        孤傲苍狼
        2014-5-11
    */
    var BlogDirectory = {
        /*
            获取元素位置,距浏览器左边界的距离(left)和距浏览器上边界的距离(top)
        */
        getElementPosition:function (ele) {        
            var topPosition = 0;
            var leftPosition = 0;
            while (ele){              
                topPosition += ele.offsetTop;
                leftPosition += ele.offsetLeft;        
                ele = ele.offsetParent;     
            }  
            return {top:topPosition, left:leftPosition}; 
        },
    
        /*
        获取滚动条当前位置
        */
        getScrollBarPosition:function () {
            var scrollBarPosition = document.body.scrollTop || document.documentElement.scrollTop;
            return  scrollBarPosition;
        },
        
        /*
        移动滚动条,finalPos 为目的位置,internal 为移动速度
        */
        moveScrollBar:function(finalpos, interval) {
    
            //若不支持此方法,则退出
            if(!window.scrollTo) {
                return false;
            }
    
            //窗体滚动时,禁用鼠标滚轮
            window.onmousewheel = function(){
                return false;
            };
              
            //清除计时
            if (document.body.movement) { 
                clearTimeout(document.body.movement); 
            } 
    
            var currentpos =BlogDirectory.getScrollBarPosition();//获取滚动条当前位置
    
            var dist = 0; 
            if (currentpos == finalpos) {//到达预定位置,则解禁鼠标滚轮,并退出
                window.onmousewheel = function(){
                    return true;
                }
                return true; 
            } 
            if (currentpos < finalpos) {//未到达,则计算下一步所要移动的距离
                dist = Math.ceil((finalpos - currentpos)/10); 
                currentpos += dist; 
            } 
            if (currentpos > finalpos) { 
                dist = Math.ceil((currentpos - finalpos)/10); 
                currentpos -= dist; 
            }
            
            var scrTop = BlogDirectory.getScrollBarPosition();//获取滚动条当前位置
            window.scrollTo(0, currentpos);//移动窗口
            if(BlogDirectory.getScrollBarPosition() == scrTop)//若已到底部,则解禁鼠标滚轮,并退出
            {
                window.onmousewheel = function(){
                    return true;
                }
                return true;
            }
            
            //进行下一步移动
            var repeat = "BlogDirectory.moveScrollBar(" + finalpos + "," + interval + ")"; 
            document.body.movement = setTimeout(repeat, interval); 
        },
        
        htmlDecode:function (text){
            var temp = document.createElement("div");
            temp.innerHTML = text;
            var output = temp.innerText || temp.textContent;
            temp = null;
            return output;
        },
    
        /*
        创建博客目录,
        id表示包含博文正文的 div 容器的 id,
        mt 和 st 分别表示主标题和次级标题的标签名称(如 H2、H3,大写或小写都可以!),
        interval 表示移动的速度
        */
        createBlogDirectory:function (id, mt, st, interval){
             //获取博文正文div容器
            var elem = document.getElementById(id);
            if(!elem) return false;
            //获取div中所有元素结点
            var nodes = elem.getElementsByTagName("*");
            //创建博客目录的div容器
            var divSideBar = document.createElement('DIV');
            divSideBar.className = 'uprightsideBar';
            divSideBar.setAttribute('id', 'uprightsideBar');
            var divSideBarTab = document.createElement('DIV');
            divSideBarTab.setAttribute('id', 'sideBarTab');
            divSideBar.appendChild(divSideBarTab);
            var h2 = document.createElement('H2');
            divSideBarTab.appendChild(h2);
            var txt = document.createTextNode('目录导航');
            h2.appendChild(txt);
            var divSideBarContents = document.createElement('DIV');
            divSideBarContents.style.display = 'none';
            divSideBarContents.setAttribute('id', 'sideBarContents');
            divSideBar.appendChild(divSideBarContents);
            //创建自定义列表
            var dlist = document.createElement("dl");
            divSideBarContents.appendChild(dlist);
            var num = 0;//统计找到的mt和st
            mt = mt.toUpperCase();//转化成大写
            st = st.toUpperCase();//转化成大写
            //遍历所有元素结点
            for(var i=0; i<nodes.length; i++)
            {
                if(nodes[i].nodeName == mt|| nodes[i].nodeName == st)    
                {
                    //获取标题文本
                    var nodetext = nodes[i].innerHTML.replace(/</?[^>]+>/g,"");//innerHTML里面的内容可能有HTML标签,所以用正则表达式去除HTML的标签
                    nodetext = nodetext.replace(/ /ig, "");//替换掉所有的 
                    nodetext = BlogDirectory.htmlDecode(nodetext);
                    //插入锚        
                    nodes[i].setAttribute("id", "blogTitle" + num);
                    var item;
                    switch(nodes[i].nodeName)
                    {
                        case mt:    //若为主标题 
                            item = document.createElement("dt");
                            break;
                        case st:    //若为子标题
                            item = document.createElement("dd");
                            break;
                    }
                    
                    //创建锚链接
                    var itemtext = document.createTextNode(nodetext);
                    item.appendChild(itemtext);
                    item.setAttribute("name", num);
                    item.onclick = function(){        //添加鼠标点击触发函数
                        var pos = BlogDirectory.getElementPosition(document.getElementById("blogTitle" + this.getAttribute("name")));
                        if(!BlogDirectory.moveScrollBar(pos.top, interval)) return false;
                    };            
                    
                    //将自定义表项加入自定义列表中
                    dlist.appendChild(item);
                    num++;
                }
            }
            
            if(num == 0) return false; 
            /*鼠标进入时的事件处理*/
            divSideBarTab.onmouseenter = function(){
                divSideBarContents.style.display = 'block';
            }
            /*鼠标离开时的事件处理*/
            divSideBar.onmouseleave = function() {
                divSideBarContents.style.display = 'none';
            }
    
            document.body.appendChild(divSideBar);
        }
        
    };
    
    window.onload=function(){
        /*页面加载完成之后生成博客目录*/
        BlogDirectory.createBlogDirectory("cnblogs_post_body","h2","h3",20);
    }
    </script>
    

    3.详细的语法链接

    详细的语法链接

  • 相关阅读:
    POJ 2486
    奇怪的电梯
    穿越泥地(mud)
    救援行动(save)
    As Fast As Possible
    Connecting Universities
    They Are Everywhere
    Cells Not Under Attack
    吃饭
    花店橱窗(flower)
  • 原文地址:https://www.cnblogs.com/lanhoo/p/9580660.html
Copyright © 2011-2022 走看看