2015-08-03 20:45:58 -04:00
|
|
|
- var getFrag = function(fileName) {
|
|
|
|
- var frag = partial(fileName);
|
|
|
|
- if (frag == null) {
|
|
|
|
- return "BAD FILENAME: " + fileName + " Current path: " + current.path;
|
|
|
|
- } else {
|
|
|
|
- // ``` gets translated to <pre><code>.....</code></pre> and we need
|
|
|
|
- // to remove this from the fragment prefix is 11 long and suffix is 13 long
|
|
|
|
- var r = frag.substring(11, frag.length-13);
|
|
|
|
- return r;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- var getExtn = function(fileName) {
|
|
|
|
- var ix = fileName.lastIndexOf('.');
|
|
|
|
- return ix > 0 ? fileName.substr(ix+1) : "";
|
|
|
|
- }
|
|
|
|
|
|
|
|
// HACK: to avoid having to include a path in makeTabs calls
|
|
|
|
- var currentPath = current.path;
|
2015-08-06 15:45:50 -04:00
|
|
|
|
|
|
|
// simple way to only take as many '../' sections as we need to back up to the 'docs' dir
|
|
|
|
// from the current document
|
|
|
|
// we will almost certainly never go 10 or 11 deep but ...
|
2015-08-03 20:45:58 -04:00
|
|
|
- var pathToFrags = "../../../../../../../../../../../".substr(0, (currentPath.length-2)*3) + "_fragments/";
|
|
|
|
|
|
|
|
mixin makeTabs(path, fileNames, tabNames)
|
|
|
|
- fileNames = fileNames.split(",");
|
|
|
|
- tabNames = tabNames.split(",")
|
|
|
|
// .p Length #{currentPath.length}
|
|
|
|
code-tabs
|
|
|
|
each fileName,index in fileNames
|
|
|
|
- var tabName = tabNames[index].trim();
|
|
|
|
- var fileName = fileNames[index].trim();
|
|
|
|
- var extn = getExtn(fileName);
|
|
|
|
// - var extPath = pathToFrags + (path.length ? path + "/" : "");
|
|
|
|
- var extPath = pathToFrags + path + "/";
|
|
|
|
code-pane(language="#{extn}" name="#{tabName}" format="linenums")
|
|
|
|
!= getFrag(extPath + fileName + ".md")
|