stharrold / stharrold.github.io

GitHub page for stharrold, "Data Science Demos", with source code (`src_*` branches).
https://stharrold.github.io
MIT License
2 stars 1 forks source link

embed html #5

Open stharrold opened 8 years ago

stharrold commented 8 years ago

http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file

As an extension to liquid_tags?

stharrold commented 8 years ago

For embed_html plugin:

<div id="embed_html" data-html-path="path/to/html"></div>

Tag is from http://www.w3schools.com/tags/att_global_data.asp

find_all(name='div', attrs={'id': 'embed_html'}, content='')
tag.getattr['data-path-html']

Raise ValueError if missing key.

with open(path_html) as fobj:
    html_content = fobj.read()

Raise IOError if missing file.

<div id="embed_html" data-path-html="path/to/html">html_content</div>

Inline replacement avoids adding newlines as siblings to the content (http://www.crummy.com/software/BeautifulSoup/bs4/doc/#going-sideways)

stharrold commented 8 years ago

embedding d3 taken care of with ipynb: http://blog.thedataincubator.com/2015/08/embedding-d3-in-an-ipython-notebook/

stharrold commented 8 years ago

use <embed> HTML5 tag http://www.w3schools.com/tags/tag_embed.asp

stharrold commented 8 years ago

<embed>, <iframe>, <object> all create a separate document and do not adopt styles from host page. <iframe> with seamless attribute will adopt styles but is not widely supported:

For discussion, see

stharrold commented 8 years ago
stharrold commented 8 years ago

With embedded ipynb as basic HTML, need CSS style or BeautifulSoup script to: * Remove paragraph anchor marks. (e.g. <a class="anchor-link" href="#20151030_test">&#182;</a>) * Drop unwanted cells.

stharrold commented 8 years ago

Future usage note: For embedding IPYNBs, either:
* use embed_html to embed the IPYNB basic HTML export (jupyter nbconvert --to html --template basic)
or:
* use liquid_tags.notebook to embed the IPYNB.
Otherwise the CSS styling from liquid_tags.notebook's generated file _nb_header.html will be applied to the embedded IPYNB basic HTML export. It's ok to use liquid_tags.notebook to embed IPYNBs and use embed_html to embed HTML files that are not IPYNB basic HTML exports.

stharrold commented 8 years ago

markdown.extensions.toc will not parse headers in embedded HTML: