This page is no longer maintained — Please continue to the home page at www.scala-lang.org

<br/> in xhtml

3 replies
Robert Nikander
Joined: 2009-08-18,
User offline. Last seen 42 years 45 weeks ago.
Hi, I'm trying to generate HTML output in a servlet using XML literals. But
doesn't work the way I'd like it to... scala> val html = some text
some more html: scala.xml.Elem = some text
some more scala> html.toString res0: String = some text
some more That renders as two line breaks in Firefox and Safari. I need it to stay as
. Anyone know how to do that? thanks, Rob
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: <br/> in xhtml
On Thu, Sep 03, 2009 at 02:02:35PM -0400, Robert Nikander wrote: > scala> val html = some text
some more > html: scala.xml.Elem = some text
some more > > scala> html.toString > res0: String = some text
some more scala> val html = some text
some more html: scala.xml.Elem = some text
some more scala> xml.Xhtml.toXhtml(html) res0: String = some text
some more
Dustin Whitney
Joined: 2009-02-08,
User offline. Last seen 2 years 32 weeks ago.
XHTML
Anybody know if there is a way to keep the scala libs from escaping the quotes in certain sections of my html where I'd like them?

For example, even when I Xhtml.toXhtml() my Nodes they go from:

<html>
<head>
<script type="text/javascript">
alert("Foo!");
<script>
</head>
<body>
</body>
</html>

to (notice the ")

<html>
<head>
<script type="text/javascript">
alert("Foo!&quot);
<script>
</head>
<body>
</body>
</html>

Lift must deal with this problem. Anybody know offhand how they do it? I've searched through the Lift source, but I can't really locate it.

Thanks,
Dustin
David Pollak
Joined: 2008-12-16,
User offline. Last seen 42 years 45 weeks ago.
Re: XHTML


On Sat, Oct 24, 2009 at 9:04 PM, <dustin [dot] whitney [at] gmail [dot] com> wrote:
Anybody know if there is a way to keep the scala libs from escaping the quotes in certain sections of my html where I'd like them?

For example, even when I Xhtml.toXhtml() my Nodes they go from:

<html>
<head>
<script type="text/javascript">
alert("Foo!");
<script>
</head>
<body>
</body>
</html>

to (notice the ")

<html>
<head>
<script type="text/javascript">
alert("Foo!&quot);
<script>
</head>
<body>
</body>
</html>

Lift must deal with this problem. Anybody know offhand how they do it? I've searched through the Lift source, but I can't really locate it.

We wrote parallel methods that convert XML to String and deal correctly with the CDATA type.  You can see more in the AltXML object in Lift's PCDataMarkupParser.scala file: http://github.com/dpp/liftweb/blob/master/lift-base/lift-util/src/main/scala/net/liftweb/util/PCDataMarkupParser.scala  

Thanks,
Dustin



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland