Skip to content

Instantly share code, notes, and snippets.

@ryoco
Created November 15, 2012 12:54
Show Gist options
  • Save ryoco/4078505 to your computer and use it in GitHub Desktop.
Save ryoco/4078505 to your computer and use it in GitHub Desktop.
Unparsed test
import scala.xml.parsing._
import scala.xml._
import scala.io._
val src = Source.fromString("<html><head /><body><script>var foo = \"fooooooo\";</script></body></html>")
val cpa = ConstructingParser.fromSource(src, false);
val doc = cpa.document();
val ppr = new scala.xml.PrettyPrinter(80,2);
val ele = doc.docElem;
val out = ppr.format(ele);
====result====
out: String =
<html>
<head></head>
<body>
<script>var foo = &quot;fooooooo&quot;;</script>
</body>
</html>
val src = Source.fromString("<html><head /><body><script>var foo = \"fooooooo\";</script></body></html>")
val str = src.mkString
val unparsed = Unparsed(str).toList.head
val ppr = new scala.xml.PrettyPrinter(80,2);
val out = ppr.format(unparsed);
====result====
out: String = <html><head /><body><script>var foo = "fooooooo";</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment