public abstract class MarkupLanguage
extends java.lang.Object
implements java.lang.Cloneable
Block
,
PatternBasedElementProcessor
and PatternBasedElement
concepts. All markup languages supported by
WikiText extend this class.
The MarkupLanguage class provides basic functionality for determining which blocks process which markup content in a particular document. In general multi-line documents are split into consecutive regions called blocks, and each line in a block is processed with spanning sections called phrase modifiers, and tokens within a span are replaced with their respective replacement tokens. These rules apply to most lightweight markup languages, however subclasses may override this default functionality if required. For example, by default phrase modifiers are non-overlapping and non-nested, however if required a subclass could permit such nesting.
Generally markup language classes are not accessed directly by client code, instead client code should configure and
call MarkupParser
, accessing the markup language by name using the ServiceLocator
.
Constructor and Description |
---|
MarkupLanguage() |
Modifier and Type | Method and Description |
---|---|
MarkupLanguage |
clone() |
void |
configure(MarkupLanguageConfiguration configuration)
configure the markup language with a configuration that may alter the language syntax and capabilities.
|
DocumentBuilder |
createDocumentBuilder(java.io.Writer out)
Creates a
DocumentBuilder suitable for emitting content in this markup language. |
DocumentBuilder |
createDocumentBuilder(java.io.Writer out,
boolean formatting)
Creates a
DocumentBuilder suitable for emitting content in this markup language. |
java.lang.String |
getExtendsLanguage()
The name of the markup language that is extended by this one
|
java.util.Set<java.lang.String> |
getFileExtensions()
Provides the normal file extensions of this markup language.
|
IdGenerationStrategy |
getIdGenerationStrategy()
get the id strategy employed by this markup language.
|
java.lang.String |
getName()
The name of the markup language, typically the same as the name of the markup language supported by this markup
language.
|
abstract void |
processContent(MarkupParser parser,
java.lang.String markupContent,
boolean asDocument) |
void |
setExtendsLanguage(java.lang.String extendsLanguage)
The name of the markup language that is extended by this one
|
void |
setFileExtensions(java.util.Set<java.lang.String> fileExtensions)
Sets the normal file extensions of this markup language.
|
void |
setName(java.lang.String name)
The name of the markup language, typically the same as the name of the markup language supported by this markup
language.
|
public MarkupLanguage clone()
clone
in class java.lang.Object
public IdGenerationStrategy getIdGenerationStrategy()
public void configure(MarkupLanguageConfiguration configuration) throws java.lang.UnsupportedOperationException
configuration
- the configuration to usejava.lang.UnsupportedOperationException
- markup languages that do not support configuration must throw this exception.public java.lang.String getName()
public void setName(java.lang.String name)
name
- the namepublic java.util.Set<java.lang.String> getFileExtensions()
getName()
.public void setFileExtensions(java.util.Set<java.lang.String> fileExtensions)
getFileExtensions()
public java.lang.String getExtendsLanguage()
public void setExtendsLanguage(java.lang.String extendsLanguage)
extendsLanguage
- the name, or null if this markup language does not extend another.public abstract void processContent(MarkupParser parser, java.lang.String markupContent, boolean asDocument)
public DocumentBuilder createDocumentBuilder(java.io.Writer out)
DocumentBuilder
suitable for emitting content in this markup language. Equivalent to
createDocumentBuilder(out,false)
.out
- the target to which content is writtenjava.lang.UnsupportedOperationException
- if the markup language has no corresponding document buildercreateDocumentBuilder(Writer, boolean)
public DocumentBuilder createDocumentBuilder(java.io.Writer out, boolean formatting)
DocumentBuilder
suitable for emitting content in this markup language.out
- the target to which content is writtenformatting
- indicates if the builder should format the output using pretty-print rules. If not supported by the
document builder this parameter is ignored.java.lang.UnsupportedOperationException
- if the markup language has no corresponding document builderCopyright © 2007, 2013 David Green and others.
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