FormatContentTransformer?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

FormatContentTransformer?

Felix Natter
Administrator
hello,

can someone please explain what exactly FormatContentTransformer is used
for?  If I disable this, it seems I still get automatic conversions like
0001 -> 1
2015-01-01 -> 1/1/15

I guess it's for formatting nodes that have a particular (date) format
_assigned_ (manually)?

--> do we want to have a separate flag in the config for this?
I currently have:
                                <boolean name="parse_data" />
                                <boolean name="parse_formulas"/>
                                <boolean name="parse_latex"/>

like:
        <boolean name="parse_assigned_formats"/>
(maybe it makes sense to always enable this)

Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Dimitry Polivaev
Administrator
I guess it is used for nodes where in the formatting panel either format is set or node numbering is
enabled

Regards,
Dimitry

> hello,
>
> can someone please explain what exactly FormatContentTransformer is used
> for?  If I disable this, it seems I still get automatic conversions like
> 0001 -> 1
> 2015-01-01 -> 1/1/15
>
> I guess it's for formatting nodes that have a particular (date) format
> _assigned_ (manually)?
>
> --> do we want to have a separate flag in the config for this?
> I currently have:
>                                  <boolean name="parse_data" />
>                                  <boolean name="parse_formulas"/>
>                                  <boolean name="parse_latex"/>
>
> like:
>          <boolean name="parse_assigned_formats"/>
> (maybe it makes sense to always enable this)
>
> Best Regards,
> --
> Felix Natter


2015-06-22 22_38_55-2015-01-02_ - Freeplane - Mind map mode C__Users_Dimitry_Documents_2015-01-02.mm.png (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Volker Börchers
Administrator
In reply to this post by Felix Natter
Hi Felix,

Am 22.06.2015 um 21:28 schrieb Felix Natter [via Freeplane Developer]:
> can someone please explain what exactly FormatContentTransformer is used
> for?  If I disable this, it seems I still get automatic conversions like
> 0001 -> 1
> 2015-01-01 -> 1/1/15
>
> I guess it's for formatting nodes that have a particular (date) format
> _assigned_ (manually)?

Exactly: You can set the format via the properties panel (e. g. "Look:
%s". If the node has typed content (like a number or a date) its format
will be relevant as well.

> --> do we want to have a separate flag in the config for this?
> I currently have:
>                                  <boolean name="parse_data" />
>                                  <boolean name="parse_formulas"/>
>                                  <boolean name="parse_latex"/>
>
> like:
>          <boolean name="parse_assigned_formats"/>
> (maybe it makes sense to always enable this)

Why is there a need for that? Formatting will only change anything if either

- the value is something special like a date
- or the format has been explicitly set

You can turn off formatting by setting the format to "Text" or - as in
Excel - by starting the text with an apostrophe.

Data recognition on the other hand needs a flag to turn it off since you
don't do that manually.

Regards,
Volker
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

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

> Hi Felix,

hello Volker,

> Am 22.06.2015 um 21:28 schrieb Felix Natter [via Freeplane Developer]:
>> can someone please explain what exactly FormatContentTransformer is used
>> for? If I disable this, it seems I still get automatic conversions like
>> 0001 -> 1
>> 2015-01-01 -> 1/1/15
>>
>> I guess it's for formatting nodes that have a particular (date) format
>> _assigned_ (manually)?
>
> Exactly: You can set the format via the properties panel (e. g. "Look:
> %s". If the node has typed content (like a number or a date) its
> format

What is "Look: %s"?

> will be relevant as well.

I still don't understand. Is the following true?

- FormatContentTransformer is only for _explicit_ formats (properties
  panel) and node numbering?

- automatic conversions
 0001 -> 1
 2015-01-01 -> 1/1/15
are done outside any IContentTransformer implementation and are toggled
via "parse_data"?

>> --> do we want to have a separate flag in the config for this?
>> I currently have:
>> <boolean name="parse_data" />
>> <boolean name="parse_formulas"/>
>> <boolean name="parse_latex"/>
>>
>> like:
>> <boolean name="parse_assigned_formats"/>
>> (maybe it makes sense to always enable this)
>
> Why is there a need for that? Formatting will only change anything if
> either
>
> - the value is something special like a date
> - or the format has been explicitly set

Isn't it already conditional with the parse_data flag?

> You can turn off formatting by setting the format to "Text" or - as in
> Excel - by starting the text with an apostrophe.
>
> Data recognition on the other hand needs a flag to turn it off since you
> don't do that manually.

> the format has been explicitly set
--> I agree.

> the value is something special like a date
--> I disagree as this is not manual; if I understand correctly,
this will transform e.g. 2015-02-01 to 01.02.15.

Cheers and Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Volker Börchers
Administrator
Hi Felix,

>  > Exactly: You can set the format via the properties panel (e. g. "Look:
>  > %s". If the node has typed content (like a number or a date) its
>  > format
>
> What is "Look: %s"?

Enter it in the format field and you'll see - it's a Formatter pattern.

> I still don't understand. Is the following true?
>
> - FormatContentTransformer is only for _explicit_ formats (properties
>    panel) and node numbering?

in FormatContentTransformer.expandFormat() you have

   final boolean hasFormat = format != null && format.length() != 0 &&
!PatternFormat.IDENTITY_PATTERN.equals(format);
   if (!hasFormat && !nodeNumbering){
     return obj;
   }

You see, it's only a matter of the format property of a node's style
(see TextController.getNodeFormat()) or node numbering. _How_ the node
got its format (properties panel or conditional style) doesn't matter here.

> - automatic conversions
>   0001 -> 1
>   2015-01-01 -> 1/1/15
> are done outside any IContentTransformer implementation and are toggled
> via "parse_data"?

Yes this only sets an initial style if parsing succeeds.

>  >> --> do we want to have a separate flag in the config for this?
>  >> I currently have:
>  >> <boolean name="parse_data" />
>  >> <boolean name="parse_formulas"/>
>  >> <boolean name="parse_latex"/>
>  >>
>  >> like:
>  >> <boolean name="parse_assigned_formats"/>
>  >> (maybe it makes sense to always enable this)
>  >
>  > Why is there a need for that? Formatting will only change anything if
>  > either
>  >
>  > - the value is something special like a date
>  > - or the format has been explicitly set
>
> Isn't it already conditional with the parse_data flag?

Don't mix up parsing and formatting: Even if you turn off parsing you
may still have parsed values in a map.

>  > the value is something special like a date
> --> I disagree as this is not manual; if I understand correctly,
> this will transform e.g. 2015-02-01 to 01.02.15.

Parsing assigns a standard format. But even (or especially) for parsed
data changing format makes sense: In case of dates for instance you may
want to see the time part or change the format to hide the date part.

Best regards,
Volker
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Volker Börchers
Administrator
In reply to this post by Felix Natter
Hi Felix,

more users have been hit by the "Recognize input ...":

https://sourceforge.net/p/freeplane/discussion/758437/thread/7150c794/#1a36

The affected part isn't the FormatContentTransformer but the LinkTransformer

Regards,
Volker
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

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

> Hi Felix,

hello Devs,

> more users have been hit by the "Recognize input ...":
>
> https://sourceforge.net/p/freeplane/discussion/758437/thread/7150c794/#1a36
>
> The affected part isn't the FormatContentTransformer but the
> LinkTransformer

I think I've fixed the issue, but I ran a across one thing worth
discussing:

parse_data (Recognize input of numbers and date-time) = true:

--> I enter "0003", result is "3", viewed as "3"

parse_data=false (but with my changes, IContentTransformers are still
active):

--> I enter "0003", result is "0003" (as expected), but "3"
    is displayed (due to FormatContentTransformer)!

--> I don't think we want to automatically disable the
    FormatContentTransformer with parse_data=false, because it does
    things the user configured explicitly (like displaying
    Format=yyyy-MM-dd)

--> Shall I extract the parts of
    FormatContentTransformer.expandFormat(Object, NodeModel, String,
    boolean), that are not explicit (like formatting Format=Standard
    nodes) into another IContentTransformer that gets triggered
    with 'parse_data' (or modify FormatContentTransformer to do this
    conditionally)?

In any case, it's confusing that if you turn off 'parse_data', Freeplane
still messes with your numbers.

What do you think?

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

Re: FormatContentTransformer?

Volker Börchers
Administrator
Hi Felix,

parsing and formatting should be kept separate, so please don't introduce a formatter that depends on the parse flag. You turn off formatting with the Text format as in excel.

Nevertheless I'm a bit puzzled why 0003 gets formatted as 3. What happens there?

Regards,
Volker

Am 13. Juli 2015 21:42:31 MESZ, schrieb "Felix Natter [via Freeplane Developer]" <[hidden email]>:
"Volker Börchers [via Freeplane Developer]"
<[hidden email]> writes:

> Hi Felix,

hello Devs,

> more users have been hit by the "Recognize input ...":
>
> https://sourceforge.net/p/freeplane/discussion/758437/thread/7150c794/#1a36
>
> The affected part isn't the FormatContentTransformer but the
> LinkTransformer

I think I've fixed the issue, but I ran a across one thing worth
discussing:

parse_data (Recognize input of numbers and date-time) = true:

--> I enter "0003", result is "3", viewed as "3"

parse_data=false (but with my changes, IContentTransformers are still
active):

--> I enter "0003", result is "0003" (as expected), but "3"
    is displayed (due to FormatContentTransformer)!

--> I don't think we want to automatically disable the
    FormatContentTransformer with parse_data=false, because it does
    things the user configured explicitly (like displaying
    Format=yyyy-MM-dd)

--> Shall I extract the parts of
    FormatContentTransformer.expandFormat(Object, NodeModel, String,
    boolean), that are not explicit (like formatting Format=Standard
    nodes) into another IContentTransformer that gets triggered
    with 'parse_data' (or modify FormatContentTransformer to do this
    conditionally)?

In any case, it's confusing that if you turn off 'parse_data', Freeplane
still messes with your numbers.

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/FormatContentTransformer-tp720p726.html
To start a new topic under Freeplane Developer, email [hidden email]
To unsubscribe from Freeplane Developer, click here.
NAML

Viele Grüße,
Volker
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

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

> Hi Felix,

hello Volker,

> parsing and formatting should be kept separate, so please don't introduce a
> formatter that depends on the parse flag. You turn off formatting with the
> Text format as in excel.

The problem is that this formatting is _not_ explicitly defined by the
user in case of parse_data=false and 0003.

> Nevertheless I'm a bit puzzled why 0003 gets formatted as 3. What happens
> there?

1. I had to change
org.freeplane.features.text.TextController.getNodeFormat(NodeModel)
to always return PatternFormat.STANDARD_FORMAT_PATTERN (and not
PatternFormat.IDENTITY_PATTERN depending on parse_data [1]),
because returning IDENTITY_PATTERN on parse_data=false would disable all
IContentTransformers (and thus defy the purpose of this ticket).
(I will soon push the branch so you can review).

2. => Previously, if parse_data==false, the FormatContentTransformer was
not active, and now it is. In line 39 of FormatContentTransformer [2],
the (node-) object is reformatted, which returns "3" for "0003".

3. What to do? As I said, I don't think it's good if such
transformations (even if just in the view, which users may not notice)
are done on parse_data=false.
--> My suggestion is not to do this if format == STANDARD_FORMAT_PATTERN,
i.e. sth like:
if (format.equals(PatternFormat.STANDARD_FORMAT_PATTERN))
{
  hasFormat = false;
}

[1] the parse_data check is (still) in:
MTextController.guessObject(Object, String)

[2] https://github.com/freeplane/freeplane/blob/f762aee4abe60885f5c3e166c7582f9238ec2433/freeplane/src/main/java/org/freeplane/features/text/FormatContentTransformer.java

Cheers and Best Regards,
Felix

> Regards, Volker
>
> Am 13. Juli 2015 21:42:31 MESZ, schrieb "Felix Natter [via Freeplane
> Developer]" <[hidden email]>:
>
>     "Volker Börchers [via Freeplane Developer]"
>     <[hidden email]> writes:
>    
>     > Hi Felix,
>    
>     hello Devs,
>    
>     > more users have been hit by the "Recognize input ...":
>     >
>     >
>     https://sourceforge.net/p/freeplane/discussion/758437/thread/7150c794/#1a36
>     >
>     > The affected part isn't the FormatContentTransformer but the
>     > LinkTransformer
>    
>     I think I've fixed the issue, but I ran a across one thing worth
>     discussing:
>    
>     parse_data (Recognize input of numbers and date-time) = true:
>    
>     --> I enter "0003", result is "3", viewed as "3"
>    
>     parse_data=false (but with my changes, IContentTransformers are still
>     active):
>    
>     --> I enter "0003", result is "0003" (as expected), but "3"
>     is displayed (due to FormatContentTransformer)!
>    
>     --> I don't think we want to automatically disable the
>     FormatContentTransformer with parse_data=false, because it does
>     things the user configured explicitly (like displaying
>     Format=yyyy-MM-dd)
>    
>     --> Shall I extract the parts of
>     FormatContentTransformer.expandFormat(Object, NodeModel, String,
>     boolean), that are not explicit (like formatting Format=Standard
>     nodes) into another IContentTransformer that gets triggered
>     with 'parse_data' (or modify FormatContentTransformer to do this
>     conditionally)?
>    
>     In any case, it's confusing that if you turn off 'parse_data',
>     Freeplane
>     still messes with your numbers.
>    
>     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/FormatContentTransformer-
>     tp720p726.html
>     To start a new topic under Freeplane Developer, email [hidden email]
>     To unsubscribe from Freeplane Developer, click here.
>     NAML
>
> Viele Grüße,
> Volker
>
> ---------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/FormatContentTransformer-tp720p727.
> html
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here.
> NAML
>

--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Felix Natter
Administrator
In reply to this post by Volker Börchers
hello Devs,

I have finally completed the "2195: Make data formatting, formula
processing and LaTeX rendering independently configurable" bug fix.

Does anybody want to review this? It's in the "contenttf2" branch:
  https://github.com/freeplane/freeplane/commits/contenttf2

Cheers and Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Dimitry Polivaev
Administrator
Hi Felix,

I think I would rather not like to review your changes because I am pretty out of context. But if
you want to explain what you did and walk me through we could try it.

Regards,
Dimitry

> hello Devs,
>
> I have finally completed the "2195: Make data formatting, formula
> processing and LaTeX rendering independently configurable" bug fix.
>
> Does anybody want to review this? It's in the "contenttf2" branch:
> https://github.com/freeplane/freeplane/commits/contenttf2
>
> Cheers and Best Regards,
> --
> Felix Natter

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FormatContentTransformer?

Felix Natter
Administrator
"Dimitry Polivaev [via Freeplane Developer]"
<[hidden email]> writes:

> Hi Felix,

hello Devs,

> I think I would rather not like to review your changes because I am pretty
> out of context. But if
> you want to explain what you did and walk me through we could try it.

Code Review done, 'contenttf2' merged.

Best Regards,
--
Felix Natter
Loading...