export function parseNitfContent()

in poller-lambdas/src/pollers/ap/parseNitfContent.ts [27:47]


export function parseNitfContent(content: string): ContentFromNitf {
	const root = parse(content);
	const issueDate = root.querySelector('date\\.issue')?.getAttribute('norm');
	const byline = root.querySelector('byline')?.textContent;
	const headline = root.querySelector('hl1#headline')?.textContent;
	const abstract = root.querySelector('abstract')?.textContent;
	const edMessage = root.querySelector('ed-msg[info]')?.getAttribute('info');

	const bodyContentBlockElements = Array.from(
		root.querySelectorAll('body\\.content block'),
	);

	const bodyContentHtml =
		bodyContentBlockElements.length > 0
			? bodyContentBlockElements
					.flatMap((block) => nitfBlockToHtml(block))
					.join('')
			: undefined;

	return { bodyContentHtml, issueDate, byline, headline, abstract, edMessage };
}