MarkdownPad2代碼高亮插件兼容移動端樣式


如果不知道MarkdownPad2使用代碼高亮插件可以查看前一篇文章《MarkdownPad2使用代碼高亮插件》

先看移動端效果圖:

移動端點擊查看效果 或者手機掃如下二維碼:

我們經常閱讀微信公眾號文章的時候,常常看到文章內有高亮的代碼,並且這代碼不會換行,可以左右拖動滾動這樣的效果對於我們閱讀代碼很方便也很舒服,上一篇文章使用高亮插件並不兼容移動端,經過簡單的對高亮代碼樣式得修改,再通過markdownpad2導出html,這樣我們就可以在移動端查看自己的代碼筆記了。這個時候有人會納悶我在移動端怎么打開html文件呢?這個我們可以通過githbub建立一個靜態網站的倉庫,這里就不多提了,然后上傳到github,我們就可以移動端訪問自己的代碼筆記啦!當然我只對高亮代碼的樣式進行了修改,后續不斷完善。

css樣式是在sunburst.css基礎上修改的,完整代碼如下:

 

/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */

pre .str, code .str { color: #65B042; } /* string  - green */
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
pre .pun, code .pun { color: #fff; } /* punctuation - white */
pre .pln, code .pln { color: #fff; } /* plaintext - white */
pre .tag, code .tag { color: #89bdff; } /* html/xml tag    - light blue */
pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name  - khaki */
pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
pre .dec, code .dec { color: #3387CC; } /* decimal - blue  */

pre.prettyprint, code.prettyprint {
    background-color: rgb(47, 54, 64);
    border-radius: 8px;
}

pre.prettyprint {
    display: block;
    width: 95%;
    margin: 1em auto;
    padding: 1em;
    box-sizing: border-box;
    overflow: auto;
}


/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { }

@media print {
  pre .str, code .str { color: #060; }
  pre .kwd, code .kwd { color: #006; font-weight: bold; }
  pre .com, code .com { color: #600; font-style: italic; }
  pre .typ, code .typ { color: #404; font-weight: bold; }
  pre .lit, code .lit { color: #044; }
  pre .pun, code .pun { color: #440; }
  pre .pln, code .pln { color: #000; }
  pre .tag, code .tag { color: #006; font-weight: bold; }
  pre .atn, code .atn { color: #404; }
  pre .atv, code .atv { color: #060; }
}

body{margin:0;padding:0}
h2{ font-family: 宋體;}
.prettyprint span{
    line-height:21px;
    font-size:18px;
}
pre code{ width:100%; overflow:auto; display:block;}

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM