RewriteRules

case class RewriteRules(spanRules: Seq[RewriteRule[Span]], blockRules: Seq[RewriteRule[Block]], templateRules: Seq[RewriteRule[TemplateSpan]])

A set of rewrite rules describing a set of modifications to be applied to an AST of a document.

For reasons of type-safety the major element type blocks and spans (in markup documents) and template spans (in template documents) have their separate set of rules, as an element in a block position for example can usually only be replaced by another block and not by any other element type.

Companion:
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

Combines the rules defined in this instance with the rules defined in the specified other instance. If a rule in this instance matches the same instance as another rule in the other instance, the rule in this instance will be applied first, before its result gets passed to the other function.

Combines the rules defined in this instance with the rules defined in the specified other instance. If a rule in this instance matches the same instance as another rule in the other instance, the rule in this instance will be applied first, before its result gets passed to the other function.

def rewriteBlock(block: Block): Block

Rewrites the specified block based on the set of rules in this instance.

Rewrites the specified block based on the set of rules in this instance.

If the rule is not defined for the block or the rule returns a Retain action as a result the old block will be returned unchanged.

If it returns Replace with a new block that block will be returned. If it returns Remove then an empty block container will be returned.

The rewriting is performed bottom-up (depth-first), including any children (blocks and spans) of the specified block, therefore an element passed to the rule only contains children which have already been processed.

def rewriteBlocks(blocks: Seq[Block]): Seq[Block]

Rewrites the specified sequence of blocks based on the set of rules in this instance.

Rewrites the specified sequence of blocks based on the set of rules in this instance.

If the rule is not defined for a specific block or the rule returns a Retain action as a result the old block remains in the tree unchanged.

If it returns Remove then the block gets removed from the ast, if it returns Replace with a new block it will replace the old one.

The size of the returned Seq is always between 0 and the number of blocks passed to this function.

The rewriting is performed bottom-up (depth-first), therefore any element passed to the rule only contains children which have already been processed. If the blocks contain span elements, the span rules defined in this instance will also be applied recursively.

Rewrites the specified element based on the set of rules in this instance.

Rewrites the specified element based on the set of rules in this instance.

If the rule is not defined for the element or the rule returns a Retain action as a result the old element will be returned unchanged.

If it returns Replace with a new element that element will be returned. If it returns Remove then an empty element container will be returned.

If the specified element type does not support rewriting, it is returned unchanged.

The rewriting is performed bottom-up (depth-first), including any children of the specified element, therefore an element passed to the rule only contains children which have already been processed.

def rewriteSpan(span: Span): Span

Rewrites the specified span based on the set of rules in this instance.

Rewrites the specified span based on the set of rules in this instance.

If the rule is not defined for the span or the rule returns a Retain action as a result the old span will be returned unchanged.

If it returns Replace with a new span that span will be returned. If it returns Remove then an empty span container will be returned.

The rewriting is performed bottom-up (depth-first), including any children of the specified span, therefore an element passed to the rule only contains children which have already been processed.

def rewriteSpans(spans: Seq[Span]): Seq[Span]

Rewrites the specified sequence of spans based on the set of rules in this instance.

Rewrites the specified sequence of spans based on the set of rules in this instance.

If the rule is not defined for a specific span or the rule returns a Retain action as a result the old span remains in the tree unchanged.

If it returns Remove then the span gets removed from the ast, if it returns Replace with a new span it will replace the old one.

The size of the returned Seq is always between 0 and the number of spans passed to this function.

The rewriting is performed bottom-up (depth-first), therefore any element passed to the rule only contains children which have already been processed.

Rewrites the specified template span based on the set of rules in this instance.

Rewrites the specified template span based on the set of rules in this instance.

If the rule is not defined for the span or the rule returns a Retain action as a result the old span will be returned unchanged.

If it returns Replace with a new span that span will be returned. If it returns Remove then an empty template span container will be returned.

The rewriting is performed bottom-up (depth-first), including any children of the specified template span, therefore an element passed to the rule only contains children which have already been processed.

Rewrites the specified sequence of template spans based on the set of rules in this instance.

Rewrites the specified sequence of template spans based on the set of rules in this instance.

If the rule is not defined for a specific span or the rule returns a Retain action as a result the old span remains in the tree unchanged.

If it returns Remove then the span gets removed from the ast, if it returns Replace with a new span it will replace the old one.

The size of the returned Seq is always between 0 and the number of template spans passed to this function.

The rewriting is performed bottom-up (depth-first), therefore any element passed to the rule only contains children which have already been processed.

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product