Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit d0c3a5c

Browse files
fix(highlight-code): fix code highlight
1 parent 61930ff commit d0c3a5c

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

webcomponents/highlight-code/src/components/highlight-code/deckdeckgo-highlight-code.scss

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ div.deckgo-highlight-code-container {
3939
text-align: var(--deckgo-highlight-code-text-align, start);
4040

4141
code {
42-
overflow-y: var(--deckgo-highlight-code-scroll, scroll);;
42+
overflow-y: var(--deckgo-highlight-code-scroll, scroll);
4343

4444
white-space: pre-wrap;
4545

@@ -54,14 +54,15 @@ div.deckgo-highlight-code-container {
5454
counter-increment: linenumber;
5555
position: relative;
5656
padding-left: 3.5em;
57-
57+
5858
&:before {
5959
content: counter(linenumber);
6060
min-height: 1rem;
6161
display: inline-block;
6262
position: absolute;
6363
left: 0;
6464
width: 2.5em;
65+
background: var(--deckgo-highlight-code-background, white);
6566
border-right: 1px solid var(--deckgo-highlight-code-line-number, #999);
6667
color: var(--deckgo-highlight-code-line-divider, #999);
6768
}
@@ -75,9 +76,8 @@ div.deckgo-highlight-code-container {
7576
visibility: hidden;
7677
}
7778

78-
span.deckgo-highlight-code-line {
79+
.deckgo-highlight-code-line {
7980
background: var(--deckgo-highlight-code-line-background, #3880ff);
80-
padding: var(--deckgo-highlight-code-line-padding);
8181
border-top: var(--deckgo-highlight-code-line-border-top);
8282
border-bottom: var(--deckgo-highlight-code-line-border-bottom);
8383
}
@@ -147,25 +147,3 @@ div.deckgo-highlight-code-container {
147147
}
148148
}
149149
}
150-
151-
// code {
152-
// counter-reset: linenumber;
153-
// white-space: pre-wrap;
154-
155-
// & > div {
156-
// counter-increment: linenumber;
157-
// position: relative;
158-
// padding-left: 3.5em;
159-
160-
// &:before {
161-
// content: counter(linenumber);
162-
// min-height: 1rem;
163-
// display: inline-block;
164-
// position: absolute;
165-
// left: 0;
166-
// width: 2.5em;
167-
// border-right: 1px solid #999;
168-
// color: #999;
169-
// }
170-
// }
171-
// }

webcomponents/highlight-code/src/components/highlight-code/deckdeckgo-highlight-code.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ export class DeckdeckgoHighlightCode {
250250
if (this.highlightLines && this.highlightLines.length > 0) {
251251

252252
const rows: number[] = await this.findRowsToHighlight();
253-
254253
if (rows && rows.length > 0) {
255254
const containerCode: HTMLElement = this.el.shadowRoot.querySelector('code');
256255

webcomponents/highlight-code/src/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,22 @@ <h1>Plain code and java language:</h1>
8787
Markdown</code>
8888
</deckgo-highlight-code>
8989

90+
<h1>Without line numbers</h1>
91+
<deckgo-highlight-code language="java" line-numbers="false" highlight-lines="0,2 6,6">
92+
<code slot="code">interface NumericTest {
93+
boolean computeTest(int n);
94+
}
95+
96+
public static void main(String args[]) {
97+
NumericTest isEven = (n) -> (n % 2) == 0;
98+
NumericTest isNegative = (n) -> (n < 0);
99+
100+
// Output: false
101+
System.out.println(isEven.computeTest(5));
102+
103+
// Output: true
104+
System.out.println(isNegative.computeTest(-5));
105+
}</code>
106+
</deckgo-highlight-code>
90107
</body>
91108
</html>

0 commit comments

Comments
 (0)