@@ -126,6 +126,9 @@ function Highlighter(options = hhDefaultOptions) {
126126 border-bottom-right-radius: 0.25em;
127127 margin-right: -0.13em; padding-right: 0.13em;
128128 }
129+ mark[data-highlight-id][data-style="fill"] + mark[data-highlight-id][data-style="fill"] {
130+ margin-left: 0; padding-left: 0;
131+ }
129132 ` ) ;
130133
131134 // Set up SVG background and selection handles
@@ -260,8 +263,9 @@ function Highlighter(options = hhDefaultOptions) {
260263 CSS . highlights . set ( highlightId , highlightObj ) ;
261264 }
262265 highlightObj . add ( range ) ;
263- let styleTemplate = getStyleTemplate ( highlightInfo . style , 'css' , null ) . replaceAll ( 'var(--hh-color)' , options . colors [ highlightInfo . color ] ) ;
264- highlightApiStylesheet . insertRule ( `${ options . containerSelector } ::highlight(${ highlightInfo . escapedHighlightId } ) { ${ styleTemplate } }` ) ;
266+ const styleTemplate = getStyleTemplate ( highlightInfo . style , 'css' , null ) ;
267+ const colorString = options . colors [ highlightInfo . color ] ;
268+ highlightApiStylesheet . insertRule ( `${ options . containerSelector } ::highlight(${ highlightInfo . escapedHighlightId } ) { --hh-color: ${ colorString } ; ${ styleTemplate } }` ) ;
265269 highlightApiStylesheet . insertRule ( `${ options . containerSelector } rt::highlight(${ highlightInfo . escapedHighlightId } ) { color: inherit; background-color: transparent; }` ) ;
266270 highlightApiStylesheet . insertRule ( `${ options . containerSelector } img::highlight(${ highlightInfo . escapedHighlightId } ) { color: inherit; background-color: transparent; }` ) ;
267271
@@ -855,7 +859,7 @@ function Highlighter(options = hhDefaultOptions) {
855859 } else if ( activeHighlightId ) {
856860 const styleTemplate = getStyleTemplate ( style , 'css' , null ) ;
857861 selectionStylesheet . replaceSync ( `
858- ${ options . containerSelector } ::selection { ${ styleTemplate } }
862+ ${ options . containerSelector } ::selection { --hh-color: ${ colorString } ; ${ styleTemplate } }
859863 ${ options . containerSelector } rt::selection, ${ options . containerSelector } img::selection { background-color: transparent; }
860864 ` ) ;
861865 } else {
0 commit comments