Bug 2660 - Mathematica notebook
Summary: Mathematica notebook
Status: RESOLVED FIXED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high enhancement
Assignee: Jonathan Blandford
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-07 06:41 UTC by Sebastian Kapfer
Modified: 2005-04-15 15:13 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Mathematica notebook (458 bytes, text/plain)
2005-03-07 06:42 UTC, Sebastian Kapfer
Details
Second try at a Mathematica magic (713 bytes, text/plain)
2005-04-16 07:55 UTC, Sebastian Kapfer
Details

Description Sebastian Kapfer 2005-03-07 06:41:11 UTC
Added MIME type
Comment 1 Sebastian Kapfer 2005-03-07 06:42:48 UTC
Created attachment 2029 [details]
Mathematica notebook
Comment 2 Christophe Fergeau 2005-04-16 05:41:19 UTC
The patch looks good, but I don't really like the magic patterns, I'm afraid of
false postives, isn't it possible to get more specific patterns ?
Comment 3 Sebastian Kapfer 2005-04-16 07:22:58 UTC
I don't really think these magics would produce many false positives.  If I
understand it right, both magics have to match, right?

I sampled few notebooks I could find and they start like this:

for version 3.0:
(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the notebook 
starts with the line of stars above.

for Version 4.0:
(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. The data for the notebook 
starts with the line containing stars above.

I don't know what this is:
(************** Content-type: application/mathematica **************

                    Mathematica-Compatible Notebook

This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.

Version 5.0:
(************** Content-type: application/mathematica **************
                     CreatedBy='Mathematica 5.0'

                    Mathematica-Compatible Notebook

This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.



So maybe we could make the star pattern a bit longer and change Mathematica to
"Mathematica-Compatible Notebook":

    <magic priority="50">
      <match value="(************" type="string" offset="0" />
      <match value="Mathematica-Compatible Notebook" type="string" offset="0:256" />
    </magic>

Is that better?
Comment 4 Christophe Fergeau 2005-04-16 07:44:15 UTC
As it is written currently, if either of those patterns match then it will be
considered as a mathematica notebook.
If you want to match both patterns before it's detected as a mathematica
notebook, you need to do:
 <magic priority="50">
      <match value="(*******" type="string" offset="0">
        <match value="Mathematica" type="string" offset="0:256" />
      </match>
 </magic>

(this is done for eps files for example)
And it's ok with me with the Mathematica-Compatible Notebook string, this one
alone is probably enough I guess, but matching for the * can't hurt
I'll commit that, thanks
Comment 5 Christophe Fergeau 2005-04-16 07:53:34 UTC
Ok, committed to CVS.
Comment 6 Sebastian Kapfer 2005-04-16 07:55:16 UTC
Created attachment 2436 [details]
Second try at a Mathematica magic

Stupid me... one matching magic suffices :-(

The attached file should produce less false positives. It can also detect
Mathematica 2.0 notebooks now.
Comment 7 Sebastian Kapfer 2005-04-16 07:57:33 UTC
Oh, thanks for the explanation.

I think the version I posted about a minute ago is even better.
Comment 8 Christophe Fergeau 2005-04-16 08:13:42 UTC
Committed your magic to cvs, thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.