Skip to content

Commit

Permalink
Consistently trim comma-separated list items
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored and bakkot committed Jan 18, 2023
1 parent f0e2368 commit de4460c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Meta extends Builder {
node
.getAttribute('effects')!
.split(',')
.map(c => c.trim()),
.map(e => e.trim()),
node
);
for (const effect of effects) {
Expand All @@ -40,6 +40,7 @@ export default class Meta extends Builder {
const classNames = node
.getAttribute('effects')!
.split(',')
.map(e => e.trim())
.map(e => `e-${e}`)
.join(' ');
const span = spec.doc.createElement('span');
Expand Down
2 changes: 1 addition & 1 deletion src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ async function walk(walker: TreeWalker, context: Context) {
throw new Error('oldids found on unsupported element: ' + context.node.nodeName);
}
oldids
.split(/,/g)
.split(',')
.map(s => s.trim())
.forEach(oid => {
const s = spec.doc.createElement('span');
Expand Down
10 changes: 8 additions & 2 deletions src/Xref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ export default class Xref extends Builder {
node.parentElement.children[0] === node
) {
if (node.parentElement.hasAttribute('effects')) {
const addEffects = node.parentElement.getAttribute('effects')!.split(',');
const addEffects = node.parentElement
.getAttribute('effects')!
.split(',')
.map(e => e.trim());
if (addEffects.length !== 0) {
this.addEffects = validateEffects(spec, addEffects, node.parentElement);
}
}
if (node.parentElement.hasAttribute('suppress-effects')) {
const suppressEffects = node.parentElement.getAttribute('suppress-effects')!.split(',');
const suppressEffects = node.parentElement
.getAttribute('suppress-effects')!
.split(',')
.map(e => e.trim());
if (suppressEffects.length !== 0) {
this.suppressEffects = validateEffects(spec, suppressEffects, node.parentElement);
}
Expand Down

0 comments on commit de4460c

Please sign in to comment.