Skip to content

Commit 8091e0c

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

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/components/DatasetFlashcards.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,18 @@ 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} 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-
}} />
438+
<pre>
439+
<code style={flashcardStyles.codeBlock}>
440+
{`const fs = require("fs");\n`}
441+
{`const jd = require("jda");\n`}
442+
{`global.atob = require("atob");\n\n`}
443+
{`const fn = "${docname}.json";\n`}
444+
{`var jstr = fs.readFileSync(fn).toString().replace(/\\n/g, "");\n`}
445+
{`var data = new jd(JSON.parse(jstr));\n`}
446+
{`data = data.decode();`}
447+
</code>
448+
</pre>
449+
447450
<Typography>Read value:</Typography>
448451
<code style={flashcardStyles.codeBlock}>
449452
{`console.log(data.data["${onekey}"]);`}

0 commit comments

Comments
 (0)