gdocs-me-up is a Node.js exporter that converts Google Docs into high-fidelity HTML+CSS, preserving document styling such as heading hierarchy, line spacing, margins, alignment, RTL directionality, lists, tables, images, and table-of-contents. It reads detailed formatting from the Google Docs API (named styles, paragraphStyle attributes, image sizes and crops) and merges those into HTML while injecting CSS that neutralizes browser defaults (for example, overriding heading inflation so inline styles govern size). Headings map to H1-H6 or classes, RTL paragraphs get dir="rtl" with flipped alignment, tables become semantic table/thead/tbody/td elements, and the main content is wrapped in a <main> landmark for site integration. Google Fonts referenced in the document are added via fonts.googleapis.com.
Usage requires Node.js v20.9+, a Google Cloud service account JSON key with Docs/Drive access, and a doc ID; running node gdocs-me-up.js produces an index.html and an images directory and supports options to include external stylesheets, scripts, and head fragments. Image handling is detailed: inline and positioned images respect document dimensions and crops, raster resizing targets twice the displayed size without enlarging sources, JPEGs are encoded as quality-84 WebP, PNGs are losslessly optimized or converted to WebP only when it saves ≥20%. The project includes extensive tests (unit tests with 97% coverage, content-verification, snapshot and visual comparison suites) to ensure fidelity and detect regressions.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.