hudson.markup
Class MarkupFormatter

java.lang.Object
  extended by hudson.model.AbstractDescribableImpl<MarkupFormatter>
      extended by hudson.markup.MarkupFormatter
All Implemented Interfaces:
ExtensionPoint, Describable<MarkupFormatter>
Direct Known Subclasses:
RawHtmlMarkupFormatter

public abstract class MarkupFormatter
extends AbstractDescribableImpl<MarkupFormatter>
implements ExtensionPoint

Generalization of a function that takes text with some markup and converts that to HTML. Such markup is often associated with Wiki.

Use of markup, as opposed to using raw HTML, ensures certain degree of security.

This is an extension point in Hudson, allowing plugins to implement different markup formatters.

Implement the following methods to enable and control CodeMirror syntax highlighting public String getCodeMirrorMode() // return null to disable CodeMirror dynamically public String getCodeMirrorConfig()

Views

This extension point must have a valid config.jelly that feeds the constructor. TODO: allow MarkupFormatter to control the UI that the user uses to edit.

Since:
1.391
Author:
Kohsuke Kawaguchi
See Also:
Jenkins.getMarkupFormatter()

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
MarkupFormatter()
           
 
Method Summary
 org.kohsuke.stapler.HttpResponse doPreviewDescription(String text)
          Generate HTML for preview, using markup formatter.
 MarkupFormatterDescriptor getDescriptor()
          Gets the descriptor for this instance.
 String getHelpUrl()
          Gets the URL of the help file.
 String translate(String markup)
           
abstract  void translate(String markup, Writer output)
          Given the text, converts that to HTML according to whatever markup rules implicit in the implementation class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkupFormatter

public MarkupFormatter()
Method Detail

translate

public abstract void translate(String markup,
                               Writer output)
                        throws IOException
Given the text, converts that to HTML according to whatever markup rules implicit in the implementation class.

Multiple threads can call this method concurrently with different inputs.

Parameters:
output - Formatted HTML should be sent to this output.
Throws:
IOException

translate

public final String translate(String markup)
                       throws IOException
Throws:
IOException

getHelpUrl

public String getHelpUrl()
Gets the URL of the help file. This help will shown next to the text area of the description, and is ideal of describing what the allowed syntax is. By default, we look for colocated help-syntax.html.

Returns:
null If there's no help file.
Since:
1.398

getDescriptor

public MarkupFormatterDescriptor getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<MarkupFormatter>
Overrides:
getDescriptor in class AbstractDescribableImpl<MarkupFormatter>

doPreviewDescription

public org.kohsuke.stapler.HttpResponse doPreviewDescription(@QueryParameter
                                                             String text)
                                                      throws IOException
Generate HTML for preview, using markup formatter. Can be called from other views.

Throws:
IOException


Copyright © 2004-2013. All Rights Reserved.