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 committed Feb 21, 2017
1 parent dae7dbd commit ab8f4e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
41 changes: 0 additions & 41 deletions js/w3c/rfc2119.js

This file was deleted.

31 changes: 31 additions & 0 deletions src/w3c/rfc2119.js
@@ -0,0 +1,31 @@
// 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)
.sort()
// 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, item => `<em class="rfc2119">${item}</em>`) + confo.innerHTML;
const plural = terms.length > 1;
let str = `The key word${plural ? "s " : " "} ${html} ${plural ? "are" : "is"}`;
str += joinAnd(terms, item => `<em class="rfc2119">${item}</em>`) + " are ";
confo.innerHTML = str + html;
cb();
}

0 comments on commit ab8f4e8

Please sign in to comment.