javamylyn-wikitext

create my own multily block in mylyn wiki text


I am looking for an example how to extend the mylyn (standalone) wiki parser. I want to make my own multi line block i.e.

%%%
my super text processed by my code
%%%

I have tried to figure it out by looking at the mylyn source code and by searching the web. I really have no idea what to do. And the documentation is also not very helpful. Maybe another library is better for my need anyway? I just need a wiki-text to html parser which I can extend to embedd my own stuff.


Solution

  • I did not get mylyin to work with custom extensions. Anyone else interested in such a fature I switched to bliki, there are some example how to extend the parser: bliki.

    i.e.:

    public class SampleTag extends NowikiTag implements INoBodyParsingTag {
        private final static String HEADER = "<div id=\"sample\">\n"
                + "<a href=\"#\" id=\"show\" onclick=\"$(\'evalframe\').show();$(\'hide\').show();$(\'show\').hide();\" />Show Sample</a> \n"
                + "<a href=\"#\" style=\"display: none;\" id=\"hide\" onclick=\"$(\'evalframe\').hide();;$(\'hide\').hide();$(\'show\').show();\" />Hide Sample</a><br />\n"
                + "<iframe src=\"";
    
        private final static String FOOTER = "\" style=\"display: none;\" id=\"evalframe\" width=\"480\" height=\"160\" \n"
                + "        scrolling=\"yes\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"1\">\n"
                + "  <p>You browser doesn\'t support IFRAMEs</p>\n" + "</iframe>\n" + "</div>";
    
        public SampleTag() {
            super("sample");
        }
    
        @Override
        public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
    
            TagNode node = this;
            Map<String, String> tagAtttributes = node.getAttributes();
    
            StringBuilder evalUrl = new StringBuilder(512);
            // sample input fields/textareas
            Utils.appendAmpersandEscapedAttribute(evalUrl, "ci", tagAtttributes);
            // sample actions
            Utils.appendAmpersandEscapedAttribute(evalUrl, "ca", tagAtttributes);
            buf.append(HEADER);
            // URL points to http://matheclipse.org/eval.jsp
            buf.append("../eval.jsp?");
            buf.append(evalUrl);
            // renderHTMLWithoutTag(converter, buf, model);
            buf.append(FOOTER);
        }
    
        @Override
        public boolean isReduceTokenStack() {
            return true;
        }
    }