Some repairs for md_parser and template engine.

This commit is contained in:
James Grogan 2022-12-07 10:21:28 +00:00
parent 8705859115
commit 22157169c0
14 changed files with 180 additions and 159 deletions

View file

@ -1,15 +1,29 @@
#include "TemplatingEngine.h"
#include "TemplateSubstitutionContext.h"
#include "File.h"
#include "TestFramework.h"
#include "TestUtils.h"
TEST_CASE(TestTemplatingEngine, "compiler")
TEST_CASE(TestTemplatingEngine_BlockInherit, "compiler")
{
auto engine = TemplatingEngine(TestUtils::getTestDataDir());
const auto content = engine.renderTemplate("index", nullptr);
File outfile(TestUtils::getTestOutputDir() / "index.html");
File outfile(TestUtils::getTestOutputDir(__FILE__) / "BlockInherit.html");
outfile.writeText(content);
}
TEST_CASE(TestTemplatingEngine_Simple, "compiler")
{
auto engine = TemplatingEngine(TestUtils::getTestDataDir());
TemplateSubstitutionContext sub_context;
sub_context.addSubstitution("content", "<div><p>test</p></div>");
const auto content = engine.renderTemplate("simple_template", &sub_context);
File outfile(TestUtils::getTestOutputDir(__FILE__) / "Simple.html");
outfile.writeText(content);
}

View file

@ -1,30 +1,7 @@
# I'm a level one header
I'm some text under level one
## I'm a level two header
I'm some text under level two
```
I'm a code block
```
I'm a line under the code block, with some `inline code`.
### I'm a level three header
I'm a bullet point list:
* First point
* Second point
* Third point
With a [hyperlink](www.imahyperlink.com) embedded.
# I'm another level one header
I'm some inline math $a = b + c$ and I'm some standalone math:
$$
d = e + f
$$
![This is an image](https://myoctocat.com/assets/images/base-octocat.svg)
With some test after.

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css" />
<title>My title</title>
</head>
<body>
<div id="content">{{ content }}</div>
</body>
</html>