clean up markdown test scripts
This commit is contained in:
parent
dac17c57aa
commit
6c0148bf14
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"firefox": "60"
|
||||
}
|
||||
}
|
||||
],
|
||||
"@babel/typescript",
|
||||
"@babel/react"
|
||||
],
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-flow-strip-types",
|
||||
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
||||
"@babel/plugin-proposal-function-sent",
|
||||
"@babel/plugin-proposal-export-namespace-from",
|
||||
"@babel/plugin-proposal-numeric-separator",
|
||||
"@babel/plugin-proposal-throw-expressions",
|
||||
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
||||
"@babel/proposal-object-rest-spread",
|
||||
"@babel/transform-react-constant-elements",
|
||||
"@babel/transform-react-inline-elements",
|
||||
"transform-react-remove-prop-types",
|
||||
"transform-react-pure-class-to-function",
|
||||
]
|
||||
}
|
2
utils/markdown-test/.gitignore
vendored
Normal file
2
utils/markdown-test/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
script.js
|
||||
script.js.LICENSE.txt
|
3
utils/markdown-test/README.md
Normal file
3
utils/markdown-test/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Markdown parser testing
|
||||
|
||||
Code to test markdown parsing, run `npx webpack` to build and open index.html
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
<body>
|
||||
<script src="./script.js"></script>
|
||||
<textarea id="input" name="text" cols="100" rows="30"></textarea><br />
|
||||
<p>Parse-time: <span id="time"/></p>
|
||||
<textarea id="output" name="text" cols="100" rows="30" readonly></textarea>
|
||||
<div id="reactroot"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,24 +1,45 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import MarkdownParser from '../../src/core/Markdown';
|
||||
import { Parser } from 'commonmark';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const reader = new Parser({smart: true});
|
||||
const a = new MarkdownParser();
|
||||
const reader = new Parser({smart: true});
|
||||
const a = new MarkdownParser();
|
||||
|
||||
const input = document.getElementById('input');
|
||||
const output = document.getElementById('output');
|
||||
const time = document.getElementById('time');
|
||||
|
||||
input.addEventListener('input', () => {
|
||||
function parseText(text, setDuration, setCmDuration) {
|
||||
let startt = Date.now();
|
||||
const [arr] = a.parseText(input.value);
|
||||
time.innerHTML = Date.now() - startt + 'ms';
|
||||
const [arr] = a.parseText(text);
|
||||
setDuration(Date.now() - startt);
|
||||
startt = Date.now();
|
||||
const parsed = reader.parse(input.value);
|
||||
time.innerHTML += ' / commonmark: ' + (Date.now() - startt) + 'ms';
|
||||
console.log(parsed);
|
||||
output.value = JSON.stringify(arr, null, 2);
|
||||
});
|
||||
setCmDuration(Date.now() - startt);
|
||||
return JSON.stringify(arr, null, 2);
|
||||
}
|
||||
|
||||
const App = () => {
|
||||
const [text, setText] = useState('');
|
||||
const [duration, setDuration] = useState('');
|
||||
const [cmDuration, setCmDuration] = useState('');
|
||||
|
||||
return (
|
||||
<div>
|
||||
<textarea
|
||||
cols="100"
|
||||
rows="30"
|
||||
onChange={(evt) => setText(evt.target.value)}
|
||||
/>
|
||||
<p>Parse-time: {duration}ms / commonmark: {cmDuration}</p>
|
||||
<textarea
|
||||
cols="100"
|
||||
rows="30"
|
||||
value={parseText(text, setDuration, setCmDuration)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
ReactDOM.render(App, document.getElementById('reactroot'));
|
||||
});
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
/*! http://mths.be/repeat v0.2.0 by @mathias */
|
|
@ -9,6 +9,8 @@ var babelPlugins = [
|
|||
'@babel/plugin-proposal-numeric-separator',
|
||||
'@babel/plugin-proposal-throw-expressions',
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
['@babel/plugin-proposal-private-methods', { loose: true }],
|
||||
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
|
||||
'@babel/proposal-object-rest-spread',
|
||||
// react-optimize
|
||||
'@babel/transform-react-constant-elements',
|
||||
|
|
Loading…
Reference in New Issue
Block a user