Developer ditches innerText for recursive DOM walker to fix structured text extraction
A developer building a browser extension to export NotebookLM AI answers as Markdown repeatedly ran into formatting failures caused by relying on JavaScript's innerText property. The innerText approach either broke paragraphs by treating citation buttons as block elements or collapsed all structure into a single wall of text when those elements were removed. After two failed workarounds, the developer rewrote the logic as a custom recursive DOM walker that processes each node type individually, preserving headings, lists, and bold formatting. The fix not only solved the newline issues but also delivered full Markdown export — including features previously considered too complex — at almost no extra cost. The developer concluded that innerText is unsuitable for any content with meaningful structure, and that walking the DOM directly is less effort overall than repeatedly patching flawed output.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in