Skip to content

Commit 71b3559

Browse files
committed
preparation for input matching
1 parent ec25516 commit 71b3559

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.6.1/github-markdown-light.css"
2525
integrity="sha512-tVO0ZLV54CEoiM+i1hvfZGcopGR3rxyyC3L2/P/6NRTVXlrp4OKyTFunluVG1BRNasDLnm6ZRPDKBGM0CkS99Q=="
2626
crossorigin="anonymous" referrerpolicy="no-referrer" />
27-
<script src="//unpkg.com/alpinejs" defer></script>
28-
29-
27+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script>
3028
</head>
3129
<script>
3230
const mathWorker = new Worker("mathWorker.js", { type: "classic" });

main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,29 @@ mathWorker.onmessage = function (oEvent) {
119119
case "string":
120120
div = document.createElement("code");
121121
div.innerHTML = value;
122+
div.setAttribute('data-from-line', e.from)
123+
div.setAttribute('data-to-line', e.to)
122124
pre.appendChild(div);
123125
break;
124126
case "any":
125127
div = document.createElement("div");
126128
div.textContent = value;
129+
div.setAttribute('data-from-line', e.from)
130+
div.setAttribute('data-to-line', e.to)
127131
pre.appendChild(div);
128132
break;
129133
case "error":
130134
div = document.createElement("div");
131135
div.style.color = "red";
132136
div.innerHTML = value;
137+
div.setAttribute('data-from-line', e.from)
138+
div.setAttribute('data-to-line', e.to)
133139
pre.appendChild(div);
134140
break;
135141
case "plot":
136142
div = document.createElement("div");
143+
div.setAttribute('data-from-line', e.from)
144+
div.setAttribute('data-to-line', e.to)
137145
try {
138146
Plotly.newPlot(div, e.result.data, e.result.layout, e.result.config)
139147
} catch (error) {
@@ -148,6 +156,8 @@ mathWorker.onmessage = function (oEvent) {
148156
break;
149157
case "markdown":
150158
const div = document.createElement("div");
159+
div.setAttribute('data-from-line', out.from)
160+
div.setAttribute('data-to-line', out.to)
151161
div.innerHTML = md.render(out.text);
152162
outputs.appendChild(div);
153163
break;

public/mathWorker.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
importScripts(
2-
"https://cdnjs.cloudflare.com/ajax/libs/mathjs/13.1.1/math.js",
2+
"https://cdnjs.cloudflare.com/ajax/libs/mathjs/14.0.0/math.js",
33
"coolprop.js",
44
"fluidProperties.js",
55
"molecularMass.js"
@@ -86,8 +86,7 @@ function makeDoc(code) {
8686
const formatedLine = lineType === 'md' ? line.slice(2) : line
8787
if (lastType === lineType) {
8888
cells[cells.length - 1].source.push(formatedLine)
89-
}
90-
else {
89+
} else {
9190
cells.push({ cell_type: lineType, source: [formatedLine], from: lastLineNum, to: lineNum })
9291
lastLineNum = lineNum
9392
}

style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ main {
1414
overflow: hidden;
1515
}
1616

17+
div[data-from-line = "1"] {
18+
background-color: pink;
19+
}
20+
1721
main>article.markdown-body {
1822
flex: 1;
1923
overflow: auto;

0 commit comments

Comments
 (0)