如何使用xwiki从html转换为markdown,
获取shouldRenderHtmlToMarkdown的“java.lang.NoSuchFieldError:fRecognizedFeatures”,尝试了不同格式的html。
public class HtmlRendererTest
{
private Converter converter;
private WikiPrinter printer;
@Test
public void testHtmlToMarkdown() throws ComponentLookupException, ConversionException, ParseException, ComponentRepositoryException
{
WikiPrinter printer = new DefaultWikiPrinter();
converter.convert(new StringReader("<h3 id=\"HHeader3\"><span>Header 3</span></h3>"), Syntax.XHTML_1_0, Syntax.MARKDOWN_1_1, printer);
System.out.println(printer.toString());
assertThat(printer.toString(), containsString("###"));
}
@Test
public void testMarkdownToHtml() throws ComponentLookupException, ConversionException, ParseException, ComponentRepositoryException
{
WikiPrinter printer = new DefaultWikiPrinter();
converter.convert(new StringReader("### Header 3"), Syntax.MARKDOWN_1_1, Syntax.ANNOTATED_XHTML_1_0, printer);
System.out.println(printer.toString());
assertThat(printer.toString(), containsString("</h3>"));
}
@Before
public void setUp() throws ComponentLookupException, ConversionException
{
EmbeddableComponentManager componentManager = new EmbeddableComponentManager();
componentManager.initialize(this.getClass().getClassLoader());
converter = componentManager.getInstance(Converter.class);
printer = new DefaultWikiPrinter();
}
}
答案 0 :(得分:0)
XWiki现在只为Markdown提供一个解析器,所以除非你自己写了一个降价序列化器,否则应该无法真正运行.RardHtmlToMarkdown。
现在它不是&#34; java.lang.NoSuchFieldError:fRecognizedFeatures&#34;是的,通常它意味着你有一些不兼容的罐子(一个类期望找到一个字段,但目标类不在预期的版本中)。完整的堆栈跟踪可能有助于了解哪些。