From 307571748a50fa6272ea13e6213e7d4d9d59c711 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Thu, 20 Dec 2012 11:03:14 +0530 Subject: SymbolMap class which was in CodeBlock.java is shifted to a dedicated file -- parsers/SymbolMap.java. added: parsers/SymbolMap.java modified: parsers/CodeBlocks.java --- parsers/CodeBlocks.java | 57 +------------------------------------------------ 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'parsers/CodeBlocks.java') diff --git a/parsers/CodeBlocks.java b/parsers/CodeBlocks.java index 251c4de..75efa27 100644 --- a/parsers/CodeBlocks.java +++ b/parsers/CodeBlocks.java @@ -36,70 +36,15 @@ public class CodeBlocks implements Parser { while(matcher.find()) { replacement.delete(0,replacement.length()); replacement.append("
"); - replacement.append(lbreak.parse(quote(matcher.group(3)))); + replacement.append(lbreak.parse(symbolMap.quote(matcher.group(3)))); replacement.append("
"); matcher.appendReplacement(sbuffer,replacement.toString()); } matcher.appendTail(sbuffer); return sbuffer.toString(); } - /** - * this method quotes symbols to a HTML number. - */ - private String quote(String string) { - Pattern pattern = Pattern.compile("(\\&(amp|lt|gt|(\\#35))\\;)|(\\p{Punct})"); - Matcher matcher = pattern.matcher(string); - StringBuffer sbuffer = new StringBuffer(); - while(matcher.find()) { - if(matcher.group(4)!=null) { - matcher.appendReplacement(sbuffer, - symbolMap.get(matcher.group())); - } - } - matcher.appendTail(sbuffer); - return sbuffer.toString(); - } } -/** - * Map of Symbols & their HTML equivalent numbers. - */ -class SymbolMap extends HashMap { - public SymbolMap() { - put("!","!"); - put("\"","""); - put("#","#"); - put("$","$"); - put("%","%"); - put("&","&"); - put("'","'"); - put("(","("); - put(")",")"); - put("*","*"); - put("+","+"); - put(",",","); - put("-","-"); - put(".","."); - put("/","/"); - put(":",":"); - put(";",";"); - put("<","<"); - put("=","="); - put(">",">"); - put("?","?"); - put("@","@"); - put("[","["); - put("\\","\"); - put("]","]"); - put("^","^"); - put("_","_"); - put("`","`"); - put("{","{"); - put("|","|"); - put("}","}"); - put("~","~"); - } -} /** Special Case: -- cgit v1.2.3