#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // 1. Setup the Transformer
   {
      uCalc::Transformer t;
      t.Owned(); // Causes t to be released when it goes out of scope
      // Allow patterns to match across multiple lines
      t.DefaultRuleSet().StatementSensitive(false);

      // 2. Define the conversion rules

      // Simple inline tags
      t.FromTo("'['b']'{text}'['/b']'", "**{text}**");
      t.FromTo("'['i']'{text}'['/i']'", "*{text}*");
      t.FromTo("'['u']'{text}'['/u']'", "<u>{text}</u>");

      // URL tag with attribute
      t.FromTo("'['url={href}']'{text}'['/url']'", "[{text}]({href})");

      // Quote block tag
      t.FromTo("'['quote']'{content}'['/quote']'", "> {content}");

      // 3. Define the input BBCode text
      auto bbCode = R"(
Hello, this is a test of the converter.

This text is [b]bold[/b] and this is [i]italic[/i].
You can also [u]underline[/u] text.

Here is a link to the uCalc website: [url=https://www.ucalc.com]uCalc[/url].

[quote]This is a block of quoted text.
It can span multiple lines.[/quote]
)";

      // 4. Run the transformation and print the result
      cout << t.Transform(bbCode) << endl;
   }
}