25
25
<!-- Do not add newlines in <pre>, as they'll appear in the rendered HTML. -->
26
26
<pre><CodeBlock><span
27
27
v-for="(line, index) in syntaxHighlightedLines"
28
- :class="['code-line-container',{ highlighted: isHighlighted(index) }]"
28
+ :class="['code-line-container',
29
+ { highlighted: !isLastCodeListing && isHighlighted(index),
30
+ deleteHighlighted: isLastCodeListing && isDeleteHighlighted(index)
31
+ }]"
29
32
:key="index"
30
33
><span
31
34
v-show="showLineNumbers" class="code-number"
@@ -75,16 +78,27 @@ export default {
75
78
type: Array,
76
79
default: () => [],
77
80
},
81
+ deleteHighlights: {
82
+ type: Array,
83
+ default: () => [],
84
+ },
78
85
showLineNumbers: {
79
86
type: Boolean,
80
87
default: () => false,
81
88
},
89
+ isLastCodeListing: {
90
+ type: Boolean,
91
+ default: () => false,
92
+ },
82
93
},
83
94
computed: {
84
95
escapedContent: ({ content }) => content.map(escapeHtml),
85
96
highlightedLineNumbers() {
86
97
return new Set(this.highlights.map(({ line }) => line));
87
98
},
99
+ deleteHighlightedLineNumbers() {
100
+ return new Set(this.deleteHighlights.map(({ line }) => line));
101
+ },
88
102
syntaxNameNormalized() {
89
103
// `occ` is a legacy naming convention
90
104
const fallbackMap = { occ: Language.objectiveC.key.url };
@@ -101,6 +115,9 @@ export default {
101
115
isHighlighted(index) {
102
116
return this.highlightedLineNumbers.has(this.lineNumberFor(index));
103
117
},
118
+ isDeleteHighlighted(index) {
119
+ return this.deleteHighlightedLineNumbers.has(this.lineNumberFor(index));
120
+ },
104
121
// Returns the line number for the line at the given index in `content`.
105
122
lineNumberFor(index) {
106
123
return this.startLineNumber + index;
@@ -152,6 +169,16 @@ export default {
152
169
}
153
170
}
154
171
172
+ .deleteHighlighted {
173
+ text-decoration-line: line-through;
174
+ background: var(--line-delete-highlight, var(--color-code-line-delete-highlight));
175
+ border-left: $highlighted-border-width solid var(--color-code-line-delete-highlight-border);
176
+
177
+ .code-number {
178
+ padding-left: $code-number-padding-left - $highlighted-border-width;
179
+ }
180
+ }
181
+
155
182
pre {
156
183
padding: $code-listing-with-numbers-padding;
157
184
display: flex;
0 commit comments