Commit a3cc0b05 authored by aggsol's avatar aggsol 🙉

change image parsing

parent 5c0ff568
......@@ -100,4 +100,10 @@ Tags of sections helps to debug and naviagte the story quickliy with the generat
3. Fix plot holes asap
4. Write related sections together
## Shuffle Sections
\ No newline at end of file
## Shuffle Sections
## Licenses
* gamebook-checker is GPLv3
* [rang](https://github.com/agauniyal/rang) is Public Domaine
* tiny-unit is Beerware
\ No newline at end of file
......@@ -55,14 +55,13 @@ namespace
}
std::array<std::string, 7> s_skipLabels = {
"fixed",
"TODO",
"Combat",
"combat",
"Karma",
"Skill",
"Stamina"
std::array<std::string, 8> s_skipLabels = {
"fixed"
,"Combat"
,"combat"
,"Karma"
,"Skill"
,"Stamina"
};
bool isSkipLabel(const std::string& l)
......@@ -78,11 +77,15 @@ namespace
return false;
}
std::array<std::string, 4> s_suffixes = {
"add-item-",
"add-weapon-",
"codeword-",
"location-"
std::array<std::string, 6> s_suffixes = {
"add-item-"
,"add-weapon-"
,"codeword-"
,"location-"
,"img-attr-"
,"img-"
};
std::string trimLabel(const std::string& l)
......@@ -124,6 +127,12 @@ void Graph::createDotFile(const std::map<int, Section>& sections)
unsigned counter = 0;
for(auto& attr: s.second.m_classes)
{
if(attr == "TODO")
{
dotfile << " " << sectionNum << " [fillcolor=red];\n";
continue;
}
if(attr.find("location-") != std::string::npos)
{
// std::cout << "location=" << attr << "\n";
......@@ -141,12 +150,6 @@ void Graph::createDotFile(const std::map<int, Section>& sections)
continue;
}
if(attr == "TODO")
{
dotfile << " " << sectionNum << " [fillcolor=red];\n";
continue;
}
if(attr == "Combat" || attr == "combat")
{
dotfile << " " << sectionNum << " [shape=hexagon];\n";
......
......@@ -24,6 +24,7 @@
namespace
{
// TODO: altTxt also consists fo attributes of the image (comma separated)
int parseImageLine(const std::string& input, std::string& outFilename, std::string& altTxt)
{
enum class State
......@@ -194,14 +195,8 @@ void Parser::parseLine(const std::string& line, std::map<int, Section>& sections
throw std::runtime_error("Missing image filename");
}
if(altTxt.empty())
{
sections[m_currSection].m_classes.insert(filename);
}
else
{
sections[m_currSection].m_classes.insert(altTxt);
}
sections[m_currSection].m_classes.insert("img-" + filename);
sections[m_currSection].m_classes.insert("img-attr-" + altTxt);
m_lastLine = LineType::Image;
state = State::Done;
......
......@@ -30,11 +30,16 @@ public:
TINY_ASSERT_EQUAL(4, sections[1].m_lines.size());
TINY_ASSERT_EQUAL(1, sections[1].m_classes.size());
TINY_ASSERT_OK(sections[1].m_classes.find("images/example01.png") != sections[1].m_classes.end());
TINY_ASSERT_EQUAL(2, sections[1].m_classes.size());
TINY_ASSERT_OK(sections[1].m_classes.find("img-images/example01.png") != sections[1].m_classes.end());
TINY_ASSERT_EQUAL(1, sections[2].m_classes.size());
TINY_ASSERT_OK(sections[2].m_classes.find("Hello again!") != sections[2].m_classes.end());
// for(auto c: 2, sections[2].m_classes)
// {
// std::cout << "class=" << c << "\n";
// }
TINY_ASSERT_EQUAL(2, sections[2].m_classes.size());
TINY_ASSERT_OK(sections[2].m_classes.find("img-attr-Hello,12,12") != sections[2].m_classes.end());
}
static void stylesection()
......
......@@ -6,4 +6,4 @@ text
[[section-2]]
=== 2
image::images/example02.png[Hello again!]
image::images/example02.png[Hello,12,12]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment