From 20009f5ad9ada7949b8c219ad82ff051f3dbae84 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Feb 2021 17:42:58 -0800 Subject: [PATCH 1/5] rm some dead code --- css/elements.css | 45 --------------------------------------------- src/Clause.ts | 19 ------------------- 2 files changed, 64 deletions(-) diff --git a/css/elements.css b/css/elements.css index fe209236..cb1ce367 100644 --- a/css/elements.css +++ b/css/elements.css @@ -382,51 +382,6 @@ h6 { font-size: 1em; } -h1:hover span.utils { - display: block; -} - -span.utils { - font-size: 18px; - line-height: 18px; - display: none; - position: absolute; - top: 100%; - left: 0; - right: 0; - font-weight: normal; -} - -span.utils:before { - content: '⤷'; - display: inline-block; - padding: 0 5px; -} - -span.utils > * { - display: inline-block; - margin-right: 20px; -} - -h1 span.utils span.anchor a, -h2 span.utils span.anchor a, -h3 span.utils span.anchor a, -h4 span.utils span.anchor a, -h5 span.utils span.anchor a, -h6 span.utils span.anchor a { - text-decoration: none; - font-variant: small-caps; -} - -h1 span.utils span.anchor a:hover, -h2 span.utils span.anchor a:hover, -h3 span.utils span.anchor a:hover, -h4 span.utils span.anchor a:hover, -h5 span.utils span.anchor a:hover, -h6 span.utils span.anchor a:hover { - color: #333; -} - emu-intro h1, emu-clause h1, emu-annex h1 { diff --git a/src/Clause.ts b/src/Clause.ts index 0e3f4116..0e6f52f8 100644 --- a/src/Clause.ts +++ b/src/Clause.ts @@ -87,24 +87,6 @@ export default class Clause extends Builder { } } - buildUtils() { - const utilsElem = this.spec.doc.createElement('span'); - utilsElem.setAttribute('class', 'utils'); - - const anchorElem = this.spec.doc.createElement('span'); - anchorElem.setAttribute('class', 'anchor'); - anchorElem.innerHTML = 'link'; - - const pinElem = this.spec.doc.createElement('span'); - pinElem.setAttribute('class', 'anchor'); - pinElem.innerHTML = 'pin'; - - utilsElem.appendChild(anchorElem); - utilsElem.appendChild(pinElem); - - this.header.appendChild(utilsElem); - } - static async enter({ spec, node, clauseStack, clauseNumberer }: Context) { if (!node.id) { spec.warn({ @@ -145,7 +127,6 @@ export default class Clause extends Builder { clause.buildHeader(); clause.buildExamples(); clause.buildNotes(); - //clause.buildUtils(); // clauses are always at the spec-level namespace. spec.biblio.add( From ac107ef5018efaf3d8b33646201e61425e68374b Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Feb 2021 18:41:10 -0800 Subject: [PATCH 2/5] tweak css so margin-top is on clauses, not headers --- css/elements.css | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/css/elements.css b/css/elements.css index cb1ce367..a7a89fd2 100644 --- a/css/elements.css +++ b/css/elements.css @@ -362,7 +362,6 @@ h1 span.title { h1 { font-size: 2.67em; - margin-top: 2em; margin-bottom: 0; line-height: 1em; } @@ -494,6 +493,40 @@ emu-annex { display: block; } + +/* these values are twice the font-size for the

titles for clauses */ +emu-intro, +emu-clause, +emu-annex { + margin-top: 4em; +} +emu-intro emu-intro, +emu-clause emu-clause, +emu-annex emu-annex { + margin-top: 3.12em; +} +emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex { + margin-top: 2.5em; +} +emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex { + margin-top: 2.22em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex emu-annex { + margin-top: 2em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex { + margin-top: 1.8em; +} + + /* Figures and tables */ figure { display: block; From df84e68b4282cf9d72d909fff130f730d2ebdfeb Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Feb 2021 18:45:43 -0800 Subject: [PATCH 3/5] add support for normative optional attribute --- css/elements.css | 11 +++++++++++ src/Clause.ts | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/css/elements.css b/css/elements.css index a7a89fd2..0b5e4ea3 100644 --- a/css/elements.css +++ b/css/elements.css @@ -1110,3 +1110,14 @@ li.menu-search-result-term:before { display: none; } } + +[normative-optional] { + border-left: 5px solid #ff6600; + padding: .5em; + display: block; + background: #ffeedd; +} + +.normative-optional-tag { + color: #884400; +} diff --git a/src/Clause.ts b/src/Clause.ts index 0e6f52f8..e6999e07 100644 --- a/src/Clause.ts +++ b/src/Clause.ts @@ -114,7 +114,7 @@ export default class Clause extends Builder { clauseStack.push(clause); } - static exit({ spec, clauseStack }: Context) { + static exit({ node, spec, clauseStack }: Context) { const clause = clauseStack[clauseStack.length - 1]; if (!clause.header) { @@ -128,6 +128,13 @@ export default class Clause extends Builder { clause.buildExamples(); clause.buildNotes(); + if (node.hasAttribute('normative-optional')) { + let tag = spec.doc.createElement('div'); + tag.className = 'normative-optional-tag'; + tag.append(spec.doc.createTextNode('NORMATIVE OPTIONAL')); + node.prepend(tag); + } + // clauses are always at the spec-level namespace. spec.biblio.add( { From 7206e989a0df7ab8400d9bcb2719b265961e7365 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Feb 2021 19:06:59 -0800 Subject: [PATCH 4/5] make autolinking work --- css/elements.css | 5 +++++ src/Clause.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/css/elements.css b/css/elements.css index 0b5e4ea3..8783086f 100644 --- a/css/elements.css +++ b/css/elements.css @@ -1119,5 +1119,10 @@ li.menu-search-result-term:before { } .normative-optional-tag { + text-transform: uppercase; + color: #884400; +} + +.normative-optional-tag a { color: #884400; } diff --git a/src/Clause.ts b/src/Clause.ts index e6999e07..cab13931 100644 --- a/src/Clause.ts +++ b/src/Clause.ts @@ -114,7 +114,7 @@ export default class Clause extends Builder { clauseStack.push(clause); } - static exit({ node, spec, clauseStack }: Context) { + static exit({ node, spec, clauseStack, inAlg, currentId }: Context) { const clause = clauseStack[clauseStack.length - 1]; if (!clause.header) { @@ -131,8 +131,18 @@ export default class Clause extends Builder { if (node.hasAttribute('normative-optional')) { let tag = spec.doc.createElement('div'); tag.className = 'normative-optional-tag'; - tag.append(spec.doc.createTextNode('NORMATIVE OPTIONAL')); + let contents = spec.doc.createTextNode('Normative Optional'); + tag.append(contents); node.prepend(tag); + + // we've already walked past the text node, so it won't get picked up by the usual process for autolinking + spec._textNodes[clause.namespace] = spec._textNodes[clause.namespace] || []; + spec._textNodes[clause.namespace].push({ + node: contents, + clause, + inAlg, + currentId, + }); } // clauses are always at the spec-level namespace. From 75ddc9a727fec08c2d0b86d4ea915cea826895dd Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Feb 2021 19:13:56 -0800 Subject: [PATCH 5/5] update spec --- css/elements.css | 4 +- docs/elements.css | 94 ++++++++++++++++++++++++----------------------- docs/index.html | 15 +++++++- spec/index.html | 15 ++++++++ 4 files changed, 78 insertions(+), 50 deletions(-) diff --git a/css/elements.css b/css/elements.css index 8783086f..5c9d6806 100644 --- a/css/elements.css +++ b/css/elements.css @@ -493,7 +493,6 @@ emu-annex { display: block; } - /* these values are twice the font-size for the

titles for clauses */ emu-intro, emu-clause, @@ -526,7 +525,6 @@ emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex { margin-top: 1.8em; } - /* Figures and tables */ figure { display: block; @@ -1113,7 +1111,7 @@ li.menu-search-result-term:before { [normative-optional] { border-left: 5px solid #ff6600; - padding: .5em; + padding: 0.5em; display: block; background: #ffeedd; } diff --git a/docs/elements.css b/docs/elements.css index fe209236..5c9d6806 100644 --- a/docs/elements.css +++ b/docs/elements.css @@ -362,7 +362,6 @@ h1 span.title { h1 { font-size: 2.67em; - margin-top: 2em; margin-bottom: 0; line-height: 1em; } @@ -382,51 +381,6 @@ h6 { font-size: 1em; } -h1:hover span.utils { - display: block; -} - -span.utils { - font-size: 18px; - line-height: 18px; - display: none; - position: absolute; - top: 100%; - left: 0; - right: 0; - font-weight: normal; -} - -span.utils:before { - content: '⤷'; - display: inline-block; - padding: 0 5px; -} - -span.utils > * { - display: inline-block; - margin-right: 20px; -} - -h1 span.utils span.anchor a, -h2 span.utils span.anchor a, -h3 span.utils span.anchor a, -h4 span.utils span.anchor a, -h5 span.utils span.anchor a, -h6 span.utils span.anchor a { - text-decoration: none; - font-variant: small-caps; -} - -h1 span.utils span.anchor a:hover, -h2 span.utils span.anchor a:hover, -h3 span.utils span.anchor a:hover, -h4 span.utils span.anchor a:hover, -h5 span.utils span.anchor a:hover, -h6 span.utils span.anchor a:hover { - color: #333; -} - emu-intro h1, emu-clause h1, emu-annex h1 { @@ -539,6 +493,38 @@ emu-annex { display: block; } +/* these values are twice the font-size for the

titles for clauses */ +emu-intro, +emu-clause, +emu-annex { + margin-top: 4em; +} +emu-intro emu-intro, +emu-clause emu-clause, +emu-annex emu-annex { + margin-top: 3.12em; +} +emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex { + margin-top: 2.5em; +} +emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex { + margin-top: 2.22em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex emu-annex { + margin-top: 2em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro, +emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause, +emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex { + margin-top: 1.8em; +} + /* Figures and tables */ figure { display: block; @@ -1122,3 +1108,19 @@ li.menu-search-result-term:before { display: none; } } + +[normative-optional] { + border-left: 5px solid #ff6600; + padding: 0.5em; + display: block; + background: #ffeedd; +} + +.normative-optional-tag { + text-transform: uppercase; + color: #884400; +} + +.normative-optional-tag a { + color: #884400; +} diff --git a/docs/index.html b/docs/index.html index a7bdcb30..7c33a266 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ Ecmarkup -
+

Ecmarkup

@@ -160,6 +160,19 @@

6.2 emu-clause

Attributes

id: Clause id. Must be unique.

aoid: Abstract operation ID. A unique name identifying this clause as an abstract operation. Algorithm steps will auto-link calls to this abstract operation to this clause. If left blank, the aoid will be set to the id of this clause.

+

normative-optional: If present, the clause is Normative Optional.

+ +

Example

+

Element

+
<emu-clause id="example-normative-optional" normative-optional>
+  <h1>Example Normative Optional Clause</h1>
+  <p>This clause is normative optional.</p>
+</emu-clause>
+

Result

+
Normative Optional
+

6.2.1 Example Normative Optional Clause

+

This clause is normative optional.

+
diff --git a/spec/index.html b/spec/index.html index 7783708e..a9915bad 100644 --- a/spec/index.html +++ b/spec/index.html @@ -166,6 +166,21 @@

emu-clause

Attributes

id: Clause id. Must be unique.

aoid: Abstract operation ID. A unique name identifying this clause as an abstract operation. Algorithm steps will auto-link calls to this abstract operation to this clause. If left blank, the aoid will be set to the id of this clause.

+

normative-optional: If present, the clause is Normative Optional.

+ +

Example

+

Element

+

+      <emu-clause id="example-normative-optional" normative-optional>
+        <h1>Example Normative Optional Clause</h1>
+        <p>This clause is normative optional.</p>
+      </emu-clause>
+    
+

Result

+ +

Example Normative Optional Clause

+

This clause is normative optional.

+