changeset 8:e8ea26ab2cd7

[no commit message]
author ferrall@nwoca.org
date Fri, 28 Jan 2011 08:20:29 -0500
parents a634b4d554d4
children ccb40d1cb213
files src/org/nwoca/ssdt/tools/html2wiki/Html2Wiki.java
diffstat 1 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/nwoca/ssdt/tools/html2wiki/Html2Wiki.java	Thu Jan 27 18:07:28 2011 -0500
+++ b/src/org/nwoca/ssdt/tools/html2wiki/Html2Wiki.java	Fri Jan 28 08:20:29 2011 -0500
@@ -37,7 +37,6 @@
         transformers.add(new DeleteTransformer("<!--.*-->(\\n|\\r)*",true));
         transformers.add(new DeleteTransformer("<a .*?>|</a>"));
         transformers.add(new DeleteTransformer("(?m)^\\*"));
-//        transformers.add(new DeleteTransformer("<blockquote>|</blockquote>"));
         transformers.add(new DeleteTransformer("(?m)<br>$"));
         transformers.add(new DeleteTransformer("<font .*?>|</font>"));
         transformers.add(new CloseTagTransformer("<li>","(\n|\r)*(<li>|</ul>|</ol>|<ul>|<ol>)","</li>"));
@@ -45,15 +44,18 @@
         transformers.add(new BadTableRowTransformer());
         transformers.add(new ReflowTransformer());
         transformers.add(new DeleteTransformer("<p>"));
-//        transformers.add(new ReplaceTransformer("</td>","\n</td>"));
-          transformers.add(new ReplaceTransformer("\\{","\\{"));  // Escape braces
-          transformers.add(new ReplaceTransformer("\\}","\\}"));
+        transformers.add(new ReplaceTransformer("\\{","\\{"));  // Escape braces
+        transformers.add(new ReplaceTransformer("\\}","\\}"));
 
         transformers.add(new ReplaceTransformer("\\[","\\["));  // Escape brackets
         transformers.add(new ReplaceTransformer("\\]","\\]"));
         transformers.add(new PreTagTransformer());              // Unescape brackets inside <pre>
 //
         transformers.add(new ReplaceTransformer("<br>","\\\\"));
+
+        //replace table tag preserving border setting.
+        transformers.add(new TagTransformer("<table\\sborder=(\\d).*?>", true, "{table:border=","}"));
+
         transformers.add(new ReplaceTransformer("<table.*?>|</table>","{table}"));
         transformers.add(new ReplaceTransformer("<tr>|</tr>","{tr}"));
         transformers.add(new ReplaceTransformer("<td.*?>|</td>","{td}"));
@@ -77,14 +79,23 @@
         transformers.add(new TagTransformer("<h4>(.*)</h4>",    "h4. ",   ""));
         transformers.add(new TagTransformer("<h5>(.*)</h5>",    "h5. ",  ""));
         transformers.add(new TagTransformer("<h6>(.*)</h6>",    "h6. ", ""));
-        transformers.add(new ReplaceTransformer("\\{center}\\n\\{table}\\n\\{tr\\}\\n\\s{2}\\{td\\}\\{center\\}\\*Note\\*\\{center\\}","{note}"));
-        transformers.add(new ReplaceTransformer("\\{td\\}\\n\\s{2}\\{tr\\}\\n\\{table\\}\\n\\{center\\}","{note}"));
+
+        //Replace Notes with Info tags.
+        transformers.add(new ReplaceTransformer("\\{center}\\n\\{table:border=\\d}\\n\\{tr\\}\\n\\s{2}\\{td\\}\\{center\\}\\*Note\\*\\{center\\}","{info}"));
+        transformers.add(new ReplaceTransformer("\\{td\\}\\n\\s{2}\\{tr\\}\\n\\{table\\}\\n\\{center\\}","{info}"));
 
-//        transformers.add(new TagTransformer("\\{center}\\n\\{table}\\n\\{tr\\}\\n\\s{2}\\{td\\}\\{center\\}\\*Note\\*\\{center\\}(.*?)\\s\\{td\\}\\n\\s{2}\\{tr\\}\\{table\\}",    "{note}",  "{note}"));
-//        transformers.add(new TagTransformer("(\\S)\\s\\n",    "", " "));
+        //Remove unnecessary table surrounding code blocks.
+        transformers.add(new ReplaceTransformer("\\{table:.*\\}\\n\\s{2}\\{tr\\}\\n\\s{4}\\{td\\}\\n\\s{6}\\n\\{code\\}","{code}"));
+        transformers.add(new ReplaceTransformer("\\{code\\}\\n\\{td\\}\\{tr\\}\\{table\\}","{code}"));
+
+        //Change borderStyle of code window for "screenshots" to none.
+        transformers.add(new TagTransformer("\\{code\\}([\\s\\n]*?_______________)", true, "{code:borderStyle=none}", ""));
+
+
+
         transformers.add(new TagTransformer("<blockquote>(.*?)</blockquote>", true,   "{quote}", "{quote}"));
         transformers.add(new DeleteTransformer("(?s)<hr.*?>"));
-        transformers.add(new ReflowTransformer("(\\{note\\})([^\\{]*)(\\{note\\})"));
+        transformers.add(new ReflowTransformer("(\\{info\\})([^\\{]*)(\\{info\\})"));
         transformers.add(new TagTransformer("<sup>(.*?)</sup>", true, "^\\[","\\]^ "));
         transformers.add(new ReplaceTransformer("&lt;","<"));
         transformers.add(new ReplaceTransformer("&gt;",">"));