Skip to content

Commit

Permalink
Define ReSpec processor for cross-reference to JSEP
Browse files Browse the repository at this point in the history
Mechanics of #337
  • Loading branch information
dontcallmedom committed Dec 3, 2015
1 parent 3a8a491 commit 0126158
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions webrtc.js
Expand Up @@ -89,4 +89,48 @@ var respecConfig = {
]
}
],
preProcess: [
function linkToJsep() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'jsep-mapping/map.json');
xhr.onload = function(e) {
var data = JSON.parse(this.responseText);
if (respecConfig.localBiblio.JSEP.date !== data.metadata.date) {
respecEvents.pub("warn", "Date of JSEP draft in localBiblio (" + respecConfig.localBiblio.date + ") does not match date of JSEP draft used in map.json (" + data.metadata.date + ").");
}
// Replace all
// <span data-jsep="foo">[[!JSEP]]</a>
// with
// <span>[[!JSEP]] (<a href="...#X.Y">section X.Y.</a>)
// based on mapping maintained in jsep.json
Array.prototype.forEach.call(
document.querySelectorAll("*[data-jsep]"),
function (el) {
var sectionLink = document.createElement("a");
var jsepSection = data.sections['sec.' + el.dataset.jsep];
if (!jsepSection) {
respecEvents.pub("warn", "Reference to inexistent JSEP section with anchor 'sec." + el.dataset.jsep + "'.");
return;
}
el.removeAttribute("data-jsep");
sectionLink.href = "https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-" + data.metadata.version + "#section-" + jsepSection.slice(0, jsepSection.length - 1);
sectionLink.textContent = "section " + jsepSection;
el.appendChild(document.createTextNode(" ("));
el.appendChild(sectionLink);
el.appendChild(document.createTextNode(")"));
});
};
xhr.send();
}
],
localBiblio: {
"JSEP": {
"authors":["Justin Uberti","Cullen Jennings","Eric Rescorla"],
"href": "http://datatracker.ietf.org/doc/draft-ietf-rtcweb-jsep/",
"publisher": "IETF",
"status": "Active Internet-Draft",
"title": "Javascript Session Establishment Protocol",
"date": "18 October 2015"
}
}
};

0 comments on commit 0126158

Please sign in to comment.