-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
695 additions
and
718 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -1,25 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = Algorithm; | ||
const Builder = require('./Builder'); | ||
const emd = require('ecmarkdown'); | ||
|
||
var emd = require('ecmarkdown'); | ||
module.exports = class Algorithm extends Builder { | ||
build() { | ||
const contents = this.node.innerHTML; | ||
let html = emd.document(contents); | ||
|
||
function Algorithm(spec, algNode) { | ||
this.spec = spec; | ||
this.node = algNode; | ||
} | ||
html = html.replace(/([A-Z]\w+)\(/g, function (match, name) { | ||
let op = this.spec.biblio.ops[name]; | ||
if (!op) op = this.spec.externalBiblio.ops[name]; | ||
if (!op) return match; | ||
|
||
Algorithm.prototype.build = function () { | ||
var contents = this.node.innerHTML; | ||
var html = emd.document(contents); | ||
return '<a href="' + op.location + '#' + op.id + '">' + name + '</a>('; | ||
}.bind(this)); | ||
|
||
html = html.replace(/([A-Z]\w+)\(/g, function (match, name) { | ||
var op = this.spec.biblio.ops[name]; | ||
if (!op) op = this.spec.externalBiblio.ops[name]; | ||
if (!op) return match; | ||
|
||
return '<a href="' + op.location + '#' + op.id + '">' + name + '</a>('; | ||
}.bind(this)); | ||
|
||
this.node.innerHTML = html; | ||
this.node.innerHTML = html; | ||
} | ||
}; |
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,12 @@ | ||
'use strict'; | ||
|
||
module.exports = class Builder { | ||
constructor(spec, node) { | ||
this.spec = spec; | ||
this.node = node; | ||
} | ||
|
||
build() { | ||
throw new Error('Builder not implemented'); | ||
} | ||
}; |
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
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,16 @@ | ||
'use strict'; | ||
|
||
const Builder = require('./Builder'); | ||
const parent = require('./utils').parent; | ||
|
||
module.exports = class Dfn extends Builder { | ||
build() { | ||
const parentClause = parent(this.node, ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']); | ||
if (!parentClause) return; | ||
|
||
this.spec.biblio.terms[this.node.textContent] = { | ||
id: parentClause.id, | ||
location: '' | ||
}; | ||
} | ||
}; |
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,22 @@ | ||
'use strict'; | ||
|
||
const Builder = require('./Builder'); | ||
const gmd = require('grammarkdown'); | ||
const GrammarFile = gmd.Grammar; | ||
const EmitFormat = gmd.EmitFormat; | ||
|
||
const gmdCompile = function (text) { | ||
let out; | ||
function readFile(file) { return text; } | ||
function writeFile(file, output) { out = output; } | ||
const g = new GrammarFile(['file.grammar'], { format: EmitFormat.ecmarkup }, readFile); | ||
g.emit(undefined, writeFile); | ||
|
||
return out; | ||
}; | ||
|
||
module.exports = class Grammar extends Builder { | ||
build() { | ||
this.node.innerHTML = gmdCompile(this.node.textContent); | ||
} | ||
}; |
Oops, something went wrong.
Hrm