Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic typechecking #568

Merged
merged 22 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/elements.css
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ table.lightweight-table th {
background-color: rgba(249, 241, 172, 1);
}
100% {
background-color: rgba(249, 241, 172, 0)
background-color: rgba(249, 241, 172, 0);
}
}
#spec-container :target:not(emu-annex, emu-clause, emu-intro, emu-note, body) {
Expand Down
20 changes: 13 additions & 7 deletions filter-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
let fs = require('fs');
let entities = require('./entities.json');

let transformed = Object.fromEntries(Object.entries(entities).map(([k, v]) => {
// whitespace, default-ignorable, combining characters, control characters
if (v.characters === '&' || v.characters === '<' || /\p{White_Space}|\p{DI}|\p{gc=M}|\p{gc=C}/u.test(v.characters)) {
return [k, null];
}
return [k, v.characters];
}));
let transformed = Object.fromEntries(
Object.entries(entities).map(([k, v]) => {
// whitespace, default-ignorable, combining characters, control characters
if (
v.characters === '&' ||
v.characters === '<' ||
/\p{White_Space}|\p{DI}|\p{gc=M}|\p{gc=C}/u.test(v.characters)
) {
return [k, null];
}
return [k, v.characters];
})
);
fs.writeFileSync('./entities-processed.json', JSON.stringify(transformed), 'utf8');
14 changes: 10 additions & 4 deletions src/Algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ export default class Algorithm extends Builder {
context.inAlg = true;
const { spec, node, clauseStack } = context;

const innerHTML = node.innerHTML; // TODO use original slice, forward this from linter

let emdTree: AlgorithmNode | null = null;
let innerHTML;
if ('ecmarkdownTree' in node) {
emdTree = (node as AlgorithmElementWithTree).ecmarkdownTree;
innerHTML = (node as AlgorithmElementWithTree).originalHtml;
} else {
const location = spec.locate(node);
const source =
location?.source == null || location.endTag == null
? node.innerHTML
: location.source.slice(location.startTag.endOffset, location.endTag.startOffset);
innerHTML = source;
try {
emdTree = emd.parseAlgorithm(innerHTML);
emdTree = emd.parseAlgorithm(source);
(node as AlgorithmElementWithTree).ecmarkdownTree = emdTree;
(node as AlgorithmElementWithTree).originalHtml = innerHTML;
(node as AlgorithmElementWithTree).originalHtml = source;
} catch (e) {
warnEmdFailure(spec.warn, node, e as SyntaxError);
}
Expand Down
Loading
Loading