Skip to content
Snippets Groups Projects
Unverified Commit 93857587 authored by Peter Mosses's avatar Peter Mosses Committed by GitHub
Browse files

Improve docs for code highlighting with line numbers (#974)

* Add toc heading custom include

Closes #961.

* Revert "Add toc heading custom include"

This reverts commit 49813c341973e313db0a21f075a60ebf2120989e.

* Update code highlighting with line numbers

- Add the example of code highlighting with line numbers explained in the [Jekyll docs](https://jekyllrb.com/docs/liquid/tags/#line-numbers).
- Fix the styling of narrow code with line numbers, which floats to the centre without this CSS adjustment. (The line numbers column expands as needed with larger numbers of lines, despite using `width`; using `min-width` doesn't work.)

To apply HTML compression, I removed `vendor` from `exclude`; that change is left to a different PR.
parent ce820828
No related branches found
No related tags found
No related merge requests found
...@@ -106,6 +106,7 @@ figure.highlight { ...@@ -106,6 +106,7 @@ figure.highlight {
} }
td.gl { td.gl {
width: 1em;
padding-right: $sp-3; padding-right: $sp-3;
} }
......
...@@ -103,13 +103,24 @@ end ...@@ -103,13 +103,24 @@ end
{% include fix_linenos.html code=code %} {% include fix_linenos.html code=code %}
{% assign code = nil %} {% assign code = nil %}
❌ With the default configuration options, the following example illustrates Narrow code stays close to the line numbers:
{% capture code %}
{% highlight ruby linenos %}
def foo
puts 'foo'
end
{% endhighlight %}
{% endcapture %}
{% include fix_linenos.html code=code %}
{% assign code = nil %}
❌ With the compression options used for the theme docs, the following example illustrates
the **incorrect** formatting arising from the incompatibility of HTML compression the **incorrect** formatting arising from the incompatibility of HTML compression
and the non-conforming HTML produced by Jekyll for line numbers: and the non-conforming HTML produced by Jekyll for line numbers:
{% highlight ruby linenos %} {% highlight ruby linenos %}
# Ruby code with syntax highlighting and unfixed line numbers using Liquid def foo
GitHubPages::Dependencies.gems.each do |gem, version| puts 'foo'
s.add_dependency(gem, "= #{version}")
end end
{% endhighlight %} {% endhighlight %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment