question on AbstractMarkupFilter rule behavior...

5 views
Skip to first unread message

jim

unread,
Sep 13, 2021, 3:14:23 PM9/13/21
to Group: okapi-devel
    String config = "exclude_by_default: true\n" +
                "elements:\n" +
                "  pre:\n" +
                "    ruleTypes: [TEXTUNIT, PRESERVE_WHITESPACE]\n" +
                "    conditions: [translate, NOT_EQUALS, 'no']";

        String snippet = "<pre>Translate me.</pre><pre translate=\"no\">Don't translate me.</pre>";


In this case what rule should apply to <pre>?  Since we have no attributes to compare to the condition should the default be TEXT_UNIT? or RULE_NOT_FOUND?

Obviously <pre translate="no"> is unambiguous the TEXT_UNIT rule does *not* apply.

Jim 

jim

unread,
Sep 14, 2021, 12:19:33 PM9/14/21
to Group: okapi-devel, Chase Tingley, Yves
Forgot to mention current behavior is to treat <pre> as a TEXT_UNIT starter. That is, the "pre" rule matches even without attributes.

The general question is: If there is a condition for a rule and the element doesn't have attributes (so we can't test the conditions) should the rule apply anyway?

Keep in mind we also have exclude_by_default: true in this particular case.

Jim

jim

unread,
Sep 16, 2021, 1:12:30 PM9/16/21
to Group: okapi-devel, Chase Tingley, Yves
It was decided that conditions should apply in *all* cases even if there are no attributes for the element. In this case any attribute value will be null.

This will change the current behavior for all filters that use the YAML rules: HTML, XmlStream, OpenXml etc...

Jim
Reply all
Reply to author
Forward
0 new messages