Rule to replace a given element and class by a new element, if the class
attribute has the expected value.
Ambiguity: This rule replaces the element name by a new name (and thus,
gets a new element). Rules, which matched the original element name will
be executed afterward (contained in subSequentRules). This handles
ambiguous mappings by overriding each other.
An example: You have mapping rules <span class="u"> to element <u> and
<span class="s"> to the element <s> and vice versa. Now, what about an
incoming <span class="s u">? One of the mapping rules will be first,
for example, replacing the element to <s>. As an intermediate state, we will
have <s class="u">. But: In subsequentRules we will still have the rule
mapping by class "u". Now, the element gets mapped to <u> in subsequent
rules, the last class being removed. Note that the order of mapping cannot
be guaranteed here (we have no predictable order in rules being executed).
This approach is considered as designed, which is, we have to deal
somehow with this ambiguity. Removing both classes will eventually remove
the ambiguity as it is decided, which class takes the lead. This is similar
to the behavior of headings (<p class="p--heading-1 p--heading-2"> will
resolve ambiguity to <p class="p--heading-1">) or text alignment as
handled by CKEditor (<p class="float--left float-right"> will get
one of the classes removed when it passed processing in CKEditor).
Parameters
originalName: string
original name of the element to match
className: string
class attribute, which must match; this attribute will be removed from the new element
Rule to replace a given element and class by a new element, if the class attribute has the expected value.
Ambiguity: This rule replaces the element name by a new name (and thus, gets a new element). Rules, which matched the original element name will be executed afterward (contained in
subSequentRules). This handles ambiguous mappings by overriding each other.An example: You have mapping rules
<span class="u">to element<u>and<span class="s">to the element<s>and vice versa. Now, what about an incoming<span class="s u">? One of the mapping rules will be first, for example, replacing the element to<s>. As an intermediate state, we will have<s class="u">. But: InsubsequentRuleswe will still have the rule mapping by class"u". Now, the element gets mapped to<u>in subsequent rules, the last class being removed. Note that the order of mapping cannot be guaranteed here (we have no predictable order in rules being executed).This approach is considered as designed, which is, we have to deal somehow with this ambiguity. Removing both classes will eventually remove the ambiguity as it is decided, which class takes the lead. This is similar to the behavior of headings (
<p class="p--heading-1 p--heading-2">will resolve ambiguity to<p class="p--heading-1">) or text alignment as handled by CKEditor (<p class="float--left float-right">will get one of the classes removed when it passed processing in CKEditor).