Skip to content

Commit

Permalink
BREAKING CHANGE(biblio): output spec title first (closes #857)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Feb 16, 2017
1 parent e6d55ab commit 199d9a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
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);
});
});

0 comments on commit 199d9a0

Please sign in to comment.