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

Inconsistent code block among different syntax #149

Open
ketozhang opened this issue Mar 30, 2018 · 3 comments
Open

Inconsistent code block among different syntax #149

ketozhang opened this issue Mar 30, 2018 · 3 comments

Comments

@ketozhang
Copy link

ketozhang commented Mar 30, 2018

While Jekyll do recommend liquid code blocks {% highlight language %} ... {% endhighlight %}, I find it these uncommon and inconvenient. I often use Github fenced code blocks with ``` code ``` instead. On chalk, the liquid code block renders differently than both Github and Kramdown's flavor.

# Kramdown's Fenced

~~~html
<!-- This is a comment -->
<div class="grid">
  <h1>This is a heading</h1>
  <p>
    This is a paragraph text.
  </p>
</div>
~~~

# Github's Fenced
```html
<!-- This is a comment -->
<div class="grid">
  <h1>This is a heading</h1>
  <p>
    This is a paragraph text.
  </p>
</div>

The margins in these code blocks are too big

image

{% highlight html %}
<!-- This is a comment -->
<div class="grid">
  <h1>This is a heading</h1>
  <p>
    This is a paragraph text.
  </p>
</div>
{% endhighlight %}

This is perfect

image

Is there a simple CSS fix to this?

@nielsenramon
Copy link
Owner

@ketozhang Can you inspect and check if there is an element that is duplicated or that gets extra padding?

@ketozhang
Copy link
Author

ketozhang commented May 26, 2018

I've forgotten about this since I put the website on hold sorry about that. It's quite obvious something is wrong. The kramdown and github flavor fences are being treated with the same structure as inline code:

Actual

<div class="language-html highlighter-rouge">
    <div class="highlight">
        <pre class="highlight">
            <code>
                <!-- spans -->
            </code>
        </pre>
    </div>
</div>

Expected

<figure class="highlight">
    <pre>
        <code class="language-html" data-lang="html">
            <!-- spans -->
        </code>
    </pre>
</figure>

@nielsenramon nielsenramon reopened this May 27, 2018
@akashjobanputra
Copy link

@nielsenramon highlight class is introducing the extra margin and padding in Github fenced code blocks too.
using {% highlight bash %}:
highlight
and using github fenced:
githubfenced
CSS:
_highlights-datk.scss#L8

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

3 participants