textileplugin.java
来自「这个weblogging 设计得比较精巧」· Java 代码 · 共 60 行
JAVA
60 行
package org.roller.presentation.velocity.plugins.textile;import org.apache.commons.lang.StringEscapeUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.velocity.context.Context;import org.roller.pojos.WeblogEntryData;import org.roller.presentation.RollerRequest;import org.roller.presentation.velocity.PagePlugin;/** * @author David M Johnson */public class TextilePlugin implements PagePlugin{ public String name = "Textile Formatter"; public String description = "Allows use of Textile formatting to easily " + "generate HTML. See the <a href='http://textism.com/tools/textile' target='textile'>Textile</a> site."; public String toString() { return name; } private net.sf.textile4j.Textile mTextile = new net.sf.textile4j.Textile(); private static Log mLogger = LogFactory.getFactory().getInstance(TextilePlugin.class); public TextilePlugin() { mLogger.debug("Textile Plugin instantiated."); } /** * Put plugin into the page context so templates may access it. */ public void init(RollerRequest rreq, Context ctx) { ctx.put("textileRenderer",this); } /** * Convert an input string that contains text that uses the Textile * syntax to an output string in HTML format. * @param src Input string that uses Textile syntax * @return Output string in HTML format. */ public String render( String src ) { return mTextile.process(src); } public String render( WeblogEntryData entry, boolean skipFlag ) { return render( entry.getText() ); } public String getName() { return name; } public String getDescription() { return StringEscapeUtils.escapeJavaScript(description); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?