Domanda

As in the below picture:

enter image description here

To explicitly point out what I'm talking about, I mean the spaces before every ., +, ], |, and =. As well as probably other punctuation that comes up elsewhere.

I'm using pygments.rb and the Redcarpet gem to format codeblocks that I'm adding to markdown. Each codeblock is surrounded in a .codebox div styled with this SASS (tabbing right in the actual file):

.highlight
  pre
    white-space: pre
    overflow: scroll
    word-wrap: normal

.codebox
    margin: auto
    margin-top: 15px
    margin-bottom: -5px
    padding-right: 8px
    padding-left: 8px
    padding-top: 5px
    padding-bottom: 5px
    padding-top: -20px
    background-color: $codebox
    p
        font-family: 'Rockwell Bold'
        &::selection
            background: $pigPink
            color: #fff
        &::moz-selection
            background: $pigPink
            color: #fff
    pre
        font-family: 'Rockwell Bold'
        font-size: 90%

and then, of course, the markdown ` backticks. If it's relevant, here's my pygments config settings:

application_helper.rb

  class HTMLwithPygments < Redcarpet::Render::HTML
    def block_code(code, language)
      Pygments.highlight(code, lexer: language)
    end
  end

  def markdown(text)
    renderer = HTMLwithPygments.new(hard_wrap: true)
    options = {
      nowrap: true,
      autolink: true,
      no_intra_emphasis: true,
      fenced_code_blocks: true,
      lax_html_blocks: true,
      strikethrough: true,
      superscript: true
    }
    Redcarpet::Markdown.new(renderer, options).render(text).html_safe
  end
È stato utile?

Soluzione

As I said in a comment, you might want to check the css of the resulting code block with web inspector. Pygments works by applying different css rules to different tokens of the resulting code block. It's possible that some of the css you have is clashing with this output and producing the effects you're witnessing, or that your default stylesheet for code blocks is causing this. It should be a simple fix.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top