Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: passing filter context #1195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/org/omegat/filters2/hhc/HHCFilter2.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void processFile(BufferedReader infile, BufferedWriter outfile, FilterCon
Parser parser = new Parser();
try {
parser.setInputHTML(all.toString());
parser.visitAllNodesWith(new HHCFilterVisitor(this, outfile));
parser.visitAllNodesWith(new HHCFilterVisitor(this, outfile, fc));
} catch (ParserException pe) {
System.out.println(pe);
}
Expand Down
6 changes: 4 additions & 2 deletions src/org/omegat/filters2/hhc/HHCFilterVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.io.BufferedWriter;

import org.htmlparser.Tag;

import org.omegat.filters2.FilterContext;
import org.omegat.filters2.html2.FilterVisitor;
import org.omegat.util.HTMLUtils;

Expand All @@ -40,8 +42,8 @@
* @author Didier Briel
*/
class HHCFilterVisitor extends FilterVisitor {
HHCFilterVisitor(HHCFilter2 hhcfilter, BufferedWriter bufwriter) {
super(hhcfilter, bufwriter, null);
HHCFilterVisitor(HHCFilter2 hhcfilter, BufferedWriter bufwriter, FilterContext fc) {
super(hhcfilter, bufwriter, null, fc);
}

// ///////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 5 additions & 1 deletion src/org/omegat/filters2/html2/FilterVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.htmlparser.nodes.TextNode;
import org.htmlparser.visitors.NodeVisitor;
import org.omegat.core.Core;
import org.omegat.filters2.FilterContext;
import org.omegat.util.HTMLUtils;
import org.omegat.util.Log;
import org.omegat.util.OStrings;
Expand All @@ -67,8 +68,10 @@ public class FilterVisitor extends NodeVisitor {
protected HTMLFilter2 filter;
private BufferedWriter writer;
private HTMLOptions options;
private FilterContext filterContext;

public FilterVisitor(HTMLFilter2 htmlfilter, BufferedWriter bufwriter, HTMLOptions opts) {
public FilterVisitor(HTMLFilter2 htmlfilter, BufferedWriter bufwriter, HTMLOptions opts,
FilterContext fc) {
this.filter = htmlfilter;
// HHC filter has no options
if (opts != null) {
Expand All @@ -79,6 +82,7 @@ public FilterVisitor(HTMLFilter2 htmlfilter, BufferedWriter bufwriter, HTMLOptio
this.options = new HTMLOptions(new TreeMap<>());
}
this.writer = bufwriter;
filterContext = fc;
}

// ///////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/org/omegat/filters2/html2/HTMLFilter2.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void processFile(BufferedReader infile, BufferedWriter outfile,
Parser parser = new Parser();
try {
parser.setInputHTML(all.toString());
parser.visitAllNodesWith(new FilterVisitor(this, outfile, options));
parser.visitAllNodesWith(new FilterVisitor(this, outfile, options, fc));
} catch (ParserException pe) {
Log.logErrorRB(pe, "HTML_EXCEPTION_PARSER");
} catch (StringIndexOutOfBoundsException se) {
Expand Down
Loading