我在LaTeX前面使用apache velocity。 #和$ escape字符与LaTeX冲突。我想将#with %%和$替换为@@以避免冲突。简单地在源文件代码上使用字符串替换不是一个好的解决方案,因为我必须使用#parse和#include之类的东西。解析/包含的文件也应该能够使用修改后的转义字符。有没有办法配置这个?有配置选项吗?
答案 0 :(得分:1)
您可以使用自定义资源加载程序修改#parse:
加载的文件VelocityEngine engine = new VelocityEngine();
Properties props = new Properties();
props.put("resource.loader", "customloader");
props.put("customloader.resource.loader.class", CustomLoader.class.getName());
engine.init(props);
public static class CustomLoader extends FileResourceLoader {
public InputStream getResourceStream(String arg0) throws ResourceNotFoundException {
InputStream original = super.getResourceStream(arg0);
//TODO modify original, return modified
original.close();
}
}