#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
      t.DefaultRuleSet().RewindOnChange(true);

      // 2. Define Rules (General rules first, specific rules last for LIFO precedence)

      // -- Inline rules --
      // Italic is defined before Bold, giving Bold higher precedence.
      t.FromTo("*{text}*", "<i>{text}</i>");
      t.FromTo("**{text}**", "<b>{text}</b>");

      // -- Block-level rules --
      t.FromTo("#{@Whitespace}{line}", "<h1>{line}</h1>");
      t.FromTo("*{@Whitespace}{line}", "<li>{line}</li>");

      // 3. Define the input Markdown text
      auto markdown = R"(
# Main Header

* First list item
* Second list item with **bold** text.
* Third list item with *italic* text.

Another paragraph with **bold** and *italic*.
)";

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