🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@marbec/web-auto-extractor

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marbec/web-auto-extractor - npm Package Compare versions

Comparing version
2.2.0
to
2.2.1
+4
renovate.json
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"]
}
+7
-0

@@ -0,1 +1,8 @@

## [2.2.1](https://github.com/herzog31/web-auto-extractor/compare/v2.2.0...v2.2.1) (2025-09-24)
### Bug Fixes
* Return error if parsed JSON is null ([#32](https://github.com/herzog31/web-auto-extractor/issues/32)) ([594f45f](https://github.com/herzog31/web-auto-extractor/commit/594f45f37c0af419f4544ee5efa5c84bc4746bc7))
# [2.2.0](https://github.com/herzog31/web-auto-extractor/compare/v2.1.1...v2.2.0) (2025-07-31)

@@ -2,0 +9,0 @@

+72
-20

@@ -337,2 +337,3 @@ class $5ebcfe677f0c94e7$export$ba54da76d8425a81 {

this.textForProp = null;
this.currentVocab = null;
this.parser = new (0, $5ebcfe677f0c94e7$export$ba54da76d8425a81)();

@@ -419,4 +420,17 @@ const { TYPE: TYPE, PROP: PROP, ID_PROPS: ID_PROPS } = this.#getAttrNames(specName);

const { context: context, type: type } = this.#getType(attribs[this.TYPE]);
const vocab = attribs.vocab;
currentScope['@context'] = context || vocab;
let finalContext;
if (this.specName === 'rdfa') {
const vocab = attribs.vocab;
if (vocab) this.currentVocab = vocab;
finalContext = context || vocab || this.currentVocab;
} else finalContext = context;
if (!finalContext) this.errors.push({
message: `${this.specName} itemtype missing valid context`,
format: this.specName,
sourceCodeLocation: sourceCodeLocation,
source: this.html.slice(sourceCodeLocation.startOffset, sourceCodeLocation.endOffset)
});
if (this.specName === 'rdfa') {
if (context || attribs.vocab) currentScope['@context'] = finalContext;
} else if (finalContext) currentScope['@context'] = finalContext;
currentScope['@type'] = type;

@@ -528,2 +542,4 @@ if ($fcd225f798e28078$var$typesWithId.includes(type)) {

const parsed = JSON.parse(text);
// Check if parsed is null
if (!parsed) throw new Error('JSON-LD is null');
// Adjust offsets by removing leading and trailing whitespace

@@ -567,3 +583,10 @@ let startOffset = sourceCodeLocation.startOffset;

}
this.errors.push({
const isEmptyJson = Object.keys(source).length === 0;
if (isEmptyJson) this.errors.push({
message: 'JSON-LD object is empty',
format: 'jsonld',
sourceCodeLocation: sourceCodeLocation,
source: JSON.stringify(source)
});
else this.errors.push({
message: 'JSON-LD object missing @type attribute',

@@ -575,2 +598,19 @@ format: 'jsonld',

}
#errorMissingContext(item) {
const sourceCodeLocation = {};
const source = {
...item
};
if (item['@location']) {
sourceCodeLocation.startOffset = parseInt(item['@location'].split(',')[0]);
sourceCodeLocation.endOffset = parseInt(item['@location'].split(',')[1]);
delete source['@location'];
}
this.errors.push({
message: 'JSON-LD object missing @context attribute',
format: 'jsonld',
sourceCodeLocation: sourceCodeLocation,
source: JSON.stringify(source)
});
}
#normalizeJsonldData() {

@@ -583,20 +623,32 @@ const normalizedData = {};

item.forEach((item)=>{
if (item['@graph']) item['@graph'].forEach((graphItem)=>{
// Move location and scope down to new root items
if (item['@location']) graphItem['@location'] = item['@location'];
if (item['@source']) graphItem['@source'] = item['@source'];
if (!graphItem['@type']) {
this.#errorMissingType(graphItem);
return;
}
if (Array.isArray(graphItem['@type'])) graphItem['@type'].forEach((type)=>{
normalizedData[type] = normalizedData[type] || [];
normalizedData[type].push(graphItem);
if (item['@graph']) {
let context = item['@context'];
let checkContext = true;
if (!context) this.#errorMissingContext(item);
else checkContext = false;
item['@graph'].forEach((graphItem)=>{
// Move location and scope down to new root items
if (item['@location']) graphItem['@location'] = item['@location'];
if (item['@source']) graphItem['@source'] = item['@source'];
if (checkContext) {
if (context && !graphItem['@context']) graphItem['@context'] = context;
else if (!context) {
if (graphItem['@context']) context = graphItem['@context'];
else this.#errorMissingContext(graphItem);
}
}
if (!graphItem['@type']) {
this.#errorMissingType(graphItem);
return;
}
if (Array.isArray(graphItem['@type'])) graphItem['@type'].forEach((type)=>{
normalizedData[type] = normalizedData[type] || [];
normalizedData[type].push(graphItem);
});
else {
normalizedData[graphItem['@type']] = normalizedData[graphItem['@type']] || [];
normalizedData[graphItem['@type']].push(graphItem);
}
});
else {
normalizedData[graphItem['@type']] = normalizedData[graphItem['@type']] || [];
normalizedData[graphItem['@type']].push(graphItem);
}
});
else {
} else {
if (!item['@type']) {

@@ -603,0 +655,0 @@ this.#errorMissingType(item);

@@ -1,1 +0,1 @@

{"mappings":"AEAO,MAAM;IACX,aAAc;QACZ,IAAI,CAAC,OAAO,GAAG,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,iBAAiB,GAAG;QACzB,IAAI,CAAC,eAAe,GAAG;QAEvB,2DAA2D;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI;YAC3B;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;IACH;IAEA,CAAA,IAAK,CAAC,KAAK,EAAE,GAAG,IAAI;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EACtB,OAAO;QAET,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAY,WAAW;QACpD,OAAO;IACT;IAEA,CAAA,YAAa,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG;QACnD,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,iBAAiB,GAAG;QACzB,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,CAAA,IAAK,CAAC,YAAY;qBACrB;mBACA;yBACA;YACA,oBAAoB;gBAClB,aAAa;gBACb,WAAW;YACb;QACF;IACF;IAEA,CAAA,UAAW,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG;QAC7B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EACZ,KAAK;QACP,MAAM,UAAE,MAAM,EAAE,QAAQ,YAAY,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAW,EACtD,MACA,IAAI,CAAC,OAAO,EACZ,KAAK;QACP,MAAM,YAAE,QAAQ,EAAE,QAAQ,aAAa,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAY,EAC1D,MACA,IAAI,CAAC,OAAO,EACZ,KAAK;QAEP,OAAO;sBACL;uBACA;kBACA;oBACA;sBACA;YACA,QAAQ;mBACH;mBACA;mBACA;mBACA;mBACA;aACJ;QACH;IACF;AACF;IAEA,2CAAe","sources":["src/index.js","src/parsers/metatag-parser.js","src/parsers/html-sax-parser.js","src/parsers/microdata-rdfa-parser.js","src/parsers/jsonld-parser.js","src/parsers/heading-parser.js"],"sourcesContent":["import MetaTagsParser from './parsers/metatag-parser.js';\nimport MicroRdfaParser from './parsers/microdata-rdfa-parser.js';\nimport JsonldParser from './parsers/jsonld-parser.js';\nimport HeadingParser from './parsers/heading-parser.js';\n\nclass WebAutoExtractor {\n constructor(options = {}) {\n this.options = {\n // Add location information to the parsed data in the @location property as comma separated start and end values\n addLocation: false,\n // Embed the source HTML in the parsed data in the @source property. Either boolean or list of data types\n embedSource: false,\n ...options,\n };\n }\n\n parse(html) {\n const { metatags, errors: metatagErrors } = MetaTagsParser(html);\n const { data: microdata, errors: microdataErrors } = new MicroRdfaParser(\n html,\n 'microdata',\n this.options,\n ).parse();\n const { data: rdfa, errors: rdfaErrors } = new MicroRdfaParser(\n html,\n 'rdfa',\n this.options,\n ).parse();\n const { jsonld, errors: jsonldErrors } = new JsonldParser(\n html,\n this.options,\n ).parse();\n const { headings, errors: headingErrors } = new HeadingParser(\n html,\n this.options,\n ).parse();\n\n return {\n metatags,\n microdata,\n rdfa,\n jsonld,\n headings,\n errors: [\n ...metatagErrors,\n ...microdataErrors,\n ...rdfaErrors,\n ...jsonldErrors,\n ...headingErrors,\n ],\n };\n }\n}\n\nexport default WebAutoExtractor;\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default (html) => {\n const metatags = {};\n const errors = [];\n let currentTitle = null;\n let inHead = false;\n\n const parser = new HTMLSAXParser();\n\n parser.on('startTag', ({ tagName, attrs, sourceCodeLocation }) => {\n if (tagName === 'head') {\n inHead = true;\n } else if (tagName === 'meta' && inHead) {\n // Convert attrs array to object for easier access\n const attribs = attrs.reduce((acc, current) => {\n acc[current.name] = current.value;\n return acc;\n }, {});\n\n // Find the name key (name, property, itemprop, or http-equiv)\n const nameKey = Object.keys(attribs).find(\n (attr) =>\n ['name', 'property', 'itemprop', 'http-equiv'].indexOf(attr) !== -1,\n );\n\n if (!nameKey) return;\n\n const name = attribs[nameKey];\n const value = attribs['content'];\n\n if (value !== undefined) {\n if (!metatags[name]) {\n metatags[name] = [];\n }\n\n metatags[name].push(value);\n } else {\n errors.push({\n message: `Meta tag \"${name}\" has no content`,\n format: 'metatags',\n sourceCodeLocation,\n });\n }\n } else if (tagName === 'title' && inHead) {\n currentTitle = '';\n }\n });\n\n parser.on('text', ({ text }) => {\n if (currentTitle !== null) {\n currentTitle += text;\n }\n });\n\n parser.on('endTag', ({ tagName }) => {\n if (tagName === 'head') {\n inHead = false;\n } else if (tagName === 'title' && inHead) {\n if (!metatags.title) {\n metatags.title = [];\n }\n metatags.title.push(currentTitle.trim());\n currentTitle = null;\n }\n });\n\n parser.end(html);\n\n return { metatags: metatags, errors };\n};\n","export class HTMLSAXParser {\n constructor() {\n this._events = {};\n this._buffer = '';\n this._currentTagStartPos = 0;\n this._currentTagEndPos = 0;\n this._lastTextEndPos = 0;\n\n // List of known void elements (self-closing tags) in HTML5\n this._voidElements = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n 'command',\n 'keygen',\n 'menuitem',\n 'frame',\n ]);\n }\n\n #emit(event, ...args) {\n if (!this._events[event]) {\n return false;\n }\n this._events[event].forEach((handler) => handler(...args));\n return true;\n }\n\n #emitStartTag(tagName, attrs, selfClosing, start, end) {\n this._currentTagStartPos = start;\n this._currentTagEndPos = end;\n this._lastTextEndPos = end;\n this.#emit('startTag', {\n tagName,\n attrs,\n selfClosing,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n #emitEndTag(tagName, start, end) {\n this._currentTagStartPos = start;\n this._currentTagEndPos = end;\n this._lastTextEndPos = end;\n this.#emit('endTag', {\n tagName,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n #parse(html) {\n this._buffer = html;\n let pos = 0;\n let textStart = 0;\n let inTag = false;\n let inScript = false;\n let scriptStart = 0;\n let inComment = false;\n\n while (pos < html.length) {\n if (inScript) {\n // Look for </script> while in script mode, but only at a tag boundary\n if (\n html[pos] === '<' &&\n html.slice(pos, pos + 9).toLowerCase() === '</script>'\n ) {\n // Found the end of script\n const scriptEnd = pos;\n // Emit the accumulated script content\n const content = html.slice(scriptStart, scriptEnd).trim();\n if (content) {\n this.#emit('text', {\n text: content,\n sourceCodeLocation: {\n startOffset: scriptStart,\n endOffset: scriptEnd,\n },\n });\n }\n pos += 9; // Skip past </script>\n textStart = pos;\n inScript = false;\n // Emit the end tag\n this.#emitEndTag('script', scriptEnd, pos);\n continue;\n }\n pos++;\n continue;\n }\n\n if (inComment) {\n // Look for --> while in comment mode, but handle nested comment-like structures\n if (\n html[pos] === '-' &&\n pos + 2 < html.length &&\n html.slice(pos, pos + 3) === '-->'\n ) {\n // End of comment\n inComment = false;\n pos += 3;\n textStart = pos;\n continue;\n }\n pos++;\n continue;\n }\n\n if (html[pos] === '<') {\n // Check for comments\n if (pos + 3 < html.length && html.slice(pos, pos + 4) === '<!--') {\n inComment = true;\n pos += 4;\n continue;\n }\n\n // Check for DOCTYPE\n if (\n pos + 8 < html.length &&\n html.slice(pos, pos + 9).toUpperCase() === '<!DOCTYPE'\n ) {\n // Skip DOCTYPE declaration\n while (pos < html.length && html[pos] !== '>') {\n pos++;\n }\n if (pos < html.length) pos++; // Skip the closing '>'\n continue;\n }\n\n // Handle any text content before this tag\n if (!inTag && pos > textStart) {\n const text = html.slice(textStart, pos);\n if (text.trim()) {\n this.#handleText(text, textStart, pos);\n }\n }\n inTag = true;\n const tagStart = pos;\n pos++;\n\n // Check if it's an end tag\n const isEndTag = html[pos] === '/';\n if (isEndTag) pos++;\n\n // Get tag name\n let tagName = '';\n while (pos < html.length && /[a-zA-Z0-9]/.test(html[pos])) {\n tagName += html[pos];\n pos++;\n }\n\n // Parse attributes\n const attrs = [];\n let attrName = '';\n let attrValue = '';\n let inAttr = false;\n let inValue = false;\n let quote = '';\n\n while (pos < html.length && html[pos] !== '>') {\n const char = html[pos];\n\n if (!inAttr && /[a-zA-Z]/.test(char)) {\n inAttr = true;\n attrName = char;\n } else if (inAttr && !inValue && char === '=') {\n inValue = true;\n pos++; // Skip the equals sign\n // Skip any whitespace after the equals sign\n while (pos < html.length && /\\s/.test(html[pos])) {\n pos++;\n }\n continue;\n } else if (inAttr && !inValue && /\\s/.test(char)) {\n attrs.push({ name: attrName, value: '' });\n inAttr = false;\n attrName = '';\n } else if (\n inValue &&\n (char === '\"' || char === \"'\" || char === '`')\n ) {\n if (!quote) {\n quote = char;\n } else if (char === quote && html[pos - 1] !== '\\\\') {\n // Only treat quote as closing if it's not escaped\n attrs.push({ name: attrName, value: attrValue });\n inAttr = false;\n inValue = false;\n attrName = '';\n attrValue = '';\n quote = '';\n } else {\n attrValue += char;\n }\n } else if (inAttr && !inValue) {\n attrName += char;\n } else if (inValue && quote) {\n if (\n char === '\\\\' &&\n pos + 1 < html.length &&\n html[pos + 1] === quote\n ) {\n // Handle escaped quotes in attribute values\n attrValue += quote;\n pos++; // Skip the escape character\n } else {\n attrValue += char;\n }\n } else if (inValue && !quote) {\n // Handle unquoted attribute values\n if (/[\\s>]/.test(char)) {\n attrs.push({ name: attrName, value: attrValue });\n inAttr = false;\n inValue = false;\n attrName = '';\n attrValue = '';\n if (char === '>') {\n pos--; // Back up one character to handle the '>' in the next iteration\n break;\n }\n } else {\n attrValue += char;\n }\n }\n\n pos++;\n }\n\n // Handle any remaining attribute\n if (inAttr) {\n if (inValue) {\n attrs.push({ name: attrName, value: attrValue });\n } else {\n attrs.push({ name: attrName, value: '' });\n }\n }\n\n // Skip the closing '>'\n pos++;\n inTag = false;\n textStart = pos;\n\n // Handle the tag\n if (isEndTag) {\n this.#emitEndTag(tagName, tagStart, pos);\n } else {\n // Check if it's a self-closing tag either by explicit /> notation\n // or by being a known void element\n const hasExplicitSelfClosing = html[pos - 2] === '/';\n const isVoidElement = this._voidElements.has(tagName.toLowerCase());\n const selfClosing = hasExplicitSelfClosing || isVoidElement;\n\n if (\n tagName.toLowerCase() === 'script' &&\n attrs.find(\n (attr) =>\n attr.name === 'type' && attr.value === 'application/ld+json',\n )\n ) {\n inScript = true;\n scriptStart = pos; // Start collecting content after the opening script tag\n }\n // For self-closing tags, include the '/' and '>' in the end offset\n const endPos = pos;\n this.#emitStartTag(tagName, attrs, selfClosing, tagStart, endPos);\n // Update textStart to be after the tag\n textStart = pos;\n }\n } else {\n pos++;\n }\n }\n\n // Handle any remaining text\n if (pos > textStart) {\n const text = html.slice(textStart, pos);\n if (text.trim()) {\n this.#handleText(text, textStart, pos);\n }\n }\n }\n\n #handleText(text, start, end) {\n if (text.trim() === '') {\n return;\n }\n\n this.#emit('text', {\n text,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n on(event, handler) {\n if (!this._events[event]) {\n this._events[event] = [];\n }\n this._events[event].push(handler);\n return this;\n }\n\n end(html) {\n this.#parse(html);\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nconst typesWithId = [\n 'Thing',\n 'WebPage',\n 'Place',\n 'Organization',\n 'Person',\n 'Event',\n 'Product',\n];\n\nexport default class MicroRdfaParser {\n constructor(html, specName, options = {}) {\n this.html = html;\n this.specName = specName.toLowerCase();\n this.options = options;\n\n this.errors = [];\n\n this.scopes = [];\n this.tags = [];\n this.topLevelScope = {};\n this.textForProp = null;\n this.parser = new HTMLSAXParser();\n\n const { TYPE, PROP, ID_PROPS } = this.#getAttrNames(specName);\n this.TYPE = TYPE;\n this.PROP = PROP;\n this.ID_PROPS = ID_PROPS;\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n }\n\n #getAttrNames(specName) {\n let TYPE, PROP, ID_PROPS;\n if (specName === 'microdata') {\n TYPE = 'itemtype';\n PROP = 'itemprop';\n ID_PROPS = ['href', 'itemid'];\n } else if (specName === 'rdfa') {\n TYPE = 'typeof';\n PROP = 'property';\n ID_PROPS = ['about', 'href', 'resource'];\n } else {\n throw new Error('Unsupported spec: use either microdata or rdfa');\n }\n return { TYPE, PROP, ID_PROPS };\n }\n\n #getType(typeString) {\n const match = /(.*\\/)(\\w+)/g.exec(typeString);\n return {\n context: match && match[1] ? match[1] : undefined,\n type: match && match[2] ? match[2] : typeString,\n };\n }\n\n #getPropValue(tagName, selfClosing, attribs) {\n if (attribs[this.TYPE]) {\n return null;\n } else if (tagName === 'a' && attribs.href) {\n return attribs.href.trim();\n } else if (selfClosing) {\n const properties = ['src', 'content', 'href', 'resource'];\n const key = properties.find((property) => attribs[property]);\n if (key && attribs[key]) {\n return attribs[key].trim();\n } else {\n throw new Error(`No value found for ${tagName} tag`);\n }\n } else if (attribs.content) {\n return attribs.content.trim();\n } else {\n return null;\n }\n }\n\n #onOpenTag({ tagName, attrs, selfClosing, sourceCodeLocation }) {\n const attribs = attrs.reduce((acc, current) => {\n acc[current.name] = current.value;\n return acc;\n }, {});\n\n let currentScope = this.scopes[this.scopes.length - 1];\n let tag = false;\n\n if (attribs[this.TYPE]) {\n if (attribs[this.PROP] && currentScope) {\n let newScope = {};\n currentScope[attribs[this.PROP]] =\n currentScope[attribs[this.PROP]] || [];\n currentScope[attribs[this.PROP]].push(newScope);\n currentScope = newScope;\n } else {\n currentScope = {};\n const { type } = this.#getType(attribs[this.TYPE]);\n this.topLevelScope[type] = this.topLevelScope[type] || [];\n this.topLevelScope[type].push(currentScope);\n\n // Only add location and source to top level scope, ignore the option for now as the values are needed for @source\n currentScope['@location'] = sourceCodeLocation.startOffset;\n }\n }\n\n if (currentScope) {\n if (attribs[this.TYPE]) {\n const { context, type } = this.#getType(attribs[this.TYPE]);\n const vocab = attribs.vocab;\n currentScope['@context'] = context || vocab;\n currentScope['@type'] = type;\n\n if (typesWithId.includes(type)) {\n const id = this.ID_PROPS.find((prop) => attribs[prop]);\n if (id) {\n currentScope['@id'] = attribs[id];\n }\n }\n tag = this.TYPE;\n this.scopes.push(currentScope);\n } else if (attribs[this.PROP]) {\n if (\n currentScope[attribs[this.PROP]] &&\n !Array.isArray(currentScope[attribs[this.PROP]])\n ) {\n currentScope[attribs[this.PROP]] = [currentScope[attribs[this.PROP]]];\n }\n\n let value = null;\n try {\n value = this.#getPropValue(tagName, selfClosing, attribs);\n } catch (error) {\n this.errors.push({\n message: error.message,\n format: this.specName,\n sourceCodeLocation,\n source: this.html.slice(\n sourceCodeLocation.startOffset,\n sourceCodeLocation.endOffset,\n ),\n });\n }\n if (!value) {\n tag = this.PROP;\n if (Array.isArray(currentScope[attribs[this.PROP]])) {\n currentScope[attribs[this.PROP]].push('');\n } else {\n currentScope[attribs[this.PROP]] = '';\n }\n this.textForProp = attribs[this.PROP];\n } else {\n if (Array.isArray(currentScope[attribs[this.PROP]])) {\n currentScope[attribs[this.PROP]].push(value);\n } else {\n currentScope[attribs[this.PROP]] = value;\n }\n }\n }\n }\n if (!selfClosing) {\n this.tags.push(tag);\n }\n }\n\n #onText({ text }) {\n if (this.textForProp) {\n if (\n Array.isArray(this.scopes[this.scopes.length - 1][this.textForProp])\n ) {\n this.scopes[this.scopes.length - 1][this.textForProp][\n this.scopes[this.scopes.length - 1][this.textForProp].length - 1\n ] += text.trim();\n } else {\n this.scopes[this.scopes.length - 1][this.textForProp] += text.trim();\n }\n }\n }\n\n #onCloseTag({ sourceCodeLocation }) {\n const tag = this.tags.pop();\n if (tag === this.TYPE) {\n let scope = this.scopes.pop();\n\n if (\n (this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))) &&\n '@location' in scope\n ) {\n scope['@source'] = this.html.slice(\n scope['@location'],\n sourceCodeLocation.endOffset,\n );\n }\n if (this.options.addLocation && '@location' in scope) {\n scope['@location'] =\n `${scope['@location']},${sourceCodeLocation.endOffset}`;\n } else if (!this.options.addLocation && '@location' in scope) {\n delete scope['@location'];\n }\n\n if (!scope['@context']) {\n delete scope['@context'];\n }\n Object.keys(scope).forEach((key) => {\n if (Array.isArray(scope[key]) && scope[key].length === 1) {\n scope[key] = scope[key][0];\n }\n });\n } else if (tag === this.PROP) {\n this.textForProp = false;\n }\n }\n\n #postProcess() {\n this.topLevelScope = this.#processMultiValueProps(this.topLevelScope);\n }\n\n /**\n * Process multi-value properties recursively and split them into individual properties\n */\n #processMultiValueProps(obj) {\n if (Array.isArray(obj)) {\n return obj.map((item) => this.#processMultiValueProps(item));\n } else if (obj && typeof obj === 'object') {\n for (const [key, value] of Object.entries(obj)) {\n if (key.startsWith('@')) {\n continue;\n }\n\n obj[key] = this.#processMultiValueProps(value);\n\n // Split the key by spaces to handle multi-value properties\n const propNames = key.trim().split(/\\s+/);\n\n if (propNames.length > 1) {\n // Multi-value property: assign the same value to each individual property\n for (const propName of propNames) {\n if (propName) {\n obj[propName] = obj[key];\n }\n }\n delete obj[key];\n }\n }\n\n return obj;\n } else {\n return obj;\n }\n }\n\n parse() {\n this.parser.end(this.html);\n this.#postProcess();\n return { data: this.topLevelScope, errors: this.errors };\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default class JsonldParser {\n constructor(html, options = {}) {\n this.html = html;\n this.options = options;\n this.jsonldData = [];\n this.scriptScope = false;\n this.parser = new HTMLSAXParser();\n this.errors = [];\n this.specName = 'jsonld';\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n }\n\n #onOpenTag({ tagName, attrs }) {\n if (\n tagName === 'script' &&\n attrs.find(\n (attr) => attr.name === 'type' && attr.value === 'application/ld+json',\n )\n ) {\n this.scriptScope = true;\n }\n }\n\n #onText({ text, sourceCodeLocation }) {\n if (!this.scriptScope) {\n return;\n }\n\n try {\n const parsed = JSON.parse(text);\n\n // Adjust offsets by removing leading and trailing whitespace\n let startOffset = sourceCodeLocation.startOffset;\n let endOffset = sourceCodeLocation.endOffset;\n const leadingWhitespace = text.match(/^\\s*/)[0].length;\n startOffset += leadingWhitespace;\n const trailingWhitespace = text.match(/\\s*$/)[0].length;\n endOffset -= trailingWhitespace;\n\n // Add script tag location to root items\n if (!Array.isArray(parsed)) {\n if (this.options.addLocation) {\n parsed['@location'] = `${startOffset},${endOffset}`;\n }\n if (\n this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))\n ) {\n parsed['@source'] = this.html.slice(startOffset, endOffset);\n }\n } else {\n parsed.forEach((item) => {\n if (this.options.addLocation) {\n item['@location'] = `${startOffset},${endOffset}`;\n }\n if (\n this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))\n ) {\n item['@source'] = this.html.slice(startOffset, endOffset);\n }\n });\n }\n\n this.jsonldData.push(parsed);\n } catch (e) {\n this.errors.push({\n message: 'Could not parse JSON-LD',\n format: 'jsonld',\n source: text,\n sourceCodeLocation,\n });\n }\n }\n\n #onCloseTag({ tagName }) {\n if (tagName === 'script' && this.scriptScope) {\n this.scriptScope = false;\n }\n }\n\n #errorMissingType(item) {\n const sourceCodeLocation = {};\n const source = { ...item };\n if (item['@location']) {\n sourceCodeLocation.startOffset = parseInt(\n item['@location'].split(',')[0],\n );\n sourceCodeLocation.endOffset = parseInt(item['@location'].split(',')[1]);\n delete source['@location'];\n }\n\n this.errors.push({\n message: 'JSON-LD object missing @type attribute',\n format: 'jsonld',\n sourceCodeLocation,\n source: JSON.stringify(source),\n });\n }\n\n #normalizeJsonldData() {\n const normalizedData = {};\n\n this.jsonldData.forEach((item) => {\n if (!Array.isArray(item)) {\n item = [item];\n }\n\n item.forEach((item) => {\n if (item['@graph']) {\n item['@graph'].forEach((graphItem) => {\n // Move location and scope down to new root items\n if (item['@location']) {\n graphItem['@location'] = item['@location'];\n }\n if (item['@source']) {\n graphItem['@source'] = item['@source'];\n }\n\n if (!graphItem['@type']) {\n this.#errorMissingType(graphItem);\n return;\n }\n\n if (Array.isArray(graphItem['@type'])) {\n graphItem['@type'].forEach((type) => {\n normalizedData[type] = normalizedData[type] || [];\n normalizedData[type].push(graphItem);\n });\n } else {\n normalizedData[graphItem['@type']] =\n normalizedData[graphItem['@type']] || [];\n normalizedData[graphItem['@type']].push(graphItem);\n }\n });\n } else {\n if (!item['@type']) {\n this.#errorMissingType(item);\n return;\n }\n\n if (Array.isArray(item['@type'])) {\n item['@type'].forEach((type) => {\n normalizedData[type] = normalizedData[type] || [];\n normalizedData[type].push(item);\n });\n } else {\n normalizedData[item['@type']] = normalizedData[item['@type']] || [];\n normalizedData[item['@type']].push(item);\n }\n }\n });\n });\n\n return normalizedData;\n }\n\n parse() {\n this.parser.end(this.html);\n return { jsonld: this.#normalizeJsonldData(), errors: this.errors };\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default class HeadingParser {\n constructor(html, options = {}) {\n this.html = html;\n this.options = {\n skipEmptyHeadings: false,\n skipLayoutElements: false,\n ...options,\n };\n\n this.errors = [];\n this.headings = [];\n this.currentHeading = null;\n this.headingText = '';\n this.headingStart = 0;\n this.headingEnd = 0;\n this.layoutStack = [];\n this.isInLayoutElement = false;\n\n this.parser = new HTMLSAXParser();\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n }\n\n #onOpenTag({ tagName, attrs, sourceCodeLocation }) {\n const tag = tagName.toLowerCase();\n\n // Track layout elements\n if (['header', 'footer', 'nav', 'aside'].includes(tag)) {\n this.layoutStack.push(tag);\n this.isInLayoutElement = true;\n }\n\n // Check if this is a heading tag (h1-h6)\n if (/^h[1-6]$/i.test(tag)) {\n this.#startHeading(tag, attrs, sourceCodeLocation);\n }\n }\n\n #onCloseTag({ tagName, sourceCodeLocation }) {\n const tag = tagName.toLowerCase();\n\n // Handle closing layout elements\n if (['header', 'footer', 'nav', 'aside'].includes(tag)) {\n const index = this.layoutStack.lastIndexOf(tag);\n if (index !== -1) {\n this.layoutStack.splice(index, 1);\n this.isInLayoutElement = this.layoutStack.length > 0;\n }\n }\n\n // Check if this is a heading tag (h1-h6)\n if (/^h[1-6]$/i.test(tag)) {\n this.#endHeading(tag, sourceCodeLocation);\n }\n }\n\n #onText({ text }) {\n if (this.currentHeading) {\n this.headingText += text;\n }\n }\n\n #startHeading(tagName, attrs, sourceCodeLocation) {\n const level = parseInt(tagName.charAt(1));\n\n this.currentHeading = {\n tag: tagName.toLowerCase(),\n level: level,\n text: '',\n order: this.headings.length,\n attributes: attrs,\n };\n\n // Only include isLayoutElement field if we're not skipping layout elements\n if (!this.options.skipLayoutElements) {\n this.currentHeading.isLayoutElement = this.isInLayoutElement;\n }\n\n this.headingText = '';\n this.headingStart = sourceCodeLocation.startOffset;\n }\n\n #endHeading(tagName, sourceCodeLocation) {\n if (!this.currentHeading) return;\n if (tagName === this.currentHeading.tag) {\n this.currentHeading.text = this.headingText.trim();\n this.headingEnd = sourceCodeLocation.endOffset;\n\n if (this.options.embedSource) {\n this.currentHeading['@source'] = this.html.slice(\n this.headingStart,\n this.headingEnd,\n );\n }\n\n if (this.options.addLocation) {\n this.currentHeading['@location'] =\n `${this.headingStart},${this.headingEnd}`;\n }\n\n if (this.options.skipLayoutElements && this.isInLayoutElement) {\n // Don't add to headings array\n } else if (\n !this.options.skipEmptyHeadings ||\n this.currentHeading.text.trim() !== ''\n ) {\n this.headings.push(this.currentHeading);\n }\n } else {\n this.errors.push({\n message: 'Heading tags are malformed',\n format: 'headings',\n sourceCodeLocation,\n });\n }\n\n this.currentHeading = null;\n this.headingText = '';\n this.headingStart = 0;\n this.headingEnd = 0;\n }\n\n parse() {\n this.parser.end(this.html);\n\n return {\n headings: this.headings,\n errors: this.errors,\n };\n }\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
{"mappings":"AEAO,MAAM;IACX,aAAc;QACZ,IAAI,CAAC,OAAO,GAAG,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,iBAAiB,GAAG;QACzB,IAAI,CAAC,eAAe,GAAG;QAEvB,2DAA2D;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI;YAC3B;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;IACH;IAEA,CAAA,IAAK,CAAC,KAAK,EAAE,GAAG,IAAI;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EACtB,OAAO;QAET,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAY,WAAW;QACpD,OAAO;IACT;IAEA,CAAA,YAAa,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG;QACnD,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,iBAAiB,GAAG;QACzB,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,CAAA,IAAK,CAAC,YAAY;qBACrB;mBACA;yBACA;YACA,oBAAoB;gBAClB,aAAa;gBACb,WAAW;YACb;QACF;IACF;IAEA,CAAA,UAAW,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG;QAC7B,IAAI,CAAC,mBAAmB,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AAG,OAAO;QACZ;IACF;IAEA,MAAM,IAAI,EAAE;QACV,MAAM,YAAE,QAAQ,EAAE,QAAQ,aAAa,EAAE,GAAG,CAAA,GAAA,wCAAa,EAAE;QAC3D,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,eAAe,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAc,EACrE,MACA,aACA,IAAI,CAAC,OAAO,EACZ,KAAK;QACP,MAAM,EAAE,MAAM,IAAI,EAAE,QAAQ,UAAU,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAc,EAC3D,MACA,QACA,IAAI,CAAC,OAAO,EACZ,KAAK;QACP,MAAM,UAAE,MAAM,EAAE,QAAQ,YAAY,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAW,EACtD,MACA,IAAI,CAAC,OAAO,EACZ,KAAK;QACP,MAAM,YAAE,QAAQ,EAAE,QAAQ,aAAa,EAAE,GAAG,IAAI,CAAA,GAAA,wCAAY,EAC1D,MACA,IAAI,CAAC,OAAO,EACZ,KAAK;QAEP,OAAO;sBACL;uBACA;kBACA;oBACA;sBACA;YACA,QAAQ;mBACH;mBACA;mBACA;mBACA;mBACA;aACJ;QACH;IACF;AACF;IAEA,2CAAe","sources":["src/index.js","src/parsers/metatag-parser.js","src/parsers/html-sax-parser.js","src/parsers/microdata-rdfa-parser.js","src/parsers/jsonld-parser.js","src/parsers/heading-parser.js"],"sourcesContent":["import MetaTagsParser from './parsers/metatag-parser.js';\nimport MicroRdfaParser from './parsers/microdata-rdfa-parser.js';\nimport JsonldParser from './parsers/jsonld-parser.js';\nimport HeadingParser from './parsers/heading-parser.js';\n\nclass WebAutoExtractor {\n constructor(options = {}) {\n this.options = {\n // Add location information to the parsed data in the @location property as comma separated start and end values\n addLocation: false,\n // Embed the source HTML in the parsed data in the @source property. Either boolean or list of data types\n embedSource: false,\n ...options,\n };\n }\n\n parse(html) {\n const { metatags, errors: metatagErrors } = MetaTagsParser(html);\n const { data: microdata, errors: microdataErrors } = new MicroRdfaParser(\n html,\n 'microdata',\n this.options,\n ).parse();\n const { data: rdfa, errors: rdfaErrors } = new MicroRdfaParser(\n html,\n 'rdfa',\n this.options,\n ).parse();\n const { jsonld, errors: jsonldErrors } = new JsonldParser(\n html,\n this.options,\n ).parse();\n const { headings, errors: headingErrors } = new HeadingParser(\n html,\n this.options,\n ).parse();\n\n return {\n metatags,\n microdata,\n rdfa,\n jsonld,\n headings,\n errors: [\n ...metatagErrors,\n ...microdataErrors,\n ...rdfaErrors,\n ...jsonldErrors,\n ...headingErrors,\n ],\n };\n }\n}\n\nexport default WebAutoExtractor;\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default (html) => {\n const metatags = {};\n const errors = [];\n let currentTitle = null;\n let inHead = false;\n\n const parser = new HTMLSAXParser();\n\n parser.on('startTag', ({ tagName, attrs, sourceCodeLocation }) => {\n if (tagName === 'head') {\n inHead = true;\n } else if (tagName === 'meta' && inHead) {\n // Convert attrs array to object for easier access\n const attribs = attrs.reduce((acc, current) => {\n acc[current.name] = current.value;\n return acc;\n }, {});\n\n // Find the name key (name, property, itemprop, or http-equiv)\n const nameKey = Object.keys(attribs).find(\n (attr) =>\n ['name', 'property', 'itemprop', 'http-equiv'].indexOf(attr) !== -1,\n );\n\n if (!nameKey) return;\n\n const name = attribs[nameKey];\n const value = attribs['content'];\n\n if (value !== undefined) {\n if (!metatags[name]) {\n metatags[name] = [];\n }\n\n metatags[name].push(value);\n } else {\n errors.push({\n message: `Meta tag \"${name}\" has no content`,\n format: 'metatags',\n sourceCodeLocation,\n });\n }\n } else if (tagName === 'title' && inHead) {\n currentTitle = '';\n }\n });\n\n parser.on('text', ({ text }) => {\n if (currentTitle !== null) {\n currentTitle += text;\n }\n });\n\n parser.on('endTag', ({ tagName }) => {\n if (tagName === 'head') {\n inHead = false;\n } else if (tagName === 'title' && inHead) {\n if (!metatags.title) {\n metatags.title = [];\n }\n metatags.title.push(currentTitle.trim());\n currentTitle = null;\n }\n });\n\n parser.end(html);\n\n return { metatags: metatags, errors };\n};\n","export class HTMLSAXParser {\n constructor() {\n this._events = {};\n this._buffer = '';\n this._currentTagStartPos = 0;\n this._currentTagEndPos = 0;\n this._lastTextEndPos = 0;\n\n // List of known void elements (self-closing tags) in HTML5\n this._voidElements = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n 'command',\n 'keygen',\n 'menuitem',\n 'frame',\n ]);\n }\n\n #emit(event, ...args) {\n if (!this._events[event]) {\n return false;\n }\n this._events[event].forEach((handler) => handler(...args));\n return true;\n }\n\n #emitStartTag(tagName, attrs, selfClosing, start, end) {\n this._currentTagStartPos = start;\n this._currentTagEndPos = end;\n this._lastTextEndPos = end;\n this.#emit('startTag', {\n tagName,\n attrs,\n selfClosing,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n #emitEndTag(tagName, start, end) {\n this._currentTagStartPos = start;\n this._currentTagEndPos = end;\n this._lastTextEndPos = end;\n this.#emit('endTag', {\n tagName,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n #parse(html) {\n this._buffer = html;\n let pos = 0;\n let textStart = 0;\n let inTag = false;\n let inScript = false;\n let scriptStart = 0;\n let inComment = false;\n\n while (pos < html.length) {\n if (inScript) {\n // Look for </script> while in script mode, but only at a tag boundary\n if (\n html[pos] === '<' &&\n html.slice(pos, pos + 9).toLowerCase() === '</script>'\n ) {\n // Found the end of script\n const scriptEnd = pos;\n // Emit the accumulated script content\n const content = html.slice(scriptStart, scriptEnd).trim();\n if (content) {\n this.#emit('text', {\n text: content,\n sourceCodeLocation: {\n startOffset: scriptStart,\n endOffset: scriptEnd,\n },\n });\n }\n pos += 9; // Skip past </script>\n textStart = pos;\n inScript = false;\n // Emit the end tag\n this.#emitEndTag('script', scriptEnd, pos);\n continue;\n }\n pos++;\n continue;\n }\n\n if (inComment) {\n // Look for --> while in comment mode, but handle nested comment-like structures\n if (\n html[pos] === '-' &&\n pos + 2 < html.length &&\n html.slice(pos, pos + 3) === '-->'\n ) {\n // End of comment\n inComment = false;\n pos += 3;\n textStart = pos;\n continue;\n }\n pos++;\n continue;\n }\n\n if (html[pos] === '<') {\n // Check for comments\n if (pos + 3 < html.length && html.slice(pos, pos + 4) === '<!--') {\n inComment = true;\n pos += 4;\n continue;\n }\n\n // Check for DOCTYPE\n if (\n pos + 8 < html.length &&\n html.slice(pos, pos + 9).toUpperCase() === '<!DOCTYPE'\n ) {\n // Skip DOCTYPE declaration\n while (pos < html.length && html[pos] !== '>') {\n pos++;\n }\n if (pos < html.length) pos++; // Skip the closing '>'\n continue;\n }\n\n // Handle any text content before this tag\n if (!inTag && pos > textStart) {\n const text = html.slice(textStart, pos);\n if (text.trim()) {\n this.#handleText(text, textStart, pos);\n }\n }\n inTag = true;\n const tagStart = pos;\n pos++;\n\n // Check if it's an end tag\n const isEndTag = html[pos] === '/';\n if (isEndTag) pos++;\n\n // Get tag name\n let tagName = '';\n while (pos < html.length && /[a-zA-Z0-9]/.test(html[pos])) {\n tagName += html[pos];\n pos++;\n }\n\n // Parse attributes\n const attrs = [];\n let attrName = '';\n let attrValue = '';\n let inAttr = false;\n let inValue = false;\n let quote = '';\n\n while (pos < html.length && html[pos] !== '>') {\n const char = html[pos];\n\n if (!inAttr && /[a-zA-Z]/.test(char)) {\n inAttr = true;\n attrName = char;\n } else if (inAttr && !inValue && char === '=') {\n inValue = true;\n pos++; // Skip the equals sign\n // Skip any whitespace after the equals sign\n while (pos < html.length && /\\s/.test(html[pos])) {\n pos++;\n }\n continue;\n } else if (inAttr && !inValue && /\\s/.test(char)) {\n attrs.push({ name: attrName, value: '' });\n inAttr = false;\n attrName = '';\n } else if (\n inValue &&\n (char === '\"' || char === \"'\" || char === '`')\n ) {\n if (!quote) {\n quote = char;\n } else if (char === quote && html[pos - 1] !== '\\\\') {\n // Only treat quote as closing if it's not escaped\n attrs.push({ name: attrName, value: attrValue });\n inAttr = false;\n inValue = false;\n attrName = '';\n attrValue = '';\n quote = '';\n } else {\n attrValue += char;\n }\n } else if (inAttr && !inValue) {\n attrName += char;\n } else if (inValue && quote) {\n if (\n char === '\\\\' &&\n pos + 1 < html.length &&\n html[pos + 1] === quote\n ) {\n // Handle escaped quotes in attribute values\n attrValue += quote;\n pos++; // Skip the escape character\n } else {\n attrValue += char;\n }\n } else if (inValue && !quote) {\n // Handle unquoted attribute values\n if (/[\\s>]/.test(char)) {\n attrs.push({ name: attrName, value: attrValue });\n inAttr = false;\n inValue = false;\n attrName = '';\n attrValue = '';\n if (char === '>') {\n pos--; // Back up one character to handle the '>' in the next iteration\n break;\n }\n } else {\n attrValue += char;\n }\n }\n\n pos++;\n }\n\n // Handle any remaining attribute\n if (inAttr) {\n if (inValue) {\n attrs.push({ name: attrName, value: attrValue });\n } else {\n attrs.push({ name: attrName, value: '' });\n }\n }\n\n // Skip the closing '>'\n pos++;\n inTag = false;\n textStart = pos;\n\n // Handle the tag\n if (isEndTag) {\n this.#emitEndTag(tagName, tagStart, pos);\n } else {\n // Check if it's a self-closing tag either by explicit /> notation\n // or by being a known void element\n const hasExplicitSelfClosing = html[pos - 2] === '/';\n const isVoidElement = this._voidElements.has(tagName.toLowerCase());\n const selfClosing = hasExplicitSelfClosing || isVoidElement;\n\n if (\n tagName.toLowerCase() === 'script' &&\n attrs.find(\n (attr) =>\n attr.name === 'type' && attr.value === 'application/ld+json',\n )\n ) {\n inScript = true;\n scriptStart = pos; // Start collecting content after the opening script tag\n }\n // For self-closing tags, include the '/' and '>' in the end offset\n const endPos = pos;\n this.#emitStartTag(tagName, attrs, selfClosing, tagStart, endPos);\n // Update textStart to be after the tag\n textStart = pos;\n }\n } else {\n pos++;\n }\n }\n\n // Handle any remaining text\n if (pos > textStart) {\n const text = html.slice(textStart, pos);\n if (text.trim()) {\n this.#handleText(text, textStart, pos);\n }\n }\n }\n\n #handleText(text, start, end) {\n if (text.trim() === '') {\n return;\n }\n\n this.#emit('text', {\n text,\n sourceCodeLocation: {\n startOffset: start,\n endOffset: end,\n },\n });\n }\n\n on(event, handler) {\n if (!this._events[event]) {\n this._events[event] = [];\n }\n this._events[event].push(handler);\n return this;\n }\n\n end(html) {\n this.#parse(html);\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nconst typesWithId = [\n 'Thing',\n 'WebPage',\n 'Place',\n 'Organization',\n 'Person',\n 'Event',\n 'Product',\n];\n\nexport default class MicroRdfaParser {\n constructor(html, specName, options = {}) {\n this.html = html;\n this.specName = specName.toLowerCase();\n this.options = options;\n\n this.errors = [];\n\n this.scopes = [];\n this.tags = [];\n this.topLevelScope = {};\n this.textForProp = null;\n this.currentVocab = null;\n this.parser = new HTMLSAXParser();\n\n const { TYPE, PROP, ID_PROPS } = this.#getAttrNames(specName);\n this.TYPE = TYPE;\n this.PROP = PROP;\n this.ID_PROPS = ID_PROPS;\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n }\n\n #getAttrNames(specName) {\n let TYPE, PROP, ID_PROPS;\n if (specName === 'microdata') {\n TYPE = 'itemtype';\n PROP = 'itemprop';\n ID_PROPS = ['href', 'itemid'];\n } else if (specName === 'rdfa') {\n TYPE = 'typeof';\n PROP = 'property';\n ID_PROPS = ['about', 'href', 'resource'];\n } else {\n throw new Error('Unsupported spec: use either microdata or rdfa');\n }\n return { TYPE, PROP, ID_PROPS };\n }\n\n #getType(typeString) {\n const match = /(.*\\/)(\\w+)/g.exec(typeString);\n return {\n context: match && match[1] ? match[1] : undefined,\n type: match && match[2] ? match[2] : typeString,\n };\n }\n\n #getPropValue(tagName, selfClosing, attribs) {\n if (attribs[this.TYPE]) {\n return null;\n } else if (tagName === 'a' && attribs.href) {\n return attribs.href.trim();\n } else if (selfClosing) {\n const properties = ['src', 'content', 'href', 'resource'];\n const key = properties.find((property) => attribs[property]);\n if (key && attribs[key]) {\n return attribs[key].trim();\n } else {\n throw new Error(`No value found for ${tagName} tag`);\n }\n } else if (attribs.content) {\n return attribs.content.trim();\n } else {\n return null;\n }\n }\n\n #onOpenTag({ tagName, attrs, selfClosing, sourceCodeLocation }) {\n const attribs = attrs.reduce((acc, current) => {\n acc[current.name] = current.value;\n return acc;\n }, {});\n\n let currentScope = this.scopes[this.scopes.length - 1];\n let tag = false;\n\n if (attribs[this.TYPE]) {\n if (attribs[this.PROP] && currentScope) {\n let newScope = {};\n currentScope[attribs[this.PROP]] =\n currentScope[attribs[this.PROP]] || [];\n currentScope[attribs[this.PROP]].push(newScope);\n currentScope = newScope;\n } else {\n currentScope = {};\n const { type } = this.#getType(attribs[this.TYPE]);\n this.topLevelScope[type] = this.topLevelScope[type] || [];\n this.topLevelScope[type].push(currentScope);\n\n // Only add location and source to top level scope, ignore the option for now as the values are needed for @source\n currentScope['@location'] = sourceCodeLocation.startOffset;\n }\n }\n\n if (currentScope) {\n if (attribs[this.TYPE]) {\n const { context, type } = this.#getType(attribs[this.TYPE]);\n let finalContext;\n if (this.specName === 'rdfa') {\n const vocab = attribs.vocab;\n if (vocab) {\n this.currentVocab = vocab;\n }\n finalContext = context || vocab || this.currentVocab;\n } else {\n finalContext = context;\n }\n\n if (!finalContext) {\n this.errors.push({\n message: `${this.specName} itemtype missing valid context`,\n format: this.specName,\n sourceCodeLocation,\n source: this.html.slice(\n sourceCodeLocation.startOffset,\n sourceCodeLocation.endOffset,\n ),\n });\n }\n\n if (this.specName === 'rdfa') {\n if (context || attribs.vocab) {\n currentScope['@context'] = finalContext;\n }\n } else {\n if (finalContext) {\n currentScope['@context'] = finalContext;\n }\n }\n currentScope['@type'] = type;\n\n if (typesWithId.includes(type)) {\n const id = this.ID_PROPS.find((prop) => attribs[prop]);\n if (id) {\n currentScope['@id'] = attribs[id];\n }\n }\n tag = this.TYPE;\n this.scopes.push(currentScope);\n } else if (attribs[this.PROP]) {\n if (\n currentScope[attribs[this.PROP]] &&\n !Array.isArray(currentScope[attribs[this.PROP]])\n ) {\n currentScope[attribs[this.PROP]] = [currentScope[attribs[this.PROP]]];\n }\n\n let value = null;\n try {\n value = this.#getPropValue(tagName, selfClosing, attribs);\n } catch (error) {\n this.errors.push({\n message: error.message,\n format: this.specName,\n sourceCodeLocation,\n source: this.html.slice(\n sourceCodeLocation.startOffset,\n sourceCodeLocation.endOffset,\n ),\n });\n }\n if (!value) {\n tag = this.PROP;\n if (Array.isArray(currentScope[attribs[this.PROP]])) {\n currentScope[attribs[this.PROP]].push('');\n } else {\n currentScope[attribs[this.PROP]] = '';\n }\n this.textForProp = attribs[this.PROP];\n } else {\n if (Array.isArray(currentScope[attribs[this.PROP]])) {\n currentScope[attribs[this.PROP]].push(value);\n } else {\n currentScope[attribs[this.PROP]] = value;\n }\n }\n }\n }\n if (!selfClosing) {\n this.tags.push(tag);\n }\n }\n\n #onText({ text }) {\n if (this.textForProp) {\n if (\n Array.isArray(this.scopes[this.scopes.length - 1][this.textForProp])\n ) {\n this.scopes[this.scopes.length - 1][this.textForProp][\n this.scopes[this.scopes.length - 1][this.textForProp].length - 1\n ] += text.trim();\n } else {\n this.scopes[this.scopes.length - 1][this.textForProp] += text.trim();\n }\n }\n }\n\n #onCloseTag({ sourceCodeLocation }) {\n const tag = this.tags.pop();\n if (tag === this.TYPE) {\n let scope = this.scopes.pop();\n\n if (\n (this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))) &&\n '@location' in scope\n ) {\n scope['@source'] = this.html.slice(\n scope['@location'],\n sourceCodeLocation.endOffset,\n );\n }\n if (this.options.addLocation && '@location' in scope) {\n scope['@location'] =\n `${scope['@location']},${sourceCodeLocation.endOffset}`;\n } else if (!this.options.addLocation && '@location' in scope) {\n delete scope['@location'];\n }\n\n if (!scope['@context']) {\n delete scope['@context'];\n }\n Object.keys(scope).forEach((key) => {\n if (Array.isArray(scope[key]) && scope[key].length === 1) {\n scope[key] = scope[key][0];\n }\n });\n } else if (tag === this.PROP) {\n this.textForProp = false;\n }\n }\n\n #postProcess() {\n this.topLevelScope = this.#processMultiValueProps(this.topLevelScope);\n }\n\n /**\n * Process multi-value properties recursively and split them into individual properties\n */\n #processMultiValueProps(obj) {\n if (Array.isArray(obj)) {\n return obj.map((item) => this.#processMultiValueProps(item));\n } else if (obj && typeof obj === 'object') {\n for (const [key, value] of Object.entries(obj)) {\n if (key.startsWith('@')) {\n continue;\n }\n\n obj[key] = this.#processMultiValueProps(value);\n\n // Split the key by spaces to handle multi-value properties\n const propNames = key.trim().split(/\\s+/);\n\n if (propNames.length > 1) {\n // Multi-value property: assign the same value to each individual property\n for (const propName of propNames) {\n if (propName) {\n obj[propName] = obj[key];\n }\n }\n delete obj[key];\n }\n }\n\n return obj;\n } else {\n return obj;\n }\n }\n\n parse() {\n this.parser.end(this.html);\n this.#postProcess();\n return { data: this.topLevelScope, errors: this.errors };\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default class JsonldParser {\n constructor(html, options = {}) {\n this.html = html;\n this.options = options;\n this.jsonldData = [];\n this.scriptScope = false;\n this.parser = new HTMLSAXParser();\n this.errors = [];\n this.specName = 'jsonld';\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n }\n\n #onOpenTag({ tagName, attrs }) {\n if (\n tagName === 'script' &&\n attrs.find(\n (attr) => attr.name === 'type' && attr.value === 'application/ld+json',\n )\n ) {\n this.scriptScope = true;\n }\n }\n\n #onText({ text, sourceCodeLocation }) {\n if (!this.scriptScope) {\n return;\n }\n\n try {\n const parsed = JSON.parse(text);\n\n // Check if parsed is null\n if (!parsed) {\n throw new Error('JSON-LD is null');\n }\n\n // Adjust offsets by removing leading and trailing whitespace\n let startOffset = sourceCodeLocation.startOffset;\n let endOffset = sourceCodeLocation.endOffset;\n const leadingWhitespace = text.match(/^\\s*/)[0].length;\n startOffset += leadingWhitespace;\n const trailingWhitespace = text.match(/\\s*$/)[0].length;\n endOffset -= trailingWhitespace;\n\n // Add script tag location to root items\n if (!Array.isArray(parsed)) {\n if (this.options.addLocation) {\n parsed['@location'] = `${startOffset},${endOffset}`;\n }\n if (\n this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))\n ) {\n parsed['@source'] = this.html.slice(startOffset, endOffset);\n }\n } else {\n parsed.forEach((item) => {\n if (this.options.addLocation) {\n item['@location'] = `${startOffset},${endOffset}`;\n }\n if (\n this.options.embedSource === true ||\n (Array.isArray(this.options.embedSource) &&\n this.options.embedSource.includes(this.specName))\n ) {\n item['@source'] = this.html.slice(startOffset, endOffset);\n }\n });\n }\n\n this.jsonldData.push(parsed);\n } catch (e) {\n this.errors.push({\n message: 'Could not parse JSON-LD',\n format: 'jsonld',\n source: text,\n sourceCodeLocation,\n });\n }\n }\n\n #onCloseTag({ tagName }) {\n if (tagName === 'script' && this.scriptScope) {\n this.scriptScope = false;\n }\n }\n\n #errorMissingType(item) {\n const sourceCodeLocation = {};\n const source = { ...item };\n if (item['@location']) {\n sourceCodeLocation.startOffset = parseInt(\n item['@location'].split(',')[0],\n );\n sourceCodeLocation.endOffset = parseInt(item['@location'].split(',')[1]);\n delete source['@location'];\n }\n\n const isEmptyJson = Object.keys(source).length === 0;\n if (isEmptyJson) {\n this.errors.push({\n message: 'JSON-LD object is empty',\n format: 'jsonld',\n sourceCodeLocation,\n source: JSON.stringify(source),\n });\n } else {\n this.errors.push({\n message: 'JSON-LD object missing @type attribute',\n format: 'jsonld',\n sourceCodeLocation,\n source: JSON.stringify(source),\n });\n }\n }\n\n #errorMissingContext(item) {\n const sourceCodeLocation = {};\n const source = { ...item };\n if (item['@location']) {\n sourceCodeLocation.startOffset = parseInt(\n item['@location'].split(',')[0],\n );\n sourceCodeLocation.endOffset = parseInt(item['@location'].split(',')[1]);\n delete source['@location'];\n }\n\n this.errors.push({\n message: 'JSON-LD object missing @context attribute',\n format: 'jsonld',\n sourceCodeLocation,\n source: JSON.stringify(source),\n });\n }\n\n #normalizeJsonldData() {\n const normalizedData = {};\n this.jsonldData.forEach((item) => {\n if (!Array.isArray(item)) {\n item = [item];\n }\n\n item.forEach((item) => {\n if (item['@graph']) {\n let context = item['@context'];\n let checkContext = true;\n\n if (!context) {\n this.#errorMissingContext(item);\n } else {\n checkContext = false;\n }\n item['@graph'].forEach((graphItem) => {\n // Move location and scope down to new root items\n if (item['@location']) {\n graphItem['@location'] = item['@location'];\n }\n if (item['@source']) {\n graphItem['@source'] = item['@source'];\n }\n if (checkContext) {\n if (context && !graphItem['@context']) {\n graphItem['@context'] = context;\n } else if (!context) {\n if (graphItem['@context']) {\n context = graphItem['@context'];\n } else {\n this.#errorMissingContext(graphItem);\n }\n }\n }\n\n if (!graphItem['@type']) {\n this.#errorMissingType(graphItem);\n return;\n }\n\n if (Array.isArray(graphItem['@type'])) {\n graphItem['@type'].forEach((type) => {\n normalizedData[type] = normalizedData[type] || [];\n normalizedData[type].push(graphItem);\n });\n } else {\n normalizedData[graphItem['@type']] =\n normalizedData[graphItem['@type']] || [];\n normalizedData[graphItem['@type']].push(graphItem);\n }\n });\n } else {\n if (!item['@type']) {\n this.#errorMissingType(item);\n return;\n }\n\n if (Array.isArray(item['@type'])) {\n item['@type'].forEach((type) => {\n normalizedData[type] = normalizedData[type] || [];\n normalizedData[type].push(item);\n });\n } else {\n normalizedData[item['@type']] = normalizedData[item['@type']] || [];\n normalizedData[item['@type']].push(item);\n }\n }\n });\n });\n\n return normalizedData;\n }\n\n parse() {\n this.parser.end(this.html);\n return { jsonld: this.#normalizeJsonldData(), errors: this.errors };\n }\n}\n","import { HTMLSAXParser } from './html-sax-parser.js';\n\nexport default class HeadingParser {\n constructor(html, options = {}) {\n this.html = html;\n this.options = {\n skipEmptyHeadings: false,\n skipLayoutElements: false,\n ...options,\n };\n\n this.errors = [];\n this.headings = [];\n this.currentHeading = null;\n this.headingText = '';\n this.headingStart = 0;\n this.headingEnd = 0;\n this.layoutStack = [];\n this.isInLayoutElement = false;\n\n this.parser = new HTMLSAXParser();\n\n this.parser.on('startTag', this.#onOpenTag.bind(this));\n this.parser.on('endTag', this.#onCloseTag.bind(this));\n this.parser.on('text', this.#onText.bind(this));\n }\n\n #onOpenTag({ tagName, attrs, sourceCodeLocation }) {\n const tag = tagName.toLowerCase();\n\n // Track layout elements\n if (['header', 'footer', 'nav', 'aside'].includes(tag)) {\n this.layoutStack.push(tag);\n this.isInLayoutElement = true;\n }\n\n // Check if this is a heading tag (h1-h6)\n if (/^h[1-6]$/i.test(tag)) {\n this.#startHeading(tag, attrs, sourceCodeLocation);\n }\n }\n\n #onCloseTag({ tagName, sourceCodeLocation }) {\n const tag = tagName.toLowerCase();\n\n // Handle closing layout elements\n if (['header', 'footer', 'nav', 'aside'].includes(tag)) {\n const index = this.layoutStack.lastIndexOf(tag);\n if (index !== -1) {\n this.layoutStack.splice(index, 1);\n this.isInLayoutElement = this.layoutStack.length > 0;\n }\n }\n\n // Check if this is a heading tag (h1-h6)\n if (/^h[1-6]$/i.test(tag)) {\n this.#endHeading(tag, sourceCodeLocation);\n }\n }\n\n #onText({ text }) {\n if (this.currentHeading) {\n this.headingText += text;\n }\n }\n\n #startHeading(tagName, attrs, sourceCodeLocation) {\n const level = parseInt(tagName.charAt(1));\n\n this.currentHeading = {\n tag: tagName.toLowerCase(),\n level: level,\n text: '',\n order: this.headings.length,\n attributes: attrs,\n };\n\n // Only include isLayoutElement field if we're not skipping layout elements\n if (!this.options.skipLayoutElements) {\n this.currentHeading.isLayoutElement = this.isInLayoutElement;\n }\n\n this.headingText = '';\n this.headingStart = sourceCodeLocation.startOffset;\n }\n\n #endHeading(tagName, sourceCodeLocation) {\n if (!this.currentHeading) return;\n if (tagName === this.currentHeading.tag) {\n this.currentHeading.text = this.headingText.trim();\n this.headingEnd = sourceCodeLocation.endOffset;\n\n if (this.options.embedSource) {\n this.currentHeading['@source'] = this.html.slice(\n this.headingStart,\n this.headingEnd,\n );\n }\n\n if (this.options.addLocation) {\n this.currentHeading['@location'] =\n `${this.headingStart},${this.headingEnd}`;\n }\n\n if (this.options.skipLayoutElements && this.isInLayoutElement) {\n // Don't add to headings array\n } else if (\n !this.options.skipEmptyHeadings ||\n this.currentHeading.text.trim() !== ''\n ) {\n this.headings.push(this.currentHeading);\n }\n } else {\n this.errors.push({\n message: 'Heading tags are malformed',\n format: 'headings',\n sourceCodeLocation,\n });\n }\n\n this.currentHeading = null;\n this.headingText = '';\n this.headingStart = 0;\n this.headingEnd = 0;\n }\n\n parse() {\n this.parser.end(this.html);\n\n return {\n headings: this.headings,\n errors: this.errors,\n };\n }\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
{
"name": "@marbec/web-auto-extractor",
"version": "2.2.0",
"version": "2.2.1",
"publishConfig": {

@@ -28,6 +28,6 @@ "access": "public"

"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.2.6",
"@semantic-release/npm": "^11.0.2",
"c8": "^9.1.0",
"chai": "^5.2.0",
"@semantic-release/github": "^11.0.0",
"@semantic-release/npm": "^12.0.0",
"c8": "^10.0.0",
"chai": "^6.0.0",
"eslint": "^9.22.0",

@@ -38,3 +38,3 @@ "globals": "^16.0.0",

"prettier": "^3.5.3",
"semantic-release": "^22.0.7"
"semantic-release": "^24.0.0"
},

@@ -41,0 +41,0 @@ "keywords": [