syntaxhighlight: fix behavior for noClasses=true #569

This commit is contained in:
Sören Weber 2023-06-15 23:17:27 +02:00
parent 5218972b06
commit d319d92d98
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 9 additions and 6 deletions

View file

@ -667,17 +667,17 @@ pre code {
}
/* increase code column to full width if highlight shortcode was used in table lineno mode */
td.lntd:nth-child(2){
div.highlight td:nth-child(2){
width: 100%;
}
/* remove border from lineno column if highlight shortcode was used in table lineno mode */
td.lntd > pre.chroma:not(.pre-code) {
div.highlight td > pre:not(.pre-code) {
border-bottom-right-radius: 0;
border-right-width: 0;
border-top-right-radius: 0;
}
td.lntd:nth-child(2) pre {
div.highlight td:nth-child(2) pre {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
@ -1981,6 +1981,6 @@ html[dir="rtl"] #sidebar ul.collapsible-menu > li > label > i.fa-chevron-right {
border-width: 0;
}
/* re-add border on code column if a single in tab and highlight shortcode was used in table lineno mode */
#body .tab-content-text > div.highlight:only-child td.lntd:nth-child(2) pre {
#body .tab-content-text > div.highlight:only-child td:nth-child(2) pre {
border-left-width: 1px;
}

View file

@ -503,7 +503,10 @@ function initCodeClipboard(){
var code = codeElements[i];
var text = code.textContent;
var inPre = code.parentNode.tagName.toLowerCase() == 'pre';
var isLineCell = code.querySelector( '.lnt' ); // avoid copy-to-clipboard for highlight shortcode in table lineno mode
// avoid copy-to-clipboard for highlight shortcode in table lineno mode
var isLineCell = inPre &&
code.parentNode.parentNode.tagName.toLowerCase() == 'td' &&
code.parentNode.parentNode.parentNode.querySelector( 'td:nth-child(1) > pre > code' ) == code;
if( !isLineCell && ( inPre || text.length > 5 ) ){
var clip = new ClipboardJS( '.copy-to-clipboard-button', {
@ -513,7 +516,7 @@ function initCodeClipboard(){
}
// if highlight shortcode used in inline lineno mode, remove lineno nodes before generating text
var code = trigger.previousElementSibling.cloneNode( true );
Array.from( code.querySelectorAll( '.ln' ) ).forEach( function( lineno ){
Array.from( code.querySelectorAll( '*:scope > span > span:nth-child(1):not(:last-child)' ) ).forEach( function( lineno ){
lineno.remove();
});
var text = code.textContent;