2014-03-06 60 views
0

我正在使用Pygments来语法化一些由用户创建的HTML。Pygments将空格添加到HTML内部

这是我的,注意左边的随机填充。

随机空间也可选择

我使用Ruby来渲染

= raw Pygments.highlight(block.content, lexer: 'html', :options => {:lineanchors => "line", :lineos => true}) 

代码块而这里的造型...

pre { 
    counter-reset: line-numbering; 
    border: solid 1px #d9d9d9; 
    border-radius: 0; 
    padding: 0; 
    line-height: 23px; 
    margin-bottom: 30px; 
    white-space: pre; 
    word-break: inherit; 
    word-wrap: inherit; 
    width: inherit; 
    overflow: scroll; 
} 

pre a::before { 
    content: counter(line-numbering); 
    counter-increment: line-numbering; 
    padding-right: 1em; /* space after numbers */ 
    width: 25px; 
    text-align: right; 
    opacity: 0.7; 
    display: inline-block; 
    color: #aaa; 
    background: #eee; 
    margin-right: 16px; 
    padding: 2px 10px; 
    font-size: 13px; 
    border-right: 1px solid #dedede; 
    -webkit-touch-callout: none; 
    -webkit-user-select: none; 
    -khtml-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
} 

pre a:first-of-type::before { 
    padding-top: 10px; 
    @include box-shadow(rgba(255, 255, 255, 0.9) 0px 1px 1px inset); 
} 

pre a:last-of-type::before { 
    padding-bottom: 10px; 
} 

pre a:only-of-type::before { 
    padding: 10px; 
} 

这是一个Pygments来做主题的顶部,我使用的是秋天,看到这里https://github.com/richleland/pygments-css

位感到困惑,是什么导致了这种神秘的白色空间,但如果有人可能知道或者已经经历过这个问题,它会是前不胜感激。

感谢

回答

0

我使用redcarpet有同样的问题。问题起源于Haml,并解决了在初始化程序中添加此行。

Haml::Template.options[:ugly] = true