mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-08 04:51:23 -06:00
Fix AsciiDoc code block styling (#1168)
These changes accommodate for some difference in the HTML structure AsciiDoc produces for source code listings: * proper padding for source code listings * proper vertical margin after source code listings * proper placement of the copy button if enabled Closes #1163
This commit is contained in:
parent
f8e93980b4
commit
fdf48d2fd3
@ -50,6 +50,11 @@ a:visited code {
|
||||
// Kramdown line_numbers = true: fences have a wider gutter than with Liquid?
|
||||
|
||||
// ```[LANG]...```
|
||||
// or in AsciiDoc:
|
||||
//
|
||||
// ----
|
||||
// ...
|
||||
// ----
|
||||
|
||||
// the code may appear with 3 different types:
|
||||
// container \ case: default case, code with line number, code with html rendering
|
||||
@ -59,6 +64,7 @@ a:visited code {
|
||||
// last level: code, pre, code (optionality)
|
||||
// highlighter level: span, span, span
|
||||
// the spacing are only in the second level for case 1, 3 and in the third level for case 2
|
||||
// in AsciiDoc, there is a parent container that contains optionally a title and the content.
|
||||
|
||||
// select top level container
|
||||
div.highlighter-rouge,
|
||||
@ -111,17 +117,17 @@ figure.highlight {
|
||||
}
|
||||
|
||||
// setting the spacing and scrollbar on the second level for the first case
|
||||
// remove all space on the second and thirt level
|
||||
div.highlighter-rouge,
|
||||
div.listingblock {
|
||||
div.highlight {
|
||||
// remove all space on the second and third level
|
||||
// this is a mixin to accommodate for the slightly different structures generated via Markdown vs AsciiDoc
|
||||
@mixin scroll-and-spacing($code-div, $pre-select) {
|
||||
#{$code-div} {
|
||||
overflow-x: auto;
|
||||
padding: $sp-3;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
pre.highlight,
|
||||
#{$pre-select},
|
||||
code {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
@ -129,6 +135,19 @@ div.listingblock {
|
||||
}
|
||||
}
|
||||
|
||||
// for Markdown
|
||||
div.highlighter-rouge {
|
||||
@include scroll-and-spacing("div.highlight", "pre.highlight");
|
||||
}
|
||||
|
||||
// for AsciiDoc. we also need to fix the margins for its parent container.
|
||||
div.listingblock {
|
||||
@include scroll-and-spacing("div.content", "div.content > pre");
|
||||
|
||||
margin-top: 0;
|
||||
margin-bottom: $sp-3;
|
||||
}
|
||||
|
||||
// {% highlight LANG %}...{% endhighlight %},
|
||||
// {% highlight LANG linenos %}...{% endhighlight %}:
|
||||
|
||||
|
@ -488,7 +488,7 @@ jtd.onReady(function(){
|
||||
|
||||
jtd.onReady(function(){
|
||||
|
||||
var codeBlocks = document.querySelectorAll('div.highlighter-rouge, div.listingblock, figure.highlight');
|
||||
var codeBlocks = document.querySelectorAll('div.highlighter-rouge, div.listingblock > div.content, figure.highlight');
|
||||
|
||||
// note: the SVG svg-copied and svg-copy is only loaded as a Jekyll include if site.enable_copy_code_button is true; see _includes/icons/icons.html
|
||||
var svgCopied = '<svg viewBox="0 0 24 24" class="copy-icon"><use xlink:href="#svg-copied"></use></svg>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user