Skip to content

Support comma-separated selectors - break down into individual items when weaving #97

@KillyMXI

Description

@KillyMXI

The input

const selectorValuePairs = [
  ['foo,bar', 'A'],
  ['bar,baz', 'B']
];

should be equivalent to

const selectorValuePairs = [
  ['foo', 'A'],
  ['bar', 'A'],
  ['bar', 'B'],
  ['baz', 'B']
];

Code location:

function toAstTerminalPairs<V>(array: [string, V][]): AstTerminalPair<V>[] {
const len = array.length;
const results = new Array(len) as AstTerminalPair<V>[];
for (let i = 0; i < len; i++) {
const [selectorString, val] = array[i];
const ast = preprocess(parseley.parse1(selectorString));
results[i] = {
ast: ast,
terminal: {
type: 'terminal',
valueContainer: { index: i, value: val, specificity: ast.specificity }
}
};
}
return results;
}

Instead of expecting exactly one result from parseley.parse1 - expect 1+ results from parseley.parse. Index has to increase for each parsed result rather than for each input array item.

The goal - more compact configuration for html-to-text package by allowing to group selectors that are treated in the same way (headings, blocks).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions