Description
I am not sure if this is a bug but we have the following situation.
We have a recognition application of recognizing text and decorating the text.
When we putting the below input text to the application:
Input for the application:
see art. 1 of the WW and then some other text
Just before the text art. 1 there is a Zero-Width space.
The application will make the text like this:
Input for the VelocityEngine:
see ${decorations[0]} and then some other text
Just before the text ${decorations[0]} there still is a Zero-Width space. because our application only changed art.1 of the WW into ${decorations[0]}
When we put this text to the VelocityEngine together with the decoration template and a list of laws in the context, the engine is changing my text. It's removing the Zero-Width Space.
Just before the VelocityEngine is using the text and the template, VelocityEngine is removing the Zer0-Width Space
Velocity should only do some markup and not change the original input text.
decoration.vm:
#set($decorations = []) #foreach($type in $annotationsMap.keySet()) #foreach($citation in $annotationsMap.get($type)) #set($hideAddResult = $decorations.add("## <verwijzing>$citation</verwijzing>## ")) #end #end
This is a pace of Java code:
Path templateFile = TEMPLATE_FILE.toPath(); VelocityEngine velocityEngine = new VelocityEngine(); Path pathName = templateFile.getParent(); velocityEngine.setProperty(FILE_RESOURCE_LOADER_PATH, pathName.toFile().getAbsolutePath()); velocityEngine.init(); Map<String, List<String>> annotationsMap = getAnnotationsMap(); StringBuilder templateStringBuilder = new StringBuilder("see \u200B${decorations[0]} and then some other text"); templateStringBuilder.insert(0, "#parse(\"" + templateFile.getFileName() + "\")"); VelocityContext context = new VelocityContext(); context.put("escape", new EscapeTool()); // annotationsMap is put in context as a whole, so that template script can decide what to do with different CitationTypes context.put("annotationsMap", annotationsMap); StringWriter writer = new StringWriter(); velocityEngine.evaluate(context, writer, templateFile.getFileName().toString(), templateStringBuilder.toString());
The output of this application is:
see <verwijzing>art. 1 of the WW</verwijzing> and then some other text
But just before <verwijzing> i expected the Zero-Width Space, but it's gone. So somewhere in the methode evaluate of the VelocityEngine this character is removed, because it's still present in the template text *"see ${decorations[0]} and then some other text"*
Please help.