mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 22:55:44 +01:00
Answer architecture round 1: 2 🔴, 6 🟡 (0 misread); carried JSON read through adf/, one spelling home per element in html/, block readers in one table, the first paragraph's form shared, a lint boundary for html/parse, a strictness oracle
This commit is contained in:
@@ -10,10 +10,11 @@ export function serializeCanonicalJson(value: JsonValue, spelling: JsonSpelling)
|
||||
return [...canonicalJsonPieces(value, spelling)].join('')
|
||||
}
|
||||
|
||||
// Stops at the first piece that does not match `text`: re-spelled with two-space indentation, a short compact text can pass the engine's longest string.
|
||||
export function spellsCanonicalJson(value: JsonValue, spelling: JsonSpelling, text: string): boolean {
|
||||
// Stops at the first piece, passed through `respell`, that does not match `text`: re-spelled with two-space indentation, a short compact text can pass the engine's longest string.
|
||||
export function spellsCanonicalJson(value: JsonValue, spelling: JsonSpelling, text: string, respell = (canonical: string): string => canonical): boolean {
|
||||
let offset = 0
|
||||
for (const piece of canonicalJsonPieces(value, spelling)) {
|
||||
for (const canonical of canonicalJsonPieces(value, spelling)) {
|
||||
const piece = respell(canonical)
|
||||
if (!text.startsWith(piece, offset)) return false
|
||||
offset += piece.length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user