Skip to content

Commit

Permalink
refactor(w3c/rfc2119): convert to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored and Marcos Cáceres committed Feb 21, 2017
1 parent 31df8e4 commit ede05b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 41 deletions.
41 changes: 0 additions & 41 deletions js/w3c/rfc2119.js

This file was deleted.

29 changes: 29 additions & 0 deletions src/w3c/rfc2119.js
@@ -0,0 +1,29 @@
// Module w3c/rfc2119
// update the 2119 terms section with the terms actually used

import { joinAnd } from "core/utils";

export const name = "w3c/rfc2119";

export function run(conf, doc, cb) {
const confo = doc.getElementById("respecRFC2119");
if (!confo) {
return cb();
}
// do we have a list of used RFC2119 items in
// conf.respecRFC2119
const terms = Object.getOwnPropertyNames(conf.respecRFC2119)

// there are no terms used - remove the clause
if (terms.length === 0) {
confo.remove();
return cb();
}

// put in the 2119 clause and reference
const html = joinAnd(terms.sort(), item => `<em class="rfc2119">${item}</em>`);
const plural = terms.length > 1;
const str = `The key word${plural ? "s " : " "} ${html} ${plural ? "are" : "is"} ${confo.innerHTML}`;
confo.innerHTML = str;
cb();
}

0 comments on commit ede05b7

Please sign in to comment.