How to support scrolling when using pygments with Jekyll

后端 未结 4 1559
眼角桃花
眼角桃花 2020-12-29 07:38

Is it possible to use horizontal scrolling rather than text wrapping in a code section highlughted with pygments when working in Jekyll.

Source of document:

4条回答
  •  悲&欢浪女
    2020-12-29 08:35

    this answer deals specifically with using pygments and jekyll on github pages

    the highlighting is generated thusly:

        
          ... pygments highlighting spans ...
        
      

    the css that will get you where you want is:

    // -- selector prefixed to the wrapper div for collision prevention
    
    .highlight pre code * {
      white-space: nowrap;    // this sets all children inside to nowrap
    }
    
    .highlight pre {
      overflow-x: auto;       // this sets the scrolling in x
    }
    
    .highlight pre code {
      white-space: pre;       // forces  to respect 
     formatting
    }
    

提交回复
热议问题