title: Recording line/character positions from generated FreeMarker templates
body: <p>Is there a way to record specific line/character positions from generated FreeMarker templates? The purpose would be to highlight specific sections of the generated output file without having to parse the generated output file.</p>
  
  <p>For example, let's say I have this template:</p>
  
  <pre><code>function foo()
  {
     ordinary_crap();
     ordinary_crap();
     do_something_special();&lt;@mark foospecial&gt;
     ordinary_crap();
  }
  
  function bar()
  {
     ordinary_crap();
     do_something_really_special();&lt;@mark barspecial&gt;
     ordinary_crap();
     ordinary_crap();
  }
  
  function baz()
  {
     foo();&lt;@mark foo_call_1&gt;
     ordinary_crap();
     bar();&lt;@mark bar_call_1&gt;
  }
  </code></pre>
  
  <p>I want the <code>&lt;@mark&gt;</code> directive not to yield any generated output, but to associate mark names <code>foospecial</code>, <code>barspecial</code>, <code>foo_call_1</code> and <code>bar_call_1</code> with the line and position-within-a-line of where the <code>&lt;@mark&gt;</code> directives are located in the generated output. The example above I showed independent single points but it would be also useful to have begin/end pairs to mark specific ranges.</p>
  
  <p>The alternatives I can see are</p>
  
  <ul>
  <li>parsing the output independently -- not always possible, for example what if there are several identical instances of something in the output, and I want to highlight a specific one of those?</li>
  <li><p>adding "mark hints" and removing them via my own postprocessing step. For example</p>
  
  <pre><code> &lt;mark name="years"&gt;Fourscore and seven&lt;/mark&gt; years ago 
   something really brilliant happened to a really nice guy named
   &lt;mark name="niceguyname"&gt;Fred&lt;/mark&gt;.
  </code></pre>
  
  <p>Then I could postprocess this and remove the <code>&lt;mark &gt;</code> tags (assuming they don't conflict with the rest of the content), recording positions as I go.</p></li>
  </ul>
  
  <p>But both of these seem kind of hacky.</p>