-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMarkdown.cpp
More file actions
42 lines (35 loc) · 1.05 KB
/
Markdown.cpp
File metadata and controls
42 lines (35 loc) · 1.05 KB
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
#ifndef LIPSUM_BUILD_STATIC
# define LIPSUM_IMPLEMENTATION // only for header-only usage
#endif
#include <lipsum.hpp>
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif
int main()
{
lpsm::Generator gen;
// Change various settings.
gen.change_setting("word", 6, 9);
gen.change_setting("frag", 3, 6);
gen.change_setting("sent", 7, 10);
gen.change_setting("point", 5, 12);
gen.change_setting("wordFmt", 6, 8);
gen.change_setting("fragFmt", 3, 5);
gen.change_setting("wordURL", 3, 5);
gen.change_setting("level", 1, 6);
// Generate an HTML document with 30 elements.
std::string text = gen.md_text(30, lpsm::HTML);
std::cout << text << "\n\n";
// clang-format off
#ifdef __EMSCRIPTEN__
// js to put text in document
EM_ASM({
const htmlText = UTF8ToString($0);
const contentElem = document.createElement("div");
contentElem.innerHTML = htmlText;
document.querySelector("body").appendChild(contentElem);
}, text.c_str());
#endif
// clang-format on
return 0;
}