1313 class =" code-listing"
1414 :data-syntax =" syntaxNameNormalized"
1515 :class =" { 'single-line': syntaxHighlightedLines.length === 1, 'is-wrapped': wrap > 0 }"
16- :style =" wrapStyle "
16+ :style =" wrap > 0 ? { '--wrap-ch': wrap } : null "
1717 >
1818 <Filename
1919 v-if =" fileName"
4242 ><span
4343 :key =" index"
4444 :class =" ['code-line-container',{ highlighted: isHighlighted(index),
45- 'user- highlighted' : isUserHighlighted(index),
46- 'user- strikethrough' : isUserStrikethrough(index),}]"
45+ highlighted: isUserHighlighted(index),
46+ strikethrough: isUserStrikethrough(index),}]"
4747 ><span
4848 v-if =" showLineNumbers"
4949 class =" code-number"
@@ -113,10 +113,13 @@ export default {
113113 highlightedLines: {
114114 type: Array ,
115115 default : () => [],
116+ validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
116117 },
117118 strikethroughLines: {
118119 type: Array ,
119120 default : () => [],
121+ validator : lines => lines .every (number => Number .isInteger (number) && number > 0 ),
122+
120123 },
121124 startLineNumber: {
122125 type: Number ,
@@ -144,26 +147,6 @@ export default {
144147 copyableText () {
145148 return this .content .join (' \n ' );
146149 },
147- highlightSet () {
148- const arr = this .highlightedLines || [];
149- return new Set (arr .map (Number ).filter (n => Number .isFinite (n) && n > 0 ));
150- },
151- strikethroughSet () {
152- const arr = this .strikethroughLines || [];
153- return new Set (arr .map (Number ).filter (n => Number .isFinite (n) && n > 0 ));
154- },
155- wrapStyle () {
156- const style = {};
157- if (this .wrap > 0 ) {
158- style .whiteSpace = ' pre-wrap' ;
159- style .wordBreak = ' break-word' ;
160- style .overflowWrap = ' anywhere' ;
161- style[' --wrap-ch' ] = String (this .wrap );
162- } else {
163- style .whiteSpace = ' pre' ;
164- }
165- return style;
166- },
167150 },
168151 watch: {
169152 content: {
@@ -176,10 +159,10 @@ export default {
176159 return this .highlightedLineNumbers .has (this .lineNumberFor (index));
177160 },
178161 isUserHighlighted (index ) {
179- return this .highlightSet . has (this .lineNumberFor (index));
162+ return this .highlightedLines . includes (this .lineNumberFor (index));
180163 },
181164 isUserStrikethrough (index ) {
182- return this .strikethroughSet . has (this .lineNumberFor (index));
165+ return this .strikethroughLines . includes (this .lineNumberFor (index));
183166 },
184167 // Returns the line number for the line at the given index in `content`.
185168 lineNumberFor (index ) {
@@ -250,16 +233,7 @@ export default {
250233 }
251234}
252235
253- .user-highlighted {
254- background : var (--user-line-highlight , var (--color-user-code-line-highlight ));
255- border-left : $highlighted-border-width solid var (--color-user-code-line-highlight-border );
256-
257- .code-number {
258- padding-left : $code-number-padding-left - $highlighted-border-width ;
259- }
260- }
261-
262- .user-strikethrough {
236+ .strikethrough {
263237 text-decoration-line : line-through ;
264238 text-decoration-color : var (--color-figure-gray );
265239 opacity : 0.85 ;
0 commit comments