MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Making raw HTML appear in a notebook exported to

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103759] Re: [mg103744] Re: Making raw HTML appear in a notebook exported to
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Mon, 5 Oct 2009 07:38:03 -0400 (EDT)
  • References: <h9v6qo$9b1$1@smc.vnet.net> <200910021223.IAA13461@smc.vnet.net>

Hi Albert,

I totally agree with your point - I too am actually not satisfied with this
solution, and mentioned in my post that it does not scale with the
complexity of the problem, just as you say. In my case, simple templating
worked well enough, also I wanted to be able to  process pages quickly since
I have a lot, and I did not have time to produce and test a more
sophisticated solution. But I do plan to change this by doing something
along the lines of your suggestion.

The possibility to use Mathematica XML capabilities for this problem did not
occur to me.  I am not sure that XML parser will be enough if we generate
html and not Xhtml (especially if I want to use third-party html templates
which are not xhtml), but I can of course stick to Xhtml then. I wrote my
own html parser in Mathematica, which also converts html to a symbolic
Mathematica tree and  back - it seems to work well and  is reasonably fast.
So either I use it or the XML parser - thanks for the suggestion!


Regards,
Leonid



On Sun, Oct 4, 2009 at 2:37 AM, Albert Retey <awnl at gmx-topmail.de> wrote:

> Hi David and Leonid,
>
> > Yes, the technique of using templates and then doing string
> > replacements is exactly what I use in the Blogging code for
> > http://scientificarts.com.worklife .  And that Is what I was working
> > on extending to solve my problem.
> >
> > Mark McClure in his answer gives the really simple way of doing this
> > via ConversionRules that I was hoping for.
> >
> > Thanks for your help!
>
> I was just wondering whether doing string replacements is really the
> best way to handle these kind of tasks. After all what mathematica
> exports seems to be valid XHTML (and is marked as that) and thus can be
> imported as XML, with e.g. Import["file.html","XML"], which gives a
> 'symbolic XML expression' which I think would be much more convenient
> and robust to be manipulated within Mathematica than just plain strings.
> Have you tried that? It might turn out to be too slow or need to much
> memory, but I would give it a try if I would try to do what you are
> after. I have experience in manipulating html with string replacements
> in other languages and have seen some of the horror that can turn into
> when things become more and more complicated (and you need to accept
> non-xhtml files with missing end tags and all the quirks that you find
> in these).
>
> > On Fri, Oct 2, 2009 at 10:00 AM, Leonid Shifrin <lshifr at gmail.com>
> wrote:
> >> Hi David,
> >>
> >> There is a possibility which I used in publishing my book online. The
> reason
> >> I did not answer your initial post is that I was expecting others to
> come up
> >> with a better solution than mine. What I did was a kind of a rudimentary
> >> "template" engine. If you have a look at my site
> >> <www.mathprogramming-intro.org>, you will  notice that the pages
> produced by
> >> Mathematica are embedded in one or another template. Those templates I
> >> produced separately as html pages, and then wrote Mathematica scripts
> which
> >> took the pages generated by Export, and used some simple string
> recognition
> >> to parse them and find how to do the embedding. It worked pretty well
> forme
> >> given that I have more than 500 pages and the embedding was done
> correctly
> >> for all of them. Once I realized that with this procedure I am no longer
> >> confined by the way Export does things, it was a big relief. The main
> >> limitations  of course are that this procedure does not scale as the
> >> complexity of the site grows, and the content is static. I have it in my
> >> plans to convert this into some simple html-generating framework for
> >> Mathematica, but did not find time for it so far.
> >>
> >> I think, similar approach could work for you. You could simply use some
> >> descriptors (string tokens, say) for the cell of interest so that the
> script
> >> running after Export is done, will replace the generated html with a
> >> different one, for this particular cell. This can be achieved rather
> easily,
> >> in many cases much easier than forcing Export into submission.
> >>
> >> Another possibility (I never tried it so this is just a blind guess) is
> to
> >> try webMathematica -  may be it already implements all the functionality
> you
> >> need?
> >>
> >> Regards,
> >> Leonid


  • Prev by Date: Re: Help Creating 3D List Line Plot
  • Next by Date: Re: Paper heading: does not work?
  • Previous by thread: Re: Making raw HTML appear in a notebook exported to
  • Next by thread: Re: Making raw HTML appear in a notebook exported to HTML