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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;

   // Ignore multi-line formatting
   t.DefaultRuleSet().StatementSensitive(false);

   // 1. Parent rule captures the content of the <nav> block.
   auto navRule = t.Pattern("<nav>{content}</nav>");

   // 2. Get the local transformer for the nav block.
   auto local_t = navRule.LocalTransformer();

   // 3. This rule will only find `<a>` tags inside the <nav> block.
   local_t.Pattern("<a href={url}>{text}</a>");

   auto html = R"(
<nav>
  <a href="/home">Home</a>
  <a href="/about">About</a>
</nav>
<main>
  <p>Some text with another <a href="/other">other link</a>.</p>
</main>
)";

   t.Text(html);
   t.Find();

   cout << "--- Found Links (Innermost Matches Only) ---" << endl;
   // Use InnermostOnly to see only the results from the local transformer.
   cout << t.GetMatches(MatchesOption::InnermostOnly).Text() << endl;
}