@mdream/js 1.0.0-beta.12 → 1.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1025,11 +1025,22 @@ function parseHtmlInternal(htmlChunk, state, handleEvent) {
1025
1025
  break;
1026
1026
  }
1027
1027
  } else if (nextCharCode === SLASH_CHAR) {
1028
- const inQuotes = state.inSingleQuote || state.inDoubleQuote || state.inBacktick;
1029
- if (state.currentNode?.tagHandler?.isNonNesting && inQuotes) {
1030
- textBuffer += htmlChunk[i];
1031
- i++;
1032
- continue;
1028
+ if (state.currentNode?.tagHandler?.isNonNesting) {
1029
+ if (state.inSingleQuote || state.inDoubleQuote || state.inBacktick) {
1030
+ textBuffer += htmlChunk[i];
1031
+ i++;
1032
+ continue;
1033
+ }
1034
+ let peekEnd = i + 2;
1035
+ while (peekEnd < chunkLength) {
1036
+ const c = htmlChunk.charCodeAt(peekEnd);
1037
+ if (c === GT_CHAR || isWhitespace(c)) break;
1038
+ peekEnd++;
1039
+ }
1040
+ if ((TagIdMap[htmlChunk.substring(i + 2, peekEnd).toLowerCase()] ?? -1) !== state.currentNode.tagId) {
1041
+ textBuffer += htmlChunk[i++];
1042
+ continue;
1043
+ }
1033
1044
  }
1034
1045
  if (textBuffer.length > 0) {
1035
1046
  processTextBuffer(textBuffer, state, handleEvent);
@@ -1058,18 +1069,18 @@ function parseHtmlInternal(htmlChunk, state, handleEvent) {
1058
1069
  break;
1059
1070
  }
1060
1071
  const tagName = htmlChunk.substring(tagNameStart, tagNameEnd).toLowerCase();
1061
- if (!tagName) {
1062
- i = tagNameEnd;
1063
- break;
1064
- }
1065
1072
  const tagId = TagIdMap[tagName] ?? -1;
1066
1073
  i2 = tagNameEnd;
1067
1074
  if (state.currentNode?.tagHandler?.isNonNesting) {
1068
- if (tagId !== state.currentNode?.tagId) {
1075
+ if (!tagName || tagId !== state.currentNode?.tagId) {
1069
1076
  textBuffer += htmlChunk[i++];
1070
1077
  continue;
1071
1078
  }
1072
1079
  }
1080
+ if (!tagName) {
1081
+ textBuffer += htmlChunk[i++];
1082
+ continue;
1083
+ }
1073
1084
  if (textBuffer.length > 0) {
1074
1085
  processTextBuffer(textBuffer, state, handleEvent);
1075
1086
  textBuffer = "";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mdream/js",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.12",
4
+ "version": "1.0.0-beta.14",
5
5
  "description": "JavaScript HTML-to-Markdown engine for mdream. Escape hatch for hooks and edge runtimes.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",