diff --git a/_sass/code.scss b/_sass/code.scss index 759faa3..d2a5ee1 100644 --- a/_sass/code.scss +++ b/_sass/code.scss @@ -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 %}: diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js index 953c615..a3253a1 100644 --- a/assets/js/just-the-docs.js +++ b/assets/js/just-the-docs.js @@ -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 = '';