Dynamically re-categorizes the newline token to treat it as whitespace, allowing a pattern to match across multiple lines.

ID: 1013

See: ByName
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
var source = """
<data>
  content spans
  multiple lines
</data>
""";
t.FromTo("<data>{body}</data>", "Body: [{body}]");

Console.WriteLine("--- Before: Newline is a Separator ---");
Console.WriteLine(t.Transform(source));

// Use ByName to find the newline token and change its type.
t.Tokens.ByName("_token_newline", TokenType.Whitespace);

Console.WriteLine("");
Console.WriteLine("--- After: Newline is Whitespace ---");
Console.WriteLine(t.Transform(source));
				
			
--- Before: Newline is a Separator ---
<data>
  content spans
  multiple lines
</data>

--- After: Newline is Whitespace ---
Body: [content spans
  multiple lines]
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   auto source = R"(<data>
  content spans
  multiple lines
</data>)";
   t.FromTo("<data>{body}</data>", "Body: [{body}]");

   cout << "--- Before: Newline is a Separator ---" << endl;
   cout << t.Transform(source) << endl;

   // Use ByName to find the newline token and change its type.
   t.Tokens().ByName("_token_newline", TokenType::Whitespace);

   cout << "" << endl;
   cout << "--- After: Newline is Whitespace ---" << endl;
   cout << t.Transform(source) << endl;
}
				
			
--- Before: Newline is a Separator ---
<data>
  content spans
  multiple lines
</data>

--- After: Newline is Whitespace ---
Body: [content spans
  multiple lines]
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      Dim source = "<data>
  content spans
  multiple lines
</data>"
      t.FromTo("<data>{body}</data>", "Body: [{body}]")
      
      Console.WriteLine("--- Before: Newline is a Separator ---")
      Console.WriteLine(t.Transform(source))
      
      '// Use ByName to find the newline token and change its type.
      t.Tokens.ByName("_token_newline", TokenType.Whitespace)
      
      Console.WriteLine("")
      Console.WriteLine("--- After: Newline is Whitespace ---")
      Console.WriteLine(t.Transform(source))
   End Sub
End Module
				
			
--- Before: Newline is a Separator ---
<data>
  content spans
  multiple lines
</data>

--- After: Newline is Whitespace ---
Body: [content spans
  multiple lines]