[[tidyMarkup-dataformat]]
= TidyMarkup DataFormat
:docTitle: TidyMarkup
:artifactId: camel-tagsoup
:description: Parse (potentially invalid) HTML into valid HTML or DOM.
:since: 2.0
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/dataformats/tidyMarkup.adoc[opts=optional]

*Since Camel {since}*

TidyMarkup is a Data Format that uses the
http://www.ccil.org/~cowan/XML/tagsoup/[TagSoup] to tidy up HTML. It can
be used to parse ugly HTML and return it as pretty wellformed HTML.

*Camel eats our own -dog food- soap*

We had some issues in our pdf Manual where we had some
strange symbols. So http://janstey.blogspot.com/[Jonathan] used this
data format to tidy up the wiki html pages that are used as base for
rendering the pdf manuals. And then the mysterious symbols vanished.

TidyMarkup only supports the *unmarshal* operation
as we really don't want to turn well formed HTML into ugly HTML.

== TidyMarkup Options



// dataformat options: START
The TidyMarkup dataformat supports 2 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| dataObjectType | org.w3c.dom.Node | String | What data type to unmarshal as, can either be org.w3c.dom.Node or java.lang.String. Is by default org.w3c.dom.Node
| omitXmlDeclaration | false | Boolean | When returning a String, do we omit the XML declaration in the top.
|===
// dataformat options: END




== Java DSL Example

An example where the consumer provides some HTML

[source,java]
---------------------------------------------------------------------------
from("file://site/inbox").unmarshal().tidyMarkup().to("file://site/blogs");
---------------------------------------------------------------------------

== Spring XML Example

The following example shows how to use TidyMarkup
to unmarshal using Spring

[source,java]
-----------------------------------------------------------------------
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="file://site/inbox"/>
    <unmarshal>
      <tidyMarkup/>
    </unmarshal>
    <to uri="file://site/blogs"/>
  </route>
</camelContext>
-----------------------------------------------------------------------

== Dependencies

To use TidyMarkup in your camel routes you need to add the a dependency
on *camel-tagsoup* which implements this data format.

If you use maven you could just add the following to your pom.xml,
substituting the version number for the latest & greatest release (see
the download page for the latest versions).

[source,java]
----------------------------------------
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-tagsoup</artifactId>
  <version>x.x.x</version>
</dependency>
----------------------------------------

include::camel-spring-boot::page$tagsoup-starter.adoc[]
