use of org.freeplane.features.format.FormattedFormula in project freeplane by freeplane.
the class FormulaTextTransformer method transformContent.
public Object transformContent(TextController textController, final Object obj, final NodeModel node, Object transformedExtension) {
if (obj instanceof FormattedFormula) {
final FormattedFormula formattedFormula = (FormattedFormula) obj;
final Object evaluationResult = transformContent(textController, formattedFormula.getObject(), node, transformedExtension);
return new FormattedObject(evaluationResult, formattedFormula.getPattern());
}
if (!(obj instanceof String)) {
return obj;
}
if (textController.isTextFormattingDisabled(node))
return obj;
final String text = obj.toString();
if (!FormulaUtils.containsFormulaCheckHTML(text)) {
return obj;
}
final String plainText = HtmlUtils.htmlToPlain(text);
// starting a new ScriptContext in evalIfScript
final Object result = FormulaUtils.evalIfScript(node, null, plainText);
if (result == null) {
throw new ExecuteScriptException("got null result from evaluating " + node.getID() + ", text='" + plainText.substring(1) + "'");
}
return result;
}
Aggregations