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(biblio): output spec title first (closes #857) #1083

Merged
merged 1 commit into from Feb 16, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/core/biblio.js
Expand Up @@ -47,24 +47,23 @@ const REF_STATUSES = new Map([
["WG-NOTE", "W3C Working Group Note"],
]);



export function stringifyReference(ref) {
if (typeof ref === "string") return ref;
var output = "";
let output = `<cite>${ref.title}</cite>`;
if (ref.href) {
output = `<a href="${ref.href}">${output}</a>. `;
}
if (ref.authors && ref.authors.length) {
output += ref.authors.join("; ");
if (ref.etAl) output += " et al";
output += ". ";
output += ".";
}
if (ref.publisher) {
output += ref.publisher;
if (/\.$/.test(ref.publisher)) {
output += " ";
} else {
output += ". ";
}
const publisher = ref.publisher + (/\.$/.test(ref.publisher) ? "" : ".");
output = `${output} ${publisher} `;
}
if (ref.href) output += `<a href="${ref.href}"><cite>${ref.title}</cite></a>. `;
else output += `<cite>${ref.title}</cite>. `;
if (ref.date) output += ref.date + ". ";
if (ref.status) output += (REF_STATUSES.get(ref.status) || ref.status) + ". ";
if (ref.href) output += `URL: <a href="${ref.href}">${ref.href}</a>`;
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/core/biblio-spec.js
Expand Up @@ -92,7 +92,7 @@ describe("W3C — Bibliographic References", function() {
// Make sure publisher is shown even when there is no author
ref = doc.querySelector("#bib-TestRef3 + dd");
expect(ref).toBeTruthy();
expect(ref.textContent).toMatch(/^Publisher Here\.\s/);
expect(ref.textContent).toMatch(/Publisher Here\.\s/);
}).then(done).catch(done);
});
});