#include "HtmlString.h"
#include
#include
#include
#include "minecraft/IGameServices.h"
#include "util/StringHelpers.h"
HtmlString::HtmlString(std::string text, eMinecraftColour hexColor,
bool italics, bool indent) {
this->text = escapeXML(text);
this->color = hexColor;
this->italics = italics;
this->indent = indent;
}
std::string HtmlString::ToString() {
std::stringstream ss;
if (indent) {
ss << " ";
}
if (italics) {
ss << "";
}
eMinecraftColour color =
this->color == eMinecraftColour_NOT_SET ? eHTMLColor_7 : this->color;
ss << "" << text << "";
if (italics) {
ss << "";
}
return ss.str();
}
std::string HtmlString::Compose(std::vector* strings) {
if (strings == nullptr) return "";
std::stringstream ss;
for (int i = 0; i < strings->size(); i++) {
ss << strings->at(i).ToString();
// Add a break if there's another line
if (i + 1 < strings->size()) {
ss << "
";
}
}
return ss.str();
}