Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(w3c/rfc2119): convert to ES6
- Loading branch information
1 parent
31df8e4
commit ede05b7
Showing
2 changed files
with
29 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |