If you have a customized xhtml variant, like evernote ENML format and you want to render it with Flying Saucer R8 you must first make sure that the extra element (in ENML case, en-media) is defined as a block-level element. To do that you create your own NamespaceHandler and you make sure that you return "display: block;" for en-media in the implementation of NamespaceHandler.getNonCssStyling. (See ENMLNamespaceHandler.java below)
.... XHTMLPanel panel = new XHTMLPanel(); panel.setDocument(doc,"",new ENMLNamespaceHandler(new XhtmlNamespaceHandler())); .... class ENMLNamespaceHandler implements NamespaceHandler { .... public String getNonCssStyling(Element e) { String toReturn = delegate.getNonCssStyling(e); if ("en-media".equalsIgnoreCase(e.getNodeName())) { toReturn = "display: block;"; } return toReturn; } .... } With that you ensure that xhtmlrenderer will call ReplacedElementFactory.createReplacedElement for en-media. Now you must supply a ReplacedElementFactory that it’s able to process en-media. Usually the implementation of the createReplacedElement() involves creating a Swing JComponent, wrapping it in a SwingReplacedElement and adding it to the LayoutContext.getCanvas().
...