mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Revert "Make TemplateRemoveer *actually* remove templates"
This reverts commit e0c23a6038.
mark found a way that was not as agricultural
This commit is contained in:
parent
f026bdd924
commit
f941989c19
1 changed files with 6 additions and 4 deletions
|
|
@ -12,6 +12,10 @@ public class TemplateRemoveModifier extends PageModifier {
|
||||||
|
|
||||||
public static final String PARAM_TEMPLATE_NAME = "template";
|
public static final String PARAM_TEMPLATE_NAME = "template";
|
||||||
|
|
||||||
|
public static final Pattern PATTERN_TEMPLATE_OPEN = Pattern.compile("\\{\\{");
|
||||||
|
public static final Pattern PATTERN_TEMPLATE_CLOSE = Pattern.compile("\\}\\}");
|
||||||
|
|
||||||
|
|
||||||
public TemplateRemoveModifier(String templateName) {
|
public TemplateRemoveModifier(String templateName) {
|
||||||
super(MODIFIER_NAME);
|
super(MODIFIER_NAME);
|
||||||
try {
|
try {
|
||||||
|
|
@ -26,7 +30,6 @@ public class TemplateRemoveModifier extends PageModifier {
|
||||||
this.params = data;
|
this.params = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Never get into a land war in Asia.
|
|
||||||
@Override
|
@Override
|
||||||
public String doModification(String pageName, String pageContents) {
|
public String doModification(String pageName, String pageContents) {
|
||||||
String templateRawName = params.optString(PARAM_TEMPLATE_NAME);
|
String templateRawName = params.optString(PARAM_TEMPLATE_NAME);
|
||||||
|
|
@ -44,14 +47,13 @@ public class TemplateRemoveModifier extends PageModifier {
|
||||||
int startIndex = matcher.start();
|
int startIndex = matcher.start();
|
||||||
int curIndex = matcher.end();
|
int curIndex = matcher.end();
|
||||||
while(curIndex < pageContents.length()) {
|
while(curIndex < pageContents.length()) {
|
||||||
if(pageContents.substring(curIndex, curIndex + 2).equals("{{")) {
|
if(PATTERN_TEMPLATE_OPEN.matcher(pageContents).find(curIndex)) {
|
||||||
braceCount++;
|
braceCount++;
|
||||||
} else if(pageContents.substring(curIndex, curIndex + 2).equals("}}")) {
|
} else if(PATTERN_TEMPLATE_CLOSE.matcher(pageContents).find(curIndex)) {
|
||||||
braceCount--;
|
braceCount--;
|
||||||
}
|
}
|
||||||
curIndex++;
|
curIndex++;
|
||||||
if(braceCount == 0) {
|
if(braceCount == 0) {
|
||||||
curIndex++; // To account for the last brace in the closing }} pair
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue