MathGroup Archive 2009

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

Search the Archive

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

On Fri, Oct 2, 2009 at 8:23 AM, David Reiss <dbreiss at> wrote:
On Sep 30, 5:02 am, David Reiss <dbre... at> wrote:
>> I want to export a notebook to html with a particular behavior of a
>> particular cell.
>> The cell in question should have its contents exported so that those
>> contents appear in the html of the resulting file exactly as written
>> in the cell. ...In essence I want to be able to insert raw html into the
>> final html file.

Simply create a new style definition with the following option:
ConversionRules -> {"HTML" -> Identity}.

The complete way to do this would be to set up a new style sheet
that extends whatever style sheet you want and includes the extra
style.  Here's a snippet of code that illustrates the idea, though:

HTMLVerbatimDef = Notebook[{Cell[StyleData["HTMLVerbatim"],
  ConversionRules -> {"HTML" -> Identity}]}];
nb = CreateDocument[{TextCell[
  "<a href=\"blah.html\">blah</a>\"", "HTMLVerbatim"]},
   StyleDefinitions -> HTMLVerbatimDef];

That code should generate a new notebook with a single cell
containing some HTML.  The cell is in the newly defined
HTMLVerbatim style.  You can view the HTML that is generated
as follows:

ExportString[nb, "HTML"]

You should see that the HTML has been copied verbatim:
<a href="blah.html">blah</a>"

By contrast, a simple Text cell in a Default style document
would yield:
&lt;a href=&quot;blah.html&quot;&gt;blah&lt;/a&gt;&quot;

Hope that helps,
Mark McClure

  • Prev by Date: Re: "Freezing" an Output cell?
  • Next by Date: Re: "Freezing" an Output cell?
  • Previous by thread: Re: Making raw HTML appear in a notebook exported to HTML
  • Next by thread: Re: Re: Making raw HTML appear in a notebook exported to