-
Notifications
You must be signed in to change notification settings - Fork 64
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
10 changed files
with
256 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
const Builder = require('./Builder'); | ||
|
||
module.exports = class Example extends Builder { | ||
constructor(spec, node, clause) { | ||
super(spec, node); | ||
this.clause = clause; | ||
this.caption = this.node.getAttribute('caption'); | ||
if (this.node.hasAttribute('id')) { | ||
this.id = this.node.getAttribute('id'); | ||
} | ||
} | ||
|
||
build(number) { | ||
// biblio is added during the build step as we don't know | ||
// the number at build time. Could probably be fixed. | ||
this.spec.biblio.examples[this.id] = { | ||
location: '', | ||
id: this.id, | ||
number: number || 1, | ||
clauseId: this.clause.id | ||
}; | ||
|
||
this.node.innerHTML = '<figure>' + this.node.innerHTML + '</figure>'; | ||
|
||
let caption = 'Example'; | ||
if (number) { | ||
caption += ' ' + number; | ||
} | ||
|
||
caption += ' (Informative)'; | ||
|
||
if (this.caption) { | ||
caption += ': ' + this.caption; | ||
} | ||
|
||
const captionElem = this.spec.doc.createElement('figcaption'); | ||
captionElem.textContent = caption; | ||
this.node.childNodes[0].appendChild(captionElem); | ||
} | ||
}; | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<pre class=metadata>toc: false</pre> | ||
<p>Examples outside of clauses aren't processed specially.</p> | ||
<emu-example> | ||
This is an example. | ||
</emu-example> | ||
<emu-clause id="sec-example"> | ||
<h1>Example Section</h1> | ||
<emu-example> | ||
Examples inside clauses are numbered and have captions. Captions are optional. | ||
</emu-example> | ||
<emu-clause id="sec-example-subclause"> | ||
<h1>Example Subclause</h1> | ||
<emu-example caption="An example"> | ||
Multiple examples are numbered similar to notes | ||
</emu-example> | ||
<emu-example caption="A second example"> | ||
So this becomes example 2. | ||
</emu-example> | ||
</emu-clause> | ||
</emu-clause> | ||
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,26 @@ | ||
<!doctype html> | ||
<head></head><body> | ||
<p>Examples outside of clauses aren't processed specially.</p> | ||
<emu-example> | ||
This is an example. | ||
</emu-example> | ||
|
||
<emu-clause id="sec-example"> | ||
<h1><span class="secnum">1</span>Example Section<span class="utils"><span class="anchor"><a href="#sec-example">#</a></span></span></h1> | ||
<emu-example><figure> | ||
Examples inside clauses are numbered and have captions. Captions are optional. | ||
<figcaption>Example (Informative)</figcaption></figure></emu-example> | ||
|
||
<emu-clause id="sec-example-subclause"> | ||
<h1><span class="secnum">1.1</span>Example Subclause<span class="utils"><span class="anchor"><a href="#sec-example-subclause">#</a></span></span></h1> | ||
<emu-example caption="An example"><figure> | ||
Multiple examples are numbered similar to notes | ||
<figcaption>Example 1 (Informative): An example</figcaption></figure></emu-example> | ||
|
||
<emu-example caption="A second example"><figure> | ||
So this becomes example 2. | ||
<figcaption>Example 2 (Informative): A second example</figcaption></figure></emu-example> | ||
</emu-clause> | ||
</emu-clause> | ||
|
||
</body> |
Oops, something went wrong.