Make "render formulas" independent of "render LaTeX" (#2195)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Make "render formulas" independent of "render LaTeX" (#2195)

Felix Natter
Administrator
Dear devs,

concerning: http://sourceforge.net/p/freeplane/bugs/2195/

While I think it would be nice to separate this, It's hard to pull this
out of the "TextTransformer" role.

Option 1: rename

Data formatting and parsing
[x] Recognize input of numbers and date-time

to

Data formatting and parsing
[x] Recognize input of numbers, date-time and LaTeX

OR Option 2: do the "parse_data" ("Recognize input of numbers and
date-time") evalution in:
  org.freeplane.features.text.TextController.addTextTransformer(IContentTransformer)

[1] LinkTransformer is also an IContentTransformer

What do you think?

Thanks and Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|

Re: Make "render formulas" independent of "render LaTeX" (#2195)

Volker Börchers
Administrator
Hi Felix,

would it suffice to modify the registration of the various
TextTransformers? LatexTextTransformer could possible be registered in
any case while the other transformers would only be registered if requested.

Regards,
Volker

Am 02.11.2014 um 17:11 schrieb Felix Natter [via Freeplane Developer]:

> Dear devs,
>
> concerning: http://sourceforge.net/p/freeplane/bugs/2195/
>
> While I think it would be nice to separate this, It's hard to pull this
> out of the "TextTransformer" role.
>
> Option 1: rename
>
> Data formatting and parsing
> [x] Recognize input of numbers and date-time
>
> to
>
> Data formatting and parsing
> [x] Recognize input of numbers, date-time and LaTeX
>
> OR Option 2: do the "parse_data" ("Recognize input of numbers and
> date-time") evalution in:
>
> org.freeplane.features.text.TextController.addTextTransformer(IContentTransformer)
>
>
> [1] LinkTransformer is also an IContentTransformer
>
> What do you think?
>
> Thanks and Best Regards,
> --
> Felix Natter
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/Make-render-formulas-independent-of-render-LaTeX-2195-tp565.html
>
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here
> <
> NAML
> <
http://freeplane-developer.996965.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|

Re: Make "render formulas" independent of "render LaTeX" (#2195)

Felix Natter
Administrator
"Volker Börchers [via Freeplane Developer]"
<[hidden email]> writes:

> Hi Felix,

hello Volker,

> would it suffice to modify the registration of the various
> TextTransformers?

Almost, but because there are places, where "text transformations"
in general are turned on/off. If I replace all references to the
"parse_data" option with 'true', and honor "parse_data" for all text
transformers (except LaTeX) then it works.

The patch is attached for early review. At least it needs cleaning.

BTW: Do we need an option to turn on/off LaTeX parsing
(like "parse_data" but for LaTeX)?

Thanks and Best Regards,
--
Felix Natter

diff --git a/freeplane/src/org/freeplane/features/text/TextController.java b/freeplane/src/org/freeplane/features/text/TextController.java
index 4f8390a..2fd6ad3 100644
--- a/freeplane/src/org/freeplane/features/text/TextController.java
+++ b/freeplane/src/org/freeplane/features/text/TextController.java
@@ -106,7 +106,9 @@ public class TextController implements IExtension {
  modeController.addAction(new ToggleDetailsAction());
  modeController.addAction(new SetShortenerStateAction());
 // modeController.addAction(new ToggleNodeNumberingAction());
- addTextTransformer(new FormatContentTransformer(this, 50));
+ if (ResourceController.getResourceController().getBooleanProperty("parse_data")) {
+ addTextTransformer(new FormatContentTransformer(this, 50));
+ }
  registerDetailsTooltip();
  registerNodeTextTooltip();
  }
@@ -128,7 +130,7 @@ public class TextController implements IExtension {
  }
 
  public Object getTransformedObject(Object object, final NodeModel nodeModel, Object extension) throws TransformationException{
- if(object instanceof String && ResourceController.getResourceController().getBooleanProperty("parse_data")){
+ if(object instanceof String && /*ResourceController.getResourceController().getBooleanProperty("parse_data")*/true){
  String string = (String) object;
  if(string.length() > 0 && string.charAt(0) == '\''){
  if(isTextFormattingDisabled(nodeModel))
@@ -347,7 +349,7 @@ public class TextController implements IExtension {
  return format;
  }
         }
-        return parseData() ? PatternFormat.STANDARD_FORMAT_PATTERN : PatternFormat.IDENTITY_PATTERN;
+        return /*parseData()*/true ? PatternFormat.STANDARD_FORMAT_PATTERN : PatternFormat.IDENTITY_PATTERN;
     }
 
  public boolean parseData() {
diff --git a/freeplane/src/org/freeplane/features/text/mindmapmode/MTextController.java b/freeplane/src/org/freeplane/features/text/mindmapmode/MTextController.java
index 707cb46..d86786c 100644
--- a/freeplane/src/org/freeplane/features/text/mindmapmode/MTextController.java
+++ b/freeplane/src/org/freeplane/features/text/mindmapmode/MTextController.java
@@ -365,7 +365,7 @@ public class MTextController extends TextController {
  }
 
     public Object guessObject(final Object text, final String oldFormat) {
-        if (parseData() && text instanceof String) {
+        if (/*parseData()*/ true && text instanceof String) {
             if (PatternFormat.getIdentityPatternFormat().getPattern().equals(oldFormat))
                 return text;
             final Object parseResult = ScannerController.getController().parse((String) text);
diff --git a/freeplane/src/org/freeplane/features/ui/FrameController.java b/freeplane/src/org/freeplane/features/ui/FrameController.java
index f911dc0..089f9e9 100644
--- a/freeplane/src/org/freeplane/features/ui/FrameController.java
+++ b/freeplane/src/org/freeplane/features/ui/FrameController.java
@@ -630,7 +630,7 @@ abstract public class FrameController implements ViewController {
  this.oldItem = null;
             if(item != null && oldItem != null && item.toString().equals(oldItem.toString()))
              return oldItem;
-            if(ResourceController.getResourceController().getBooleanProperty("parse_data")
+            if(/*ResourceController.getResourceController().getBooleanProperty("parse_data")*/true
              && item instanceof String){
                 final Object scannedObject = ScannerController.getController().parse((String)item);
                 return scannedObject;
diff --git a/freeplane_plugin_formula/src/org/freeplane/plugin/formula/Activator.java b/freeplane_plugin_formula/src/org/freeplane/plugin/formula/Activator.java
index b73afe6..db572b8 100644
--- a/freeplane_plugin_formula/src/org/freeplane/plugin/formula/Activator.java
+++ b/freeplane_plugin_formula/src/org/freeplane/plugin/formula/Activator.java
@@ -29,7 +29,9 @@ public class Activator implements BundleActivator {
  final EvaluateAllAction evaluateAllAction = new EvaluateAllAction();
  modeController.addAction(evaluateAllAction);
  if (!disablePluginProperty) {
- TextController.getController(modeController).addTextTransformer(new FormulaTextTransformer(1));
+ if (ResourceController.getResourceController().getBooleanProperty("parse_data")) {
+ TextController.getController(modeController).addTextTransformer(new FormulaTextTransformer(1));
+ }
  // to enable Formulas in text templates:
  // TextController.getController(modeController).addTextTransformer(new FormulaTextTransformer(100));
  final FormulaUpdateChangeListener listener = new FormulaUpdateChangeListener();
Reply | Threaded
Open this post in threaded view
|

Re: Make "render formulas" independent of "render LaTeX" (#2195)

Felix Natter
Administrator
hello @Volker, @Dimitry, @...:

What do you think about the patch?
Shall I provide a clean version of it and test it more thoroughly?

Are there performance implications of disabling "parse_data" later in
the chain?

I think the currrent state is a bit strange anyway (TextController.java):
    public boolean parseData() {
        return false;
    }

and the prefs option shall be renamed:
"Recognize input of numbers and date time"->
"Recognize input of numbers/date time and formulas (not LaTeX)"?

Thanks and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|

Re: Make "render formulas" independent of "render LaTeX" (#2195)

Volker Börchers
Administrator
Hi Felix,

I'm sorry for letting you wait for an answer!

Content recognition is a difficult thing since it can't be optimal for
everyone but the current way Freeplane treats "parse_data" is actually
very irritating:

- parse_data should only affect parsing input but instead it affects
rendering output as well since it sets nodes' format to "Text".

- setting parse_data to off not only affects new nodes (i.e. newly
parsed nodes) but _all_ nodes (that don't have a special format set).

- Setting format to "Text" has irritating effects as well: Instead of
changing the style of the text it switches content recognition off.
Excel doesn't do that for formulas.

- _But_ if one disabled "parse_data" one can still enforce latex and
formulas by setting the format to "Latex" or "Standard".

I think it would be best to keep almost everything as it is, except...

1. Add an option to the preferences to disable recognition of \latex
(for new nodes). This should be the only way to disable recognition of
nodes starting witn "\latex".
2. Only disable =formula evaluation if "Disable formula evaluation" is
set in the preferences. Let changes take effect immediately (like
"parse_data").
3. We could perhaps assign an explicit format to every new node to avoid
disabling "parse_data" makes changes to existing nodes.

parse_data changes come into effect immediately. This is useful and
shouldn't change so Transformer registration is not an option anymore in
my eyes.

Regards,
Volker

Am 29.11.2014 um 16:51 schrieb Felix Natter [via Freeplane Developer]:

> hello @Volker, @Dimitry, @...:
>
> What do you think about the patch?
> Shall I provide a clean version of it and test it more thoroughly?
>
> Are there performance implications of disabling "parse_data" later in
> the chain?
>
> I think the currrent state is a bit strange anyway (TextController.java):
>      public boolean parseData() {
>          return false;
>      }
>
> and the prefs option shall be renamed:
> "Recognize input of numbers and date time"->
> "Recognize input of numbers/date time and formulas (not LaTeX)"?
>
> Thanks and Best Regards,
> Felix
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/Make-render-formulas-independent-of-render-LaTeX-2195-tp565p577.html
>
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here
> <
> NAML
> <
http://freeplane-developer.996965.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|

Re: Make "render formulas" independent of "render LaTeX" (#2195)

Felix Natter
Administrator
"Volker Börchers [via Freeplane Developer]"
<[hidden email]> writes:

> Hi Felix,

Good morning Volker,

> I'm sorry for letting you wait for an answer!

No problem.

> Content recognition is a difficult thing since it can't be optimal for
> everyone but the current way Freeplane treats "parse_data" is actually
> very irritating:
>
> - parse_data should only affect parsing input but instead it affects
> rendering output as well since it sets nodes' format to "Text".
>
> - setting parse_data to off not only affects new nodes (i.e. newly
> parsed nodes) but _all_ nodes (that don't have a special format set).

I think that is ok (Excel behaves that way (but it has no way of
switching that off)).

> - Setting format to "Text" has irritating effects as well: Instead of
> changing the style of the text it switches content recognition off.
> Excel doesn't do that for formulas.

Ok, sounds less-than-perfect but ok.

> - _But_ if one disabled "parse_data" one can still enforce latex and
> formulas by setting the format to "Latex" or "Standard".

That's a workaround, but I think it would be better if the "\latex "
prefix would still be honored if parse_data==false (if that's not too
much effort, of course).

> I think it would be best to keep almost everything as it is, except...
>
> 1. Add an option to the preferences to disable recognition of \latex
> (for new nodes). This should be the only way to disable recognition of
> nodes starting witn "\latex".

Agreed, but "for new nodes" could be tricky (as you state above)?

> 2. Only disable =formula evaluation if "Disable formula evaluation" is
> set in the preferences.

Do you mean:

New prefs option "Disable formula evaluation" that is evaluated in
freeplane_plugin_formula/src/org/freeplane/plugin/formula/Activator.java
and keep "parse_data" logic as is
=> this means that if parse_data==false and "Disable formula
evaluation"==false, formulas won't be shown.

[P.S. I realize it would break "parse_data" changes to come into effect
immediately...]

=> but this won't fix #2195 ("Latex formatting clashes with the "Date
formatting" options")
=> do we want to apply (a variant of, see below!) my hack for that?

> Let changes take effect immediately (like
> "parse_data").

I think this is done by always querying
"ResourceController.getResourceController().getBooleanProperty("parse_data")"?

> 3. We could perhaps assign an explicit format to every new node to avoid
> disabling "parse_data" makes changes to existing nodes.

That's a good idea, but it's a different feature/bug.

> parse_data changes come into effect immediately. This is useful and
> shouldn't change so Transformer registration is not an option anymore in
> my eyes.

You are saying that I shouldn't apply hacks like these:

- TextController.getController(modeController).addTextTransformer(new FormulaTextTransformer(1));
+ if (ResourceController.getResourceController().getBooleanProperty("parse_data")) {
+ TextController.getController(modeController).addTextTransformer(new FormulaTextTransformer(1));
+ }

in order not to break "parse_data" changes to come into effect
immediately?

Thanks and Best Regards,
--
Felix Natter