user2633351
user2633351

Reputation: 173

html-conduit (HTML -> XHTML in Haskell)

I am a beginner to Haskell. I have some code that uses xml-conduit, and it's all working well, I am able to transform it as I want.

let src_file = "blah.xhtml"
Document prologue root epilogue <- readFile def{psDecodeEntities=decodeHtmlEntities} src_file

let root' = transform root

-- And now we write out. Let's indent our output
writeFile def
    { rsPretty = True
    } "output.xhtml" $ Document prologue root' epilogue

The problem I have is that my input comes from html (from the web). I want to feed this into my function. Currently to do this, I have to run the commandline utility 'tidy' to normalise it to XHTML:

tidy -output blah.xhtml -asxhtml blah.html

This is working but is not obviously not ideal. I don't want to write a commandline wrapper around 'tidy' and I am sure that this must have been solved already! I have found the html-conduit package, but couldn't work out how to connect one to the other. If someone could shed some light about how to go about this, or another library that would do what I want, I would be grateful. I tried reading the documentation for html-conduit but couldn't work out how the two libraries interoperate.

Upvotes: 0

Views: 176

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31315

You should be able to use the readFile function from html-conduit. What problems have you run into when trying to integrate the two libraries?

Upvotes: 1

Related Questions