2014-03-06 59 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