Skip to content

Commit 777c75b

Browse files
Hari KiranHari Kiran
authored andcommitted
Fix: Prevent Webpack from parsing displayed require() code
1 parent 21d809b commit 777c75b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/components/DatasetFlashcards.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,15 @@ json data(datafile);`}
435435
<Typography>Install:</Typography>
436436
<code style={flashcardStyles.codeBlock}>npm install jda numjs pako atob</code>
437437
<Typography>Load:</Typography>
438-
<code style={flashcardStyles.codeBlock}>
439-
{`const fs = require("fs");
440-
const jd = require("jda");
441-
global.atob = require("atob");
442-
443-
const fn = "${docname}.json";
444-
var jstr = fs.readFileSync(fn).toString().replace(/\\n/g, "");
445-
var data = new jd(JSON.parse(jstr));
446-
data = data.decode();`}
447-
</code>
438+
<code style={flashcardStyles.codeBlock} dangerouslySetInnerHTML={{
439+
__html: `const fs = require("fs");<br>
440+
const jd = require("jda");<br>
441+
global.atob = require("atob");<br><br>
442+
const fn = "${docname}.json";<br>
443+
var jstr = fs.readFileSync(fn).toString().replace(/\\n/g, "");<br>
444+
var data = new jd(JSON.parse(jstr));<br>
445+
data = data.decode();`
446+
}} />
448447
<Typography>Read value:</Typography>
449448
<code style={flashcardStyles.codeBlock}>
450449
{`console.log(data.data["${onekey}"]);`}

0 commit comments

Comments
 (0)