org.xwiki.rendering.internal.renderer.plain.PlainTextRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xwiki-rendering-syntax-plain Show documentation
Show all versions of xwiki-rendering-syntax-plain Show documentation
XWiki Rendering - Syntax - Plain
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.rendering.internal.renderer.plain;
import javax.inject.Inject;
import javax.inject.Named;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.InstantiationStrategy;
import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
import org.xwiki.component.phase.Initializable;
import org.xwiki.component.phase.InitializationException;
import org.xwiki.rendering.listener.chaining.BlockStateChainingListener;
import org.xwiki.rendering.listener.chaining.EmptyBlockChainingListener;
import org.xwiki.rendering.listener.chaining.ListenerChain;
import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
import org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator;
/**
* Print only plain text information. For example it remove anything which need a specific syntax a simple plain text
* editor can't support like the style, link, image, etc. This renderer is mainly used to generate a simple as possible
* label like in a TOC.
*
* @version $Id: 99c881c9d1321f1cc1e720628b5d08a4e6cf93cc $
* @since 2.0M3
*/
@Component
@Named("plain/1.0")
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
public class PlainTextRenderer extends AbstractChainingPrintRenderer implements Initializable
{
/**
* Used to generate link label when not explicitely provided.
*/
@Inject
private LinkLabelGenerator linkLabelGenerator;
@Override
public void initialize() throws InitializationException
{
ListenerChain chain = new ListenerChain();
setListenerChain(chain);
// Construct the listener chain in the right order. Listeners early in the chain are called before listeners
// placed later in the chain.
chain.addListener(this);
chain.addListener(new BlockStateChainingListener(chain));
chain.addListener(new EmptyBlockChainingListener(chain));
chain.addListener(new PlainTextChainingRenderer(this.linkLabelGenerator, chain));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy