Parsing multiple Marks defined by css selector


I’m trying to get multiple Marks by parsing an html tag with attributes, one mark per attribute. For example I want to get 2 marks by parsing <font size="7" color="red">text</font>.

I thought about creating a Mark for tag:'font' with several attributes, but it doesn’t look like a right way to go, especially if I also have different rules for font-size and color (based on style or css class) and a bunch of other attributes.

Defining 2 mark specs with tag:'font[size]' and tag:'font[color]' won’t work. It stops after matching first rule, and rules that defined later in schema are never tested example. For nodes this behavior makes sense, but for marks I would expect all rules to be tested, like with style:'font-size'.

Is there a way to change that behavior and test against all defined tag rules when parsing Marks?

That does indeed seem strange. But on the other hand, matching any number of mark rules against an element makes it hard to have rules with different specificity for a given element (say you want to parse code as code font mark but code.variable as some other mark), so I’m not entirely sure that would be a good solution.

Is there a problem with putting both marks on such element? And using exclude + ordering in schema if you want one mark, but not the other.

That does seem a bit too messy. I suppose a better solution would be to only match further rules whose main selector (node name, attribute name, or class/id name) hasn’t already been matched by a previous rule. But this would involve quite some restructuring in the DOM parser, and I don’t currently have time to work on that.