#ifndef LIPSUM_BUILD_STATIC
# define LIPSUM_IMPLEMENTATION
#endif
static std::string
ReplaceAll(std::string& s, const std::string& from, const std::string& to)
{
if (from.empty())
return s;
size_t pos = 0;
while ((pos = s.find(from, pos)) != std::string::npos)
{
s.replace(pos, from.length(), to);
pos += to.length();
}
return s;
}
int main()
{
std::cout << "Notice: this example was AI-generated.\n";
std::string mdTemplate =
"{TITLE}\n\n"
"## About\n\n"
"{ABOUT}\n\n"
"## Highlights\n\n"
"{HIGHLIGHTS}\n\n"
"## Quick Example\n\n"
"```cpp\n"
"// This is a tiny snippet; it's intentionally silly\n"
"auto awesome = \"{WORD}\";\n"
"std::cout << \"Behold: \" << awesome << std::endl;\n"
"```\n\n"
"## Related Link\n\n"
"{MDLINK}\n\n"
"## Gallery\n\n"
"{GALLERY}\n";
std::string title = gen.
fmt_header(1, lpsm::MARKDOWN);
std::string about = gen.
fmt_paragraph(1, lpsm::USELIPSUM, lpsm::MARKDOWN);
std::string highlights = gen.
fmt_list(lpsm::UNORDERED, lpsm::MARKDOWN);
std::string word = gen.
word();
std::string mdLink = gen.
fmt_link(lpsm::MARKDOWN);
std::string gallery = gen.
paragraph(3, lpsm::NO_USELIPSUM);
std::string caption = std::string(
"> Caption: ") + gen.
sentence() +
"\n\n";
gallery = caption + gallery;
std::string md = mdTemplate;
md = ReplaceAll(md, "{TITLE}", title);
md = ReplaceAll(md, "{ABOUT}", about);
md = ReplaceAll(md, "{HIGHLIGHTS}", highlights);
md = ReplaceAll(md, "{WORD}", word);
md = ReplaceAll(md, "{MDLINK}", mdLink);
md = ReplaceAll(md, "{GALLERY}", gallery);
std::cout << "----- Generated Markdown -----\n\n";
std::cout << md << "\n";
std::cout << "----- Stats -----\n";
std::cout << "Sentences: " << sentences << "\n";
std::cout << "Words: " << words << "\n";
return 0;
}
Main class of lipsum-cpp.
Definition generator.hpp:92
void change_setting(const std::string &setting, const ArgVec2 &value)
Change a setting.
Definition generatorcore.inl:131
std::string fmt_paragraph(int num=1, bool useLipsum=true, bool useHtml=false)
Generate Markdown or HTML paragraphs.
Definition generatorformats.inl:27
std::string sentence(int num=1, bool useLipsum=true)
Generate sentences.
Definition generator.inl:98
std::string fmt_header(int level=1, bool useHtml=false)
Generate a Markdown or HTML header.
Definition generatorformats.inl:110
std::string word(int num=1)
Generate words.
Definition generator.inl:67
std::string fmt_list(bool ordered=false, bool useHtml=false)
Generate a Markdown or HTML list.
Definition generatorformats.inl:186
std::string fmt_link(bool useHtml=false)
Generate a Markdown or HTML link.
Definition generatorformats.inl:173
std::string paragraph(int num=1, bool useLipsum=true)
Generate paragraphs.
Definition generator.inl:125
Main header of lipsum-cpp.
LIPSUM_API int CountSentences(const std::string &str)
Count the number of sentences in a string.
Definition misc.inl:127
LIPSUM_API int CountWords(const std::string &str)
Count the number of words in a string.
Definition misc.inl:43