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

Fix some minor issues and inconsistencies in string handling #501

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1456,14 +1456,14 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
this.doc.body.insertBefore(h1, this.doc.body.firstChild);
}

// version string, ala 6th Edition July 2016 or Draft 10 / September 26, 2015
// version string, e.g. "6th Edition July 2016" or "Draft 10 / September 26, 2015"
let versionText = '';
let omitShortname = false;
if (version) {
versionText += version + ' / ';
} else if (status === 'proposal' && stage) {
versionText += 'Stage ' + stage + ' Draft / ';
} else if (shortname && status === 'draft') {
} else if (status === 'draft' && shortname) {
versionText += 'Draft ' + shortname + ' / ';
omitShortname = true;
} else {
Expand Down 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
4 changes: 3 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ const build = debounce(async function build() {
warnings.push(err);
};

// Respect a reproducible build timestamp.
// https://reproducible-builds.org/specs/source-date-epoch/
if (process.env.SOURCE_DATE_EPOCH) {
const sde = process.env.SOURCE_DATE_EPOCH.trim();
if (!/^[0-9]+/.test(sde)) {
if (!/^[0-9]+$/.test(sde)) {
fail(`SOURCE_DATE_EPOCH value ${sde} is not valid`);
}
const ts = +sde;
Expand Down