Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra space and different theme in code block exports #55

Closed
ermanno opened this issue Jul 10, 2017 · 2 comments
Closed

Extra space and different theme in code block exports #55

ermanno opened this issue Jul 10, 2017 · 2 comments

Comments

@ermanno
Copy link

ermanno commented Jul 10, 2017

I wanted to use Org mode to write my blog posts with Hugo, and I have some issues with how source code blocks are exported. If I use:

#+BEGIN_SRC python
  def main():
      pass
#+END_SRC

I get the following output:

<pre><code class="language-python">
  def main():
      pass
</code></pre>

which is different from the output I get by using the same synthax I would use if I were writing in Markdown (in particular, graphically it is shifted to the right and with one line before the code, see image below with the three examples), which gives me:

<div class="highlight" style="background: #272822"><pre style="line-height: 125%"><span></span><span style="color: #66d9ef">def</span> <span style="color: #a6e22e">main</span><span style="color: #f8f8f2">():</span>
    <span style="color: #66d9ef">pass</span>
</pre></div>

Furthermore, with that approoach I could do something like:

{{< highlight python "linenos=inline,hl_lines=2 3" >}}
def main():
    i = 2
    j = 3
    pass
{{< / highlight >}}

which would yield the following:

<p><div class="highlight" style="background: #272822"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">1 </span><span style="color: #66d9ef">def</span> <span style="color: #a6e22e">main</span><span style="color: #f8f8f2">():</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span><span style="background-color: #49483e">    <span style="color: #f8f8f2">i</span> <span style="color: #f92672">=</span> <span style="color: #ae81ff">2</span>
</span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span><span style="background-color: #49483e">    <span style="color: #f8f8f2">j</span> <span style="color: #f92672">=</span> <span style="color: #ae81ff">3</span>
</span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">4 </span>    <span style="color: #66d9ef">pass</span>
</pre></div>
</p>

This is how the three examples appear graphically (note how the first code block is shifted below and to the right, compared to the second, one other thing I notice is the different theme... the second and third examples use the settings specified for Pygments, I believe):

@ermanno ermanno changed the title Issue exporting source code blocks Code blocks exported with extra space above/below Jul 10, 2017
@ermanno ermanno changed the title Code blocks exported with extra space above/below Issue exporting code blocks Jul 10, 2017
@ermanno ermanno changed the title Issue exporting code blocks Extra space and different theme in code block exports Jul 10, 2017
@ermanno
Copy link
Author

ermanno commented Aug 1, 2017

I think that this might be due to how client side syntax highlighting (i.e. with highlight.js) have issue dealing with the newline after the opening "code" tag (jekyll/jekyll-help#191).

@ermanno
Copy link
Author

ermanno commented Aug 1, 2017

For the moment I am using this (https://stackoverflow.com/questions/14946908/how-can-i-ignore-leading-and-trailing-linebreaks-within-an-html-code-block-usi) to work around the first line issue, in any case I don't think that it is a problem with goorgeous, but rather with how the highlighter deals with the newline.

@ermanno ermanno closed this as completed Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant