From b93097c37c632226714cf44d048bb2ddb590f929 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sat, 16 Dec 2023 14:08:41 +0200 Subject: [PATCH] Update & expand spec text to cover fallback values and pattern selection (#35) * Add semantic line breaks to spec.emu to make editing easier * Update to ecmarkup 18 * Add return types to AO structured headers --------- Co-authored-by: Daniel Minor --- .github/workflows/build.yml | 6 +- index.html | 1155 ++++++++++++++++++++++++++++++----- package.json | 2 +- spec.emu | 361 +++++++++-- 4 files changed, 1308 insertions(+), 216 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd22fc9..599caae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '16.x' + node-version: '20.x' - run: npm install - run: npm run build - name: commit changes diff --git a/index.html b/index.html index 17f5a88..31efc93 100644 --- a/index.html +++ b/index.html @@ -135,7 +135,7 @@ }; Search.prototype.documentKeydown = function (e) { - if (e.keyCode === 191) { + if (e.key === '/') { e.preventDefault(); e.stopPropagation(); this.triggerSearch(); @@ -190,7 +190,7 @@ relevance += 2048; } - relevance += Math.max(0, 255 - result.entry.key.length); + relevance += Math.max(0, 255 - result.key.length); return relevance; } @@ -214,20 +214,21 @@ if (/^[\d.]*$/.test(searchString)) { results = this.biblio.clauses .filter(clause => clause.number.substring(0, searchString.length) === searchString) - .map(clause => ({ entry: clause })); + .map(clause => ({ key: getKey(clause), entry: clause })); } else { results = []; for (let i = 0; i < this.biblio.entries.length; i++) { let entry = this.biblio.entries[i]; - if (!entry.key) { + let key = getKey(entry); + if (!key) { // biblio entries without a key aren't searchable continue; } - let match = fuzzysearch(searchString, entry.key); + let match = fuzzysearch(searchString, key); if (match) { - results.push({ entry, match }); + results.push({ key, entry, match }); } } @@ -276,6 +277,7 @@ let html = '