Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KillyMXI opened this issue Apr 2, 2023 · 0 comments

Comments

@KillyMXI
Copy link
Member

KillyMXI commented Apr 2, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant