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

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   // Note the change in section/div/h2
   auto t = uc.NewTransformer();

   auto rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false);
   auto section = rule.LocalTransformer();
   section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>");
   section.SkipOver("&{entity};");
   auto ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>");

   cout << "Has a local transformer: " << tf(rule.HasLocalTransformer()) << endl;
   cout << "rule is a child rule: " << tf(rule.IsChildRule()) << endl;
   cout << "ch is a child rule: " << tf(ch.IsChildRule()) << endl;

   auto HtmlText =
   R"(
<div class="article" data-id="1">
  <h2>Article One</h2>
  <p>This is the first article.</p>
</div>

<div class="article" data-id="2">
  <h2>Article Two</h2>
  <p>This is the second article.</p>
</div>

<section>
  <div class="article" data-id="3">
    <h2>Article Three</h2>
    <p>This one is inside a &lt;section&gt;.</p>
  </div>
</section>

<div class="article" data-id="4">
  <h2>Article Four</h2>
  <p>This is the fourth article.</p>
</div>
)";

   t.Text(HtmlText);
   t.Transform();
   cout << t.Text() << endl;


}