summaryrefslogtreecommitdiff
path: root/resources/test/core_result.html
blob: 0f242a7897d6890cb73bad27a22edcdbdd7d40f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<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>. <em>What about italic text that <strong>has bold text</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>

<hr>

<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>

<h1>This is a H1 heading with settext</h1>

<h2>And this is a H2 heading with settext</h2>