summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/test/core.md71
-rw-r--r--resources/test/core_result.html39
2 files changed, 110 insertions, 0 deletions
diff --git a/resources/test/core.md b/resources/test/core.md
new file mode 100644
index 0000000..0db2199
--- /dev/null
+++ b/resources/test/core.md
@@ -0,0 +1,71 @@
+Lorem ipsum dolor **sit** amet. Lorem ipsum *dolor* _sit_ __amet__.
+
+1. List item
+2. Another list item
+ 1. Sub list item
+ 2. Another sub list item
+ 1. Sub sub list item
+ 3. Continuing sub list item
+3. Continuing list item
+
+```javascript
+// Detect horizontal line block
+function isHorizontalLineBlock(block) {
+ return block === "***";
+}
+
+// Render horizontal line block
+function horizontalLineBlock(block) {
+ return `<hr>`;
+}
+
+// Compose an array of parsers
+const parsers = [{
+ matcher: isHorizontalLineBlock,
+ renderers: [horizontalLineBlock]
+}];
+
+// And finally, our parser itself
+function markdownToHTML(markdown) {
+ // Create blocks
+ const blocks = content.split(/\n\n/);
+
+ // Parse blocks
+ const parsedBlocks = blocks.map((block) => {
+ // Let's find a parser that has a matcher that matches
+ const parser = parsers.find((parser) => parser.matcher(block));
+
+ // If match was found, let's run our renderers over `block`
+ if (parser) {
+ for (const renderer of match.renderers) {
+ block = renderer(block);
+ }
+ }
+
+ return block;
+ });
+
+ // And at last, join the blocks together for one big block.
+ return parsedBlocks.join("");
+}
+```
+
+This is ___bold italic text___ and ***this is also***.
+
+## Hi there, world!
+
+* List item
+* Another list item
+ * Sub list item
+ * Another sub list item
+ * Sub sub list item
+ * Continuing sub list item
+* Continuing list item
+
+* List item
+* Another list item
+ * Sub list item
+ * Another sub list item
+ 1. Sub sub list item
+ 2. Continuing sub list item
+* Continuing list item \ No newline at end of file
diff --git a/resources/test/core_result.html b/resources/test/core_result.html
new file mode 100644
index 0000000..350a595
--- /dev/null
+++ b/resources/test/core_result.html
@@ -0,0 +1,39 @@
+<p>Lorem ipsum dolor <strong>sit</strong> amet. Lorem ipsum <em>dolor</em> <em>sit</em> <strong>amet</strong>.</p><ol><li>List item</li><li>Another list item<ol><li>Sub list item</li><li>Another sub list item<ol><li>Sub sub list item</li></ol></li><li>Continuing sub list item</li></ol></li><li>Continuing list item</li></ol><pre><code class="language-javascript">// Detect horizontal line block
+function isHorizontalLineBlock(block) {
+ return block === "***";
+}
+
+// Render horizontal line block
+function horizontalLineBlock(block) {
+ return `&lt;hr&gt;`;
+}
+
+// Compose an array of parsers
+const parsers = [{
+ matcher: isHorizontalLineBlock,
+ renderers: [horizontalLineBlock]
+}];
+
+// And finally, our parser itself
+function markdownToHTML(markdown) {
+ // Create blocks
+ const blocks = content.split(/\n\n/);
+
+ // Parse blocks
+ const parsedBlocks = blocks.map((block) =&gt; {
+ // Let's find a parser that has a matcher that matches
+ const parser = parsers.find((parser) =&gt; parser.matcher(block));
+
+ // If match was found, let's run our renderers over `block`
+ if (parser) {
+ for (const renderer of match.renderers) {
+ block = renderer(block);
+ }
+ }
+
+ return block;
+ });
+
+ // And at last, join the blocks together for one big block.
+ return parsedBlocks.join("");
+}</code></pre><p>This is <em><strong>bold italic text</strong></em> and <em><strong>this is also</strong></em>.</p><h2>Hi there, world!</h2><ul><li>List item</li><li>Another list item<ul><li>Sub list item</li><li>Another sub list item<ul><li>Sub sub list item</li><li>Continuing sub list item</li></ul></li></ul></li><li>Continuing list item</li></ul><ul><li>List item</li><li>Another list item<ul><li>Sub list item</li><li>Another sub list item<ol><li>Sub sub list item</li><li>Continuing sub list item</li></ol></li></ul></li><li>Continuing list item</li></ul> \ No newline at end of file