Skip to content

Commit

Permalink
Add methods to handle <qau>, <au> and <er> elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkgeek committed Sep 15, 2015
1 parent 9c8224a commit c0e2a64
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
25 changes: 25 additions & 0 deletions src/main/java/im/darkgeek/dicts/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ public int process(Element element) {
return 1;
}
};
Callback changeToHypeLink = new Callback() {
public int process(Element element) {
element.setName("a");
element.addAttribute("href", element.getTextTrim());
return 1;
}
};
Callback enhanceQAUblock = new Callback() {
public int process(Element element) {
List qauContents = element.content();
Iterator iterator = qauContents.iterator();

while (iterator.hasNext()) {
Node node = (Node) iterator.next();
if (node.getNodeType() == Node.TEXT_NODE) {
node.setText("--" + node.getText());
break;
}
}
return 1;
}
};

System.setProperty("entityExpansionLimit", "640000");
System.out.println(System.getProperty("user.dir"));
Expand All @@ -96,6 +118,9 @@ public int process(Element element) {
.addQuirk("sd", addBRbefore)
.addQuirk("as", handleASblock)
.addQuirk("pbr", rewriteElementNameToBR)
.addQuirk("er", changeToHypeLink)
.addQuirk("qau", enhanceQAUblock)
.addQuirk("au", enhanceQAUblock)
.generate();
System.out.println("Size: " + list.size());
DictGenerator.createGeneratorScript(list);
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/im/darkgeek/dicts/DictProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,10 @@ private void postElementProcess(Element element) {
}

String elemName = element.getName();
Set<String> wordsNotToBeProcessed = new HashSet<String>(Arrays.asList("br", "p", "div", "span"));

if (wordsNotToBeProcessed.contains(elemName))
return;

// Handle other kinds of elements specifically
// Handle elements specifically
if (quirksMap != null && quirksMap.containsKey(elemName)) {
quirksMap.get(elemName).process(element);
}

// element.setName("span");
// element.addAttribute("class", elemName);
}

/**
Expand Down

0 comments on commit c0e2a64

Please sign in to comment.