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

using namespace std;
using namespace uCalcSoftware;

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

   // The parent rule will find the <section> block and make its content available to a local transformer.
   // StatementSensitive(false) is needed so the multiline content is captured.
   auto parentRule = t.Pattern("<section>{body}</section>");
   parentRule.StatementSensitive(false);

   // Get the local transformer for the <section> block.
   auto section_t = parentRule.LocalTransformer();

   // These rules will ONLY run on the content inside the <section> tag.
   section_t.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>");
   section_t.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>");

   auto sourceHtml =
   R"(
<div>
  <h2>Article One</h2>
  <p>This is NOT in the section.</p>
</div>

<section>
  <div>
    <h2>Article Two</h2>
    <p>This one IS inside the section.</p>
  </div>
</section>
)";

   t.Text(sourceHtml);
   t.Transform();
   cout << t.Text() << endl;
}