Comparing version 9.7.0 to 9.7.1
@@ -38,10 +38,8 @@ "use strict"; | ||
let emdTree; | ||
if ('ecmarkdownTree' in node) { | ||
emdTree = node.ecmarkdownTree; | ||
try { | ||
emdTree = emd.parseAlgorithm(innerHTML); | ||
} | ||
else { | ||
try { | ||
emdTree = emd.parseAlgorithm(innerHTML); | ||
} | ||
catch (e) { | ||
catch (e) { | ||
if (!('ecmarkdownTree' in node)) { | ||
// if it is present, we've already warned earlier | ||
utils_1.warnEmdFailure(spec.warn, node, e); | ||
@@ -48,0 +46,0 @@ } |
@@ -74,2 +74,6 @@ "use strict"; | ||
this.header = header; | ||
if (header == null) { | ||
this.title = 'UNKNOWN'; | ||
this.titleHTML = 'UNKNOWN'; | ||
} | ||
} | ||
@@ -200,22 +204,2 @@ buildStructuredHeader(header) { | ||
const clause = clauseStack[clauseStack.length - 1]; | ||
const header = clause.header; | ||
if (header == null) { | ||
clause.title = 'UNKNOWN'; | ||
clause.titleHTML = 'UNKNOWN'; | ||
} | ||
else { | ||
const headerClone = header.cloneNode(true); | ||
for (const a of headerClone.querySelectorAll('a')) { | ||
a.replaceWith(...a.childNodes); | ||
} | ||
clause.titleHTML = headerClone.innerHTML; | ||
clause.title = headerClone.textContent; | ||
if (clause.number) { | ||
const numElem = clause.spec.doc.createElement('span'); | ||
numElem.setAttribute('class', 'secnum'); | ||
numElem.textContent = clause.number; | ||
header.insertBefore(clause.spec.doc.createTextNode(' '), header.firstChild); | ||
header.insertBefore(numElem, header.firstChild); | ||
} | ||
} | ||
clause.buildExamples(); | ||
@@ -222,0 +206,0 @@ clause.buildNotes(); |
@@ -14,2 +14,3 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const Spec_1 = require("./Spec"); | ||
class Meta extends Builder_1.default { | ||
@@ -25,9 +26,9 @@ static enter({ spec, node, clauseStack }) { | ||
for (const effect of effects) { | ||
if (!parent.effects.includes(effect)) { | ||
parent.effects.push(effect); | ||
if (!spec._effectWorklist.has(effect)) { | ||
spec._effectWorklist.set(effect, []); | ||
} | ||
spec._effectWorklist.get(effect).push(parent); | ||
if (!utils_1.doesEffectPropagateToParent(node, effect)) { | ||
continue; | ||
} | ||
if (!spec._effectWorklist.has(effect)) { | ||
spec._effectWorklist.set(effect, []); | ||
} | ||
Spec_1.maybeAddClauseToEffectWorklist(effect, parent, spec._effectWorklist.get(effect)); | ||
} | ||
@@ -34,0 +35,0 @@ } |
import type { Options } from './ecmarkup'; | ||
import Clause from './Clause'; | ||
export default interface Spec { | ||
@@ -48,1 +49,2 @@ spec: this; | ||
}; | ||
export declare function maybeAddClauseToEffectWorklist(effectName: string, clause: Clause, worklist: Clause[]): void; |
@@ -21,1 +21,2 @@ import type { MarkupData } from 'parse5'; | ||
export declare function validateEffects(spec: Spec, effectsRaw: string[], node: Element): string[]; | ||
export declare function doesEffectPropagateToParent(node: Element, effect: string): boolean; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateEffects = exports.attrValueLocation = exports.attrLocation = exports.offsetToLineAndColumn = exports.copyFile = exports.writeFile = exports.readFile = exports.shouldInline = exports.logWarning = exports.logVerbose = exports.replaceTextNode = exports.domWalkBackward = exports.htmlToDom = exports.emdTextNode = exports.wrapEmdFailure = exports.warnEmdFailure = void 0; | ||
exports.doesEffectPropagateToParent = exports.validateEffects = exports.attrValueLocation = exports.attrLocation = exports.offsetToLineAndColumn = exports.copyFile = exports.writeFile = exports.readFile = exports.shouldInline = exports.logWarning = exports.logVerbose = exports.replaceTextNode = exports.domWalkBackward = exports.htmlToDom = exports.emdTextNode = exports.wrapEmdFailure = exports.warnEmdFailure = void 0; | ||
const jsdom = require("jsdom"); | ||
@@ -238,1 +238,26 @@ const chalk = require("chalk"); | ||
exports.validateEffects = validateEffects; | ||
function doesEffectPropagateToParent(node, effect) { | ||
var _a, _b; | ||
// Effects should not propagate past explicit fences in parent steps. | ||
// | ||
// Abstract Closures are considered automatic fences for the user-code | ||
// effect, since those are effectively nested functions. | ||
// | ||
// Calls to Abstract Closures that can call user code must be explicitly | ||
// marked as such with <emu-meta effects="user-code">...</emu-meta>. | ||
for (; node.parentElement; node = node.parentElement) { | ||
const parent = node.parentElement; | ||
// This is super hacky. It's checking the output of ecmarkdown. | ||
if (parent.tagName !== 'LI') | ||
continue; | ||
if (effect === 'user-code' && ((_a = parent.textContent) === null || _a === void 0 ? void 0 : _a.includes('be a new Abstract Closure'))) { | ||
return false; | ||
} | ||
if ((_b = parent | ||
.getAttribute('fence-effects')) === null || _b === void 0 ? void 0 : _b.split(',').map(s => s.trim()).includes(effect)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
exports.doesEffectPropagateToParent = doesEffectPropagateToParent; |
@@ -73,27 +73,7 @@ "use strict"; | ||
shouldPropagateEffect(effectName) { | ||
var _a, _b; | ||
if (!this.isInvocation) | ||
return false; | ||
if (this.clause) { | ||
// Xrefs should not propagate past explicit fences in parent steps. Fences | ||
// must be at the beginning of steps. | ||
// | ||
// Abstract Closures are considered automatic fences for the user-code | ||
// effect, since those are effectively nested functions. | ||
// | ||
// Calls to Abstract Closures that can call user code must be explicitly | ||
// marked as such with <emu-meta effects="user-code">...</emu-meta>. | ||
for (let node = this.node; node.parentElement; node = node.parentElement) { | ||
const parent = node.parentElement; | ||
// This is super hacky. It's checking the output of ecmarkdown. | ||
if (parent.tagName !== 'LI') | ||
continue; | ||
if (effectName === 'user-code' && | ||
((_a = parent.textContent) === null || _a === void 0 ? void 0 : _a.includes('be a new Abstract Closure'))) { | ||
return false; | ||
} | ||
if ((_b = parent | ||
.getAttribute('fence-effects')) === null || _b === void 0 ? void 0 : _b.split(',').map(s => s.trim()).includes(effectName)) { | ||
return false; | ||
} | ||
if (!utils_1.doesEffectPropagateToParent(this.node, effectName)) { | ||
return false; | ||
} | ||
@@ -100,0 +80,0 @@ if (!this.clause.canHaveEffect(effectName)) { |
{ | ||
"name": "ecmarkup", | ||
"version": "9.7.0", | ||
"version": "9.7.1", | ||
"description": "Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.", | ||
@@ -5,0 +5,0 @@ "main": "lib/ecmarkup.js", |
Sorry, the diff of this file is too big to display
1425538
119
10287