Switched to FM 2.3.24 nightly, using new-style escaping
diff --git a/ivy.xml b/ivy.xml
index a2d1687..d912016 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -8,7 +8,7 @@
     </publications>
     <dependencies>
         <dependency org="com.thaiopensource" name="jing" rev="20081028" conf="default->default" />
-        <dependency org="org.freemarker" name="freemarker" rev="2.3.23" conf="default->default" changing="false" />
+        <dependency org="org.freemarker" name="freemarker" rev="2.3-branch-head" conf="default->default" changing="true" />
         <dependency org="ant" name="ant" rev="1.6.5" conf="default->default" />
     </dependencies>
 </ivy-module>
diff --git a/src/main/org/freemarker/docgen/Transform.java b/src/main/org/freemarker/docgen/Transform.java
index 88fffd9..77c267f 100644
--- a/src/main/org/freemarker/docgen/Transform.java
+++ b/src/main/org/freemarker/docgen/Transform.java
@@ -357,7 +357,7 @@
  *       <li><p><tt>docgen-templates</tt> directory:
  *           The templates here will have priority over the ones in the
  *           {@code org.freemarker.docgen.templates} package.
- *           This is mostly used for overriding <tt>customizations.ftl</tt>;
+ *           This is mostly used for overriding <tt>customizations.ftlh</tt>;
  *           that FTL is <tt>#import</tt>-ed at the beginning of all
  *           template files, and searched first for the
  *           <tt>#visit</tt>/<tt>#recurse</tt> calls.
@@ -438,11 +438,11 @@
     static final String FILE_SEARCH_RESULTS_HTML = "search-results.html";
     static final String FILE_TOC_JSON_TEMPLATE = "toc-json.ftl";
     static final String FILE_TOC_JSON_OUTPUT = "toc.js";
-    static final String FILE_ECLIPSE_TOC_TEMPLATE = "eclipse-toc.ftl";
+    static final String FILE_ECLIPSE_TOC_TEMPLATE = "eclipse-toc.ftlx";
     static final String FILE_ECLIPSE_TOC_OUTPUT = "eclipse-toc.xml";
     static final String DIR_TEMPLATES = "docgen-templates";
 
-    static final String FILE_SITEMAP_XML_TEMPLATE = "sitemap.ftl";
+    static final String FILE_SITEMAP_XML_TEMPLATE = "sitemap.ftlx";
     static final String FILE_SITEMAP_XML_OUTPUT = "sitemap.xml";
 
     static final String SETTING_IGNORED_FILES = "ignoredFiles";
@@ -1182,7 +1182,7 @@
             throw new BugException(e);
         }
 
-        fmConfig = new Configuration(Configuration.VERSION_2_3_23);
+        fmConfig = new Configuration(Configuration.VERSION_2_3_24);
 
         TemplateLoader templateLoader = new ClassTemplateLoader(
                 Transform.class, "templates");
@@ -2676,7 +2676,7 @@
 
 	private void generateHTMLFile_inner(SimpleHash dataModel, String fileName)
             throws TemplateException, IOException {
-        Template template = fmConfig.getTemplate("page.ftl");
+        Template template = fmConfig.getTemplate("page.ftlh");
         File outputFile = new File(destDir, fileName);
         FileOutputStream fos = new FileOutputStream(outputFile);
         OutputStreamWriter osw = new OutputStreamWriter(fos, UTF_8);
diff --git a/src/main/org/freemarker/docgen/templates/customizations.ftl b/src/main/org/freemarker/docgen/templates/customizations.ftlh
similarity index 100%
rename from src/main/org/freemarker/docgen/templates/customizations.ftl
rename to src/main/org/freemarker/docgen/templates/customizations.ftlh
diff --git a/src/main/org/freemarker/docgen/templates/eclipse-toc.ftl b/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
similarity index 95%
rename from src/main/org/freemarker/docgen/templates/eclipse-toc.ftl
rename to src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
index 09f686b..dbe01ae 100644
--- a/src/main/org/freemarker/docgen/templates/eclipse-toc.ftl
+++ b/src/main/org/freemarker/docgen/templates/eclipse-toc.ftlx
@@ -1,6 +1,5 @@
 <#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"}>
 <#import "util.ftl" as u>
-<#escape x as x?html>
 <?xml version="1.0" encoding="utf-8"?>
 <?NLS TYPE="org.eclipse.help.toc"?>
 
@@ -36,5 +35,3 @@
 </#macro>
 
 <#macro "@text"></#macro>
-
-</#escape>
diff --git a/src/main/org/freemarker/docgen/templates/footer.ftl b/src/main/org/freemarker/docgen/templates/footer.ftlh
similarity index 87%
rename from src/main/org/freemarker/docgen/templates/footer.ftl
rename to src/main/org/freemarker/docgen/templates/footer.ftlh
index 120bea7..3dc2dc0 100644
--- a/src/main/org/freemarker/docgen/templates/footer.ftl
+++ b/src/main/org/freemarker/docgen/templates/footer.ftlh
@@ -1,16 +1,10 @@
-<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"} stripText = true>
-<#escape x as x?html>
+<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"}>
 
 <#import "util.ftl" as u>
 
 <#macro footer>
   <#compress>
     <#local book = .node?root.*>
-    <#local footerTitleHTML = u.getRequiredTitleAsString(book)>
-    <#local bookSubtitle = u.getOptionalSubtitleAsString(book)>
-    <#if bookSubtitle?hasContent>
-      <#local footerTitleHTML += " – " + bookSubtitle?html>
-    </#if>
 
     <div class="site-footer"><#t>
       <#-- keep site-width inside so background extends -->
@@ -52,7 +46,7 @@
 <#macro lastGenerated>
   Last generated:
   <time itemprop="dateModified" datetime="${transformStartTime?datetime?isoUtc}" title="${transformStartTime?datetime?string.full}"><#t>
-    ${transformStartTime?string('yyyy-MM-dd HH:mm:ss z')?html}<#t>
+    ${transformStartTime?string('yyyy-MM-dd HH:mm:ss z')}<#t>
   </time><#t>
 </#macro>
 
@@ -95,5 +89,3 @@
     </div><#t>
   </#list>
 </#macro>
-
-</#escape>
diff --git a/src/main/org/freemarker/docgen/templates/google.ftl b/src/main/org/freemarker/docgen/templates/google.ftlh
similarity index 86%
rename from src/main/org/freemarker/docgen/templates/google.ftl
rename to src/main/org/freemarker/docgen/templates/google.ftlh
index c23c043..af858fe 100644
--- a/src/main/org/freemarker/docgen/templates/google.ftl
+++ b/src/main/org/freemarker/docgen/templates/google.ftlh
@@ -1,8 +1,9 @@
 <#macro search>
   <#if searchKey??>
     <script>
+      <#noAutoEsc>
       (function() {
-        var cx = '${searchKey}';
+        var cx = '${searchKey?jsString}';
         var gcse = document.createElement('script');
         gcse.type = 'text/javascript';
         gcse.async = true;
@@ -11,6 +12,7 @@
         var s = document.getElementsByTagName('script')[0];
         s.parentNode.insertBefore(gcse, s);
       })();
+      </#noAutoEsc>
     </script>
     <gcse:searchbox></gcse:searchbox>
   </#if>
@@ -21,8 +23,9 @@
   <#if searchKey??>
     <div class="search-results">
       <script>
+        <#noAutoEsc>
         (function() {
-          var cx = '${searchKey}';
+          var cx = '${searchKey?jsString}';
           var gcse = document.createElement('script');
           gcse.type = 'text/javascript';
           gcse.async = true;
@@ -31,6 +34,7 @@
           var s = document.getElementsByTagName('script')[0];
           s.parentNode.insertBefore(gcse, s);
         })();
+        </#noAutoEsc>
       </script>
       <gcse:searchresults-only>Loading…</gcse:searchresults-only>
     </div>
diff --git a/src/main/org/freemarker/docgen/templates/header.ftl b/src/main/org/freemarker/docgen/templates/header.ftlh
similarity index 92%
rename from src/main/org/freemarker/docgen/templates/header.ftl
rename to src/main/org/freemarker/docgen/templates/header.ftlh
index b68f86d..9061663 100644
--- a/src/main/org/freemarker/docgen/templates/header.ftl
+++ b/src/main/org/freemarker/docgen/templates/header.ftlh
@@ -1,8 +1,7 @@
-<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"} stripText = true>
-<#escape x as x?html>
+<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"}>
 
-<#import "navigation.ftl" as nav>
-<#import "google.ftl" as google>
+<#import "navigation.ftlh" as nav>
+<#import "google.ftlh" as google>
 
 
 <#macro header>
@@ -79,5 +78,3 @@
     </#list>
   </ul><#t>
 </#macro>
-
-</#escape>
diff --git a/src/main/org/freemarker/docgen/templates/navigation.ftl b/src/main/org/freemarker/docgen/templates/navigation.ftlh
similarity index 86%
rename from src/main/org/freemarker/docgen/templates/navigation.ftl
rename to src/main/org/freemarker/docgen/templates/navigation.ftlh
index bdc9971..f40f403 100644
--- a/src/main/org/freemarker/docgen/templates/navigation.ftl
+++ b/src/main/org/freemarker/docgen/templates/navigation.ftlh
@@ -1,10 +1,9 @@
 <#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"}>
-<#escape x as x?html>
 
 <#import "util.ftl" as u>
 
-<#import "node-handlers.ftl" as defaultNodeHandlers>
-<#import "customizations.ftl" as customizations>
+<#import "node-handlers.ftlh" as defaultNodeHandlers>
+<#import "customizations.ftlh" as customizations>
 <#assign nodeHandlers = [customizations, defaultNodeHandlers]>
 
 <#macro navigationBar top>
@@ -26,7 +25,7 @@
     <div class="navigation">
       <#-- keep site-width inside navigation so that the background extends -->
       <div class="site-width">
-        <#noEscape>${captured}</#noEscape><#t>
+        ${captured?noEsc}<#t>
       </div>
     </div>
   </#if>
@@ -66,23 +65,25 @@
 
 
 <#macro breadcrumbJs>
-  var breadcrumb = [<#t>
-  <#local path = []>
-  <#local curNode = .node>
-  <#list 1.. as _>
-    <#local path = [curNode] + path>
-    <#if curNode.@docgen_root_element?size != 0>
-      <#break>
-    </#if>
-    <#local curNode = curNode?parent>
-  </#list>
-  <#if (path?size > 1)>
-    <#list path as step>
-      "<#noEscape>${u.titleToString(step.title[0]!step.info.title)?jsString}</#noEscape>"<#t>
-      <#sep>,<#t>
+  <#outputFormat "plainText">
+    var breadcrumb = [<#t>
+    <#local path = []>
+    <#local curNode = .node>
+    <#list 1.. as _>
+      <#local path = [curNode] + path>
+      <#if curNode.@docgen_root_element?size != 0>
+        <#break>
+      </#if>
+      <#local curNode = curNode?parent>
     </#list>
-  </#if>
-  ];<#t>
+    <#if (path?size > 1)>
+      <#list path as step>
+        "${u.titleToString(step.title[0]!step.info.title)?jsString}"<#t>
+        <#sep>,<#t>
+      </#list>
+    </#if>
+    ];<#t>
+  </#outputFormat>
 </#macro>
 
 
@@ -155,4 +156,3 @@
   </#compress>
 </#macro>
 
-</#escape>
diff --git a/src/main/org/freemarker/docgen/templates/node-handlers.ftl b/src/main/org/freemarker/docgen/templates/node-handlers.ftlh
similarity index 94%
rename from src/main/org/freemarker/docgen/templates/node-handlers.ftl
rename to src/main/org/freemarker/docgen/templates/node-handlers.ftlh
index 14a1f51..d6e761f 100644
--- a/src/main/org/freemarker/docgen/templates/node-handlers.ftl
+++ b/src/main/org/freemarker/docgen/templates/node-handlers.ftlh
@@ -5,7 +5,6 @@
 <#-- Constants: -->
 <#assign forProgrammersCss = "programmers-note">
 
-
 <#-- State variables: -->
 <#assign
     inHtmlP = false, compactPara = false,
@@ -14,7 +13,7 @@
 >
 <#assign footnotes = []>
 
-<#macro @text>${.node?html}</#macro>
+<#macro @text>${.node}</#macro>
 
 <#macro @element>
   <#stop "This DocBook element is not supported by the Docgen transformer, "
@@ -112,7 +111,7 @@
         <#elseIf mark = "">
             <ul><#t>
         <#else>
-            <ul type="${mark?html}"><#t>
+            <ul type="${mark}"><#t>
         </#if>
         <#recurse>
         </ul><#t>
@@ -122,16 +121,16 @@
 
 <#macro link>
    <#if .node.@linkend?hasContent>
-      <a href="${CreateLinkFromID(.node.@linkend)?html}"><#recurse></a><#t>
+      <a href="${CreateLinkFromID(.node.@linkend)}"><#recurse></a><#t>
    <#else>
-      <a href="${.node["@xlink:href"]?html}"><#recurse></a><#t>
+      <a href="${.node["@xlink:href"]}"><#recurse></a><#t>
    </#if>
 </#macro>
 
 <#macro listitem>
    <#local mark=.node?parent.@mark[0]!>
    <#if mark != "">
-       <li style="list-style-type: ${mark?html}"><#t>
+       <li style="list-style-type: ${mark}"><#t>
    <#else>
        <li><#t>
    </#if>
@@ -211,7 +210,7 @@
 <#macro olink>
     <#if !(olinks[.node.@targetdoc]??)>
       <#stop "The olink element refers to an unknown targetdoc: \""
-             + .node.@targetdoc?xml
+             + .node.@targetdoc?jsString
              + "\". Ensure this target is defined in the docgen.cfg file.">
     </#if>
     <a href="${olinks[.node.@targetdoc]}"><#recurse></a><#t>
@@ -249,10 +248,10 @@
     <p<#if cssClass?hasContent> class="${cssClass}"</#if>><#t>
     <#local content><@Anchor /><#recurse></#local><#t>
     <#-- Avoid empty p element when closing para directly after orderedlist or itemizedlist. -->
-    <#if !content?matches(r".*<p>\s*$", "s")>
+    <#if !content?markup?matches(r".*<p>\s*$", "s")>
         ${content}</p><#t>
     <#else>
-        ${content[0 ..< content?lastIndexOf("<p>")]}<#t>
+        ${content?markup[0 ..< content?lastIndexOf("<p>")]?noEsc}<#t>
     </#if>
     <#assign inHtmlP = false>
   </#if>
@@ -364,7 +363,7 @@
     <div class="code-wrapper"><#t>
     <pre class="code-block ${codeType}"><@Anchor/><#t><#-- XXE and usual FO-stylesheet-compatible interpretation of inital line-breaks -->
       <#local content><#recurse></#local><#t>
-      ${content?chopLinebreak}</pre></div><#t>
+      ${content?markup?chopLinebreak?noEsc}</pre></div><#t>
   </@CantBeNestedIntoP>
 </#macro>
 
@@ -459,7 +458,7 @@
     <#list indexEntries as key>
       <#local letter = key[0]?upperCase>
       <#if lastLetter != letter>
-        <#if lastLetter != "">&nbsp;| </#if><a href="#${index_safeID(letter)?html}">${letter?html}</a><#t>
+        <#if lastLetter != "">&nbsp;| </#if><a href="#${index_safeID(letter)}">${letter}</a><#t>
         <#local lastLetter = letter>
       </#if>
     </#list>
@@ -474,14 +473,14 @@
         </dl></div><#lt>
       </#if>
       <div class="indexdiv"><#lt>
-      <a name="${index_safeID(letter)?html}"></a><#lt>
-      <h2 class="indexLabel">${letter?html}</h2><#lt>
+      <a name="${index_safeID(letter)}"></a><#lt>
+      <h2 class="indexLabel">${letter}</h2><#lt>
       <dl><#lt>
       <#local lastLetter = letter>
     </#if>
     <#local entryNodes = primaryIndexTermLookup[key]>
     <dt>
-      ${key?html}<#if entryNodes?hasContent>,&nbsp;&nbsp;</#if><#rt>
+      ${key}<#if entryNodes?hasContent>,&nbsp;&nbsp;</#if><#rt>
       <#list entryNodes as entryNode>
         <a href="${CreateLinkFromNode(entryNode)}"><#t><@index_entryText entryNode/></a><#t>
         <#sep>,</#sep><#lt>
@@ -492,7 +491,7 @@
       <dd><dl>
       <#list secondaryTerms?keys?sort as secondary>
         <dt><#rt>
-        ${secondary?html}, <#t>
+        ${secondary}, <#t>
         <#list secondaryTerms[secondary] as secondaryNode>
           <a href="${CreateLinkFromNode(secondaryNode)}"><#t>
             <@index_entryText secondaryNode/><#t>
@@ -517,7 +516,7 @@
     <#if node.title?hasContent>
       <#local title=node.title>
       <#if !node.@id[0]!?startsWith("autoid_")>
-        ${title?trim?html}<#t>
+        ${title?trim}<#t>
         <#return>
       </#if>
     </#if>
@@ -541,7 +540,7 @@
       <#if fullgt?size != 0>
         <#local gtl = fullgt.@@text[0]?upperCase>
         <#if gtl != lgtl>
-          <#if lgtl != "">&nbsp;| </#if><a href="#${ge.@id?html}">${gtl?html}</a><#t>
+          <#if lgtl != "">&nbsp;| </#if><a href="#${ge.@id}">${gtl}</a><#t>
           <#local lgtl = gtl>
         </#if>
       </#if>
@@ -608,7 +607,7 @@
 </#macro>
 
 <#macro ulink>
-  <a href="${.node.@url?html}"><#recurse></a><#t>
+  <a href="${.node.@url}"><#recurse></a><#t>
 </#macro>
 
 <#macro xref>
@@ -618,7 +617,7 @@
 
   <#local label = targetNode.@xreflabel[0]!>
   <#if label?hasContent>
-    <a href="${targetLink?html}">${label?html}</a><#t>
+    <a href="${targetLink}">${label}</a><#t>
   <#else>
     <#local labelHTMLs = buildTitleHTMLChain(targetNode)>
     <#if labelHTMLs?size == 0>
@@ -626,16 +625,16 @@
           + "\" has no \"title\" element in it nor \"xreflabel\" attribute.">
     </#if>
     <#local ctxLabelHTMLs = buildTitleHTMLChain(.node, true)>
-    <a href="${targetLink?html}"><#t>
+    <a href="${targetLink}"><#t>
       <#local started = false>
       <#list labelHTMLs as labelHTML>
         <#if started || !(
               labelHTML?hasNext
               && ctxLabelHTMLs[labelHTML?index]??
-              && labelHTML == ctxLabelHTMLs[labelHTML?index]
+              && labelHTML?markup == ctxLabelHTMLs[labelHTML?index]?markup
             )
         >
-          ${labelHTML}<#sep>/</#sep><#t>
+          ${labelHTML?noEsc}<#sep>/</#sep><#t>
           <#local started = true>
         </#if>
       </#list>
@@ -685,7 +684,7 @@
   <${.node?nodeName}<#t>
     <#list .node.@@ as att>
       <#if supportedAtts[att?nodeName]??>
-        ${' '}${att?nodeName}="${att?html}"<#t>
+        ${' '}${att?nodeName}="${att}"<#t>
       <#else>
         <#stop 'Unimplemented attribute for "${.node?nodeName}": ' + att?nodeName>
       </#if>
@@ -695,7 +694,7 @@
     <#recurse><#t>
     </${.node?nodeName}><#t>
   </#if>
-  ${"\n"}<#t>
+  ${'\n'}<#t>
 </#macro>
 
 <#assign htmlAlignAtts = {"align":true, "valign":true}>
diff --git a/src/main/org/freemarker/docgen/templates/page.ftl b/src/main/org/freemarker/docgen/templates/page.ftlh
similarity index 94%
rename from src/main/org/freemarker/docgen/templates/page.ftl
rename to src/main/org/freemarker/docgen/templates/page.ftlh
index e5e5991..9c548a9 100644
--- a/src/main/org/freemarker/docgen/templates/page.ftl
+++ b/src/main/org/freemarker/docgen/templates/page.ftlh
@@ -1,12 +1,11 @@
-<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"} stripText = true>
-<#escape x as x?html>
+<#ftl nsPrefixes={"D":"http://docbook.org/ns/docbook"} stripText=true>
 <#import "util.ftl" as u>
-<#import "footer.ftl" as footer>
-<#import "header.ftl" as header>
-<#import "navigation.ftl" as nav>
-<#import "google.ftl" as google>
-<#import "node-handlers.ftl" as defaultNodeHandlers>
-<#import "customizations.ftl" as customizations>
+<#import "footer.ftlh" as footer>
+<#import "header.ftlh" as header>
+<#import "navigation.ftlh" as nav>
+<#import "google.ftlh" as google>
+<#import "node-handlers.ftlh" as defaultNodeHandlers>
+<#import "customizations.ftlh" as customizations>
 <#assign nodeHandlers = [customizations, defaultNodeHandlers]>
 <@page>
   <#assign titleElement = u.getRequiredTitleElement(.node)>
@@ -58,7 +57,7 @@
       <@css />
 
       <#if !offline && onlineTrackerHTML??>
-        <#noEscape>${onlineTrackerHTML}</#noEscape>
+        ${onlineTrackerHTML?noEsc}
       </#if>
     </head>
   </#compress>
@@ -206,8 +205,7 @@
   </#compress>
 </#macro>
 
+
 <#function getPageType>
   <#return pageType!.node?nodeName>
 </#function>
-
-</#escape>
diff --git a/src/main/org/freemarker/docgen/templates/sitemap.ftl b/src/main/org/freemarker/docgen/templates/sitemap.ftlx
similarity index 100%
rename from src/main/org/freemarker/docgen/templates/sitemap.ftl
rename to src/main/org/freemarker/docgen/templates/sitemap.ftlx