Skip to content

to_html() should produce self-contained HTML without requiring manual asset copying #643

@paddymul

Description

@paddymul

Problem

buckaroo.artifact.to_html() generates HTML that references static-embed.js and static-embed.css as sibling files. Users must manually locate and copy these from the installed package alongside their generated HTML, or the page won't render.

This is awkward for the simplest use case:

from buckaroo.artifact import to_html
import pandas as pd

html = to_html(pd.read_csv('data.csv'), title="My Data")
with open('my-data.html', 'w') as f:
    f.write(html)
# Page doesn't work until you also run:
# cp $(python -c "...")/static/static-embed.* ./

Possible solutions

  1. Inline the JS/CSSto_html() could embed the bundle directly in the HTML via <script> and <style> tags. Makes the file ~1.3 MB larger but fully self-contained. Could be opt-in: to_html(df, inline_assets=True).

  2. Copy assets automaticallyto_html() or a companion to_html_dir() could write the HTML + assets to a directory.

  3. CDN reference — publish static-embed.js to a CDN (jsDelivr, unpkg) and reference it by URL. Each HTML file stays tiny, but requires internet access to view.

Option 1 (with an inline_assets flag) seems like the lowest-friction fix. Option 3 is the long-term goal per the content plan.

Context

Reported via Codex review on #641. The current workaround is documented in the embedding guide, but the default to_html() experience should just work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions