All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.markup.MarkupFormatter Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 *
 * Copyright (c) 2010, CloudBees, Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:        
 *
 *******************************************************************************/ 

/*
 * The MIT License
 *
 * Copyright (c) 2010, CloudBees, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package hudson.markup;

import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Hudson;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

/**
 * 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. * *

Views

*

* This extension point must have a valid config.jelly that feeds the constructor. * * TODO: allow {@link MarkupFormatter} to control the UI that the user uses to edit. * * @author Kohsuke Kawaguchi * @since 1.391 * @see Hudson#getMarkupFormatter() */ public abstract class MarkupFormatter extends AbstractDescribableImpl implements ExtensionPoint { /** * 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. * * @param output * Formatted HTML should be sent to this output. */ public abstract void translate(String markup, Writer output) throws IOException; public final String translate(String markup) throws IOException { StringWriter w = new StringWriter(); translate(markup,w); return w.toString(); } @Override public MarkupFormatterDescriptor getDescriptor() { return (MarkupFormatterDescriptor)super.getDescriptor(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy