Skip to content

Commit 0373c17

Browse files
committed
extend mergeInlineNodes custom tags
1 parent 75b4a79 commit 0373c17

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

hyperless/deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dbushell/hyperless",
3-
"version": "0.29.0",
3+
"version": "0.30.0",
44
"exports": {
55
".": "./mod.ts"
66
},

hyperless/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dbushell/hyperless",
3-
"version": "0.29.0",
3+
"version": "0.30.0",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/dbushell/hyperspace.git"

hyperless/src/html-utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@ import { inlineTags } from "./html-tags.ts";
44
/**
55
* Merge adjacent text and inline Nodes into single text Node
66
* @param node HTML Node
7+
* @param customTags Custom inline tags
78
*/
8-
export const mergeInlineNodes = (node: Node): void => {
9+
export const mergeInlineNodes = (
10+
node: Node,
11+
customTags: Set<string> = new Set(),
12+
): void => {
913
for (const child of [...node.children]) {
1014
if (child.type === "OPAQUE") {
1115
continue;
1216
}
1317
// Recursively merge sub-tree first
14-
mergeInlineNodes(child);
18+
mergeInlineNodes(child, customTags);
1519
// Merge this text node into the previous text node
1620
if (child.type === "TEXT" && child.previous?.type === "TEXT") {
1721
child.previous.raw += child.toString();
1822
child.detach();
1923
continue;
2024
}
21-
if (inlineTags.has(child.tag)) {
25+
if (inlineTags.has(child.tag) || customTags.has(child.tag)) {
2226
// Merge this inline node into previous text node
2327
if (child.previous?.type === "TEXT") {
2428
child.previous.raw += child.toString();

hypermore/deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dbushell/hypermore",
3-
"version": "0.30.0",
3+
"version": "0.31.0",
44
"exports": {
55
".": "./mod.ts"
66
},

hypermore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dbushell/hypermore",
3-
"version": "0.30.0",
3+
"version": "0.31.0",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/dbushell/hyperspace.git"
@@ -23,6 +23,6 @@
2323
"README.md"
2424
],
2525
"dependencies": {
26-
"@dbushell/hyperless": "^0.29.0"
26+
"@dbushell/hyperless": "^0.30.0"
2727
}
2828
}

0 commit comments

Comments
 (0)