From 27bb2769097f2941761b72d5873f6371dd24046a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 25 Feb 2023 00:05:38 +0100 Subject: [PATCH] i18n: write code ltr even for rtl languages #492 --- static/css/theme.css | 7 ++++--- static/js/theme.js | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/static/css/theme.css b/static/css/theme.css index e042a7bc83..783946c809 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -548,10 +548,11 @@ pre { position: relative; } -pre.pre-code, -pre:has( code ){ - /* the :has() operator isn't available in FF yet, so we patch this by JS */ +/* pre:has( code ), */ +/* the :has() operator isn't available in FF yet, so we patch this by JS */ +pre.pre-code { direction: ltr; + text-align: left; } pre code { diff --git a/static/js/theme.js b/static/js/theme.js index d79243772a..75afadd4fd 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -368,13 +368,11 @@ function initCodeClipboard(){ clip.on( 'success', function( e ){ e.clearSelection(); - var inPre = e.trigger.parentNode.tagName.toLowerCase() == 'pre'; e.trigger.setAttribute( 'aria-label', window.T_Copied_to_clipboard ); e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) ); }); clip.on( 'error', function( e ){ - var inPre = e.trigger.parentNode.tagName.toLowerCase() == 'pre'; e.trigger.setAttribute( 'aria-label', fallbackMessage(e.action) ); e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) ); var f = function(){ @@ -388,7 +386,7 @@ function initCodeClipboard(){ code.classList.add( 'copy-to-clipboard-code' ); if( inPre ){ code.classList.add( 'copy-to-clipboard' ); - code.classList.add( 'pre-code' ); + code.parentNode.classList.add( 'pre-code' ); } else{ var clone = code.cloneNode( true );