Skip to content

Commit fe8a2f0

Browse files
committed
shorter id
1 parent c793c23 commit fe8a2f0

23 files changed

+49
-49
lines changed

src/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function makeHtmlRenderer(root: string, baseRenderer: RenderRule): RenderRule {
6969
}
7070

7171
function uniqueCodeId(context: ParseContext, content: string): string {
72-
const hash = String(computeHash(content));
72+
const hash = computeHash(content).slice(0, 8);
7373
let id = hash;
7474
let count = 1;
7575
while (context.pieces.some((piece) => piece.code.some((code) => code.id === id))) {

test/output/block-expression.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div><span id="cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"></span></div>
1+
<div><span id="cell-6212702c"></span></div>

test/output/block-expression.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"type": "html",
99
"id": "",
1010
"cellIds": [
11-
"6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"
11+
"6212702c"
1212
],
13-
"html": "<div><span id=\"cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1\"></span></div>\n"
13+
"html": "<div><span id=\"cell-6212702c\"></span></div>\n"
1414
}
1515
],
1616
"cells": [
1717
{
1818
"type": "cell",
19-
"id": "6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1",
19+
"id": "6212702c",
2020
"inputs": [
2121
"display"
2222
],

test/output/dollar-expression.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p>$<span id="cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"></span></p>
1+
<p>$<span id="cell-6212702c"></span></p>

test/output/dollar-expression.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"type": "html",
99
"id": "",
1010
"cellIds": [
11-
"6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"
11+
"6212702c"
1212
],
13-
"html": "<p>$<span id=\"cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1\"></span></p>\n"
13+
"html": "<p>$<span id=\"cell-6212702c\"></span></p>\n"
1414
}
1515
],
1616
"cells": [
1717
{
1818
"type": "cell",
19-
"id": "6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1",
19+
"id": "6212702c",
2020
"inputs": [
2121
"display"
2222
],
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p><span id="cell-56e8b37a90d0b07a884e0445fe2495dee259fe3274d2e75aad25488aba87ea41"></span></p>
1+
<p><span id="cell-56e8b37a"></span></p>

test/output/double-quote-expression.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"type": "html",
99
"id": "",
1010
"cellIds": [
11-
"56e8b37a90d0b07a884e0445fe2495dee259fe3274d2e75aad25488aba87ea41"
11+
"56e8b37a"
1212
],
13-
"html": "<p><span id=\"cell-56e8b37a90d0b07a884e0445fe2495dee259fe3274d2e75aad25488aba87ea41\"></span></p>\n"
13+
"html": "<p><span id=\"cell-56e8b37a\"></span></p>\n"
1414
}
1515
],
1616
"cells": [
1717
{
1818
"type": "cell",
19-
"id": "56e8b37a90d0b07a884e0445fe2495dee259fe3274d2e75aad25488aba87ea41",
19+
"id": "56e8b37a",
2020
"inputs": [
2121
"display"
2222
],
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<h1 id="embedded-expression" tabindex="-1"><a class="observablehq-header-anchor" href="#embedded-expression">Embedded expression</a></h1>
2-
<p>One plus two is <span id="cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"></span>.</p>
2+
<p>One plus two is <span id="cell-6212702c"></span>.</p>

test/output/embedded-expression.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
"type": "html",
1515
"id": "",
1616
"cellIds": [
17-
"6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1"
17+
"6212702c"
1818
],
19-
"html": "<p>One plus two is <span id=\"cell-6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1\"></span>.</p>\n"
19+
"html": "<p>One plus two is <span id=\"cell-6212702c\"></span>.</p>\n"
2020
}
2121
],
2222
"cells": [
2323
{
2424
"type": "cell",
25-
"id": "6212702c7a0d68f00b8b23b5aecfca631a96c20d2cad78cd874611ac87cdbce1",
25+
"id": "6212702c",
2626
"inputs": [
2727
"display"
2828
],

test/output/fenced-code.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 id="fenced-code" tabindex="-1"><a class="observablehq-header-anchor" href="#fenced-code">Fenced code</a></h1>
2-
<div><div id="cell-fe9e095ef56a9999b1b76d6c863ccf89e19a55bcaa854ffc83a6f4390d151971" class="observablehq observablehq--block"></div>
2+
<div><div id="cell-fe9e095e" class="observablehq observablehq--block"></div>
33
<pre><code class="language-js"><span class="hljs-keyword">function</span> <span class="hljs-title function_">add</span>(<span class="hljs-params">a, b</span>) {
44
<span class="hljs-keyword">return</span> a + b;
55
}

0 commit comments

Comments
 (0)