Package org.apache.wiki.htmltowiki

# Class HtmlStringToWikiTranslator

java.lang.Object
org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator

public class HtmlStringToWikiTranslator extends Object
Converting Html to Wiki Markup with NekoHtml for converting html to xhtml and Xhtml2WikiTranslator for converting xhtml to Wiki Markup.

## Constructor Summary

Constructors
Constructor
Description
`HtmlStringToWikiTranslator(org.apache.wiki.api.core.Engine e)`
Create a new translator.

## Method Summary

Modifier and Type
Method
Description
`static String`
`element2String(org.jdom2.Element element)`
A static helper method to create HTML from an Element.
`String`
`translate(String html)`
Translates text from HTML into WikiMarkup without a WikiContext (meaning some things perhaps cannot be translated).
`String`
`translate(String html, org.apache.wiki.api.core.Context wikiContext)`
Translates text from HTML into WikiMarkup with a WikiContext.
`String`
`translate(String html, XHtmlToWikiConfig config)`
Translates text from HTML into WikiMarkup using a specified configuration.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### HtmlStringToWikiTranslator

public HtmlStringToWikiTranslator(org.apache.wiki.api.core.Engine e)
Create a new translator.

## Method Details

### translate

public String translate(String html) throws org.jdom2.JDOMException, IOException, ReflectiveOperationException
Translates text from HTML into WikiMarkup without a WikiContext (meaning some things perhaps cannot be translated). Uses the default configuration.

Parameters:
  `html` - HTML text to translate
Returns:
  WikiMarkup
Throws:
  `org.jdom2.JDOMException` - If parsing fails
  `IOException` - For other kinds of errors.
  `ReflectiveOperationException`

### translate

public String translate(String html, org.apache.wiki.api.core.Context wikiContext) throws org.jdom2.JDOMException, IOException, ReflectiveOperationException
Translates text from HTML into WikiMarkup with a WikiContext. The translation accuracy is better. Uses the default configuration.

Parameters:
  `html` - HTML text to translate
  `wikiContext` - The WikiContext to use.
Returns:
  WikiMarkup
Throws:
  `org.jdom2.JDOMException` - If parsing fails
  `IOException` - For other kinds of errors.
  `ReflectiveOperationException`

### translate

public String translate(String html, XHtmlToWikiConfig config) throws org.jdom2.JDOMException, IOException, ReflectiveOperationException
Translates text from HTML into WikiMarkup using a specified configuration.

Parameters:
  `html` - HTML text to translate
  `config` - The configuration to use.
Returns:
  WikiMarkup
Throws:
  `org.jdom2.JDOMException` - If parsing fails
  `IOException` - For other kinds of errors.
  `ReflectiveOperationException`

### element2String

public static String element2String(org.jdom2.Element element)
A static helper method to create HTML from an Element.

Parameters:
  `element` - The element to get HTML from.
Returns:
  HTML