zoukankan      html  css  js  c++  java
  • 博客园使用sublime text风格的代码高亮样式

      By wenzi FROM cnblogs

      本文地址:http://www.cnblogs.com/xumengxuan/p/3980376.html

      博客园默认显示代码的风格有点丑,于是就想着能不能使用sublime text3的代码高亮,因为本人使用sublime text3编辑C, js, php, html等时,代码高亮的颜色都是本人比较喜欢的。于是就搜到了大神 【刘哇勇】 的博客,按照大神的博客,确实是能设置成功了。

      不过设置完成以后,感觉代码的字体和行间距有些不美观。既然都到这一步了,咱们就自己动手,丰衣足食。于是本人首先在div.highlight里设置{font-family:consolas, courier new; line-height: 18px;}时,代码的行间距变了,但是字体没变,然后在div.hightlight的子节点pre里设置{font-family:consolas, courier new; line-height: 18px;},保存后,查看源代码发现pre里没有刚才设置的属性。

    #include "stdio.h"
    #include "math.h"
    #include "string.h"
    #include "stdlib.h"
    
    // font-family:consolas, courier new; line-height: 18px;
    int main(int argc, char const *argv[])
    {
    	int data[35], _i, n, sum, s1, s2;
    
    	while(scanf("%d", &n), n){
    		sum = 0;
    		for(_i=0; _i<n; _i++){
    			scanf("%d", &data[_i]);
    			sum += data[_i];
    		}
    		s1 = 0, s2 = sum;
    		for(_i=0; _i<n; _i++){
    			s1 += data[_i];
    			s2 -= data[_i];
    			if(s1 == s2){
    				break;
    			}
    		}
    		if(_i>=n){
    			printf("No equal partitioning.
    ");
    		}else{
    			printf("Sam stops at position %d and Ella stops at position %d.
    ", _i+1, _i+2);
    		}
    	}
    
    	return 0;
    }
    

      郁闷,难道我刚才没有保存么,再设置一边,(⊙o⊙)…,在TinyMCE编辑器里倒是看到了CSS的效果,可是保存之后,查看文章的时候,还是没有效果!得,折腾一会儿之后,我得出的方案是:

      当要粘贴代码时,先保存之前写的文章,在“选项”中将编辑器修改为纯文本编辑器,把高亮的代码片段粘贴进去,然后在pre标签里添加上自己设置的属性,成功。不过这里有一个问题:不能把编辑器再设置回默认的,否则刚才添加的就是失效。为什么TinyMCE编辑器会去掉pre里的属性呢?

      好吧,我的方法确实比较麻烦!^_^

    #include "stdio.h"
    #include "math.h"
    #include "string.h"
    #include "stdlib.h"
    
    // font-family:consolas, courier new; line-height: 18px;
    int main(int argc, char const *argv[])
    {
    	int data[35], _i, n, sum, s1, s2;
    
    	while(scanf("%d", &n), n){
    		sum = 0;
    		for(_i=0; _i<n; _i++){
    			scanf("%d", &data[_i]);
    			sum += data[_i];
    		}
    		s1 = 0, s2 = sum;
    		for(_i=0; _i<n; _i++){
    			s1 += data[_i];
    			s2 -= data[_i];
    			if(s1 == s2){
    				break;
    			}
    		}
    		if(_i>=n){
    			printf("No equal partitioning.
    ");
    		}else{
    			printf("Sam stops at position %d and Ella stops at position %d.
    ", _i+1, _i+2);
    		}
    	}
    
    	return 0;
    }
    

    当然,如果要设置行号的话,可以在导出高亮代码之前,进行插件的配置

    也不知道这样的文章可不可以上首页!^_^

  • 相关阅读:
    43. VUE 脚手架 2 版本 新建项目过程
    42 VUE 脚手架 安装 和 基本使用(创建项目)【命令】
    JDBC 原始缺点分析 和 解决
    39-8 WEBPACK —— 搭建本地服务器
    39-7 WEBPACK — js压缩的Plugin
    14. SpringBoot 更换指定的 日志框架
    39-6 打包html的plugin
    39-5 插件 — 添加版权的Plugin
    【HDU 1027】Ignatius and the Princess II
    【洛谷 1896】互不侵犯_new
  • 原文地址:https://www.cnblogs.com/xumengxuan/p/3980376.html
Copyright © 2011-2022 走看看