You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Embed hyperlinks in io.ascii.write html output? #4006
Hmm--looks like the HTML writer always escapes the raw strings for HTML related characters. However I could see this as an argument for a "raw" mode to just write strings from a table without escaping. If so, I think this should be enabled on a per-column basis.
This would require an update to the XMLWriter class to allow data to be written to an element without HTML entity escapes. It would also require an update to the astropy.io.ascii.html.HTML class to accept an optional sequence of columns in which to allow raw HTML, and an update to HTML.write to support that.
I think also as a security concern, insecure tags like <script> or <iframe> should be disabled even in raw HTML mode, unless explicitly whitelisted (this is why I bumped this up to effort-medium).
the functionality is present in pandas "to_html" writer. A pandas table "pd" containing html links can be printed to html setting "escape=False"
pd.to_html('fileout.html',escape=False)
Unfortunately, pandas writes vanilla html without sorting headers etc., so it would still be nice to get this added to astropy
Activity
embray commentedon Jul 24, 2015
Hmm--looks like the HTML writer always escapes the raw strings for HTML related characters. However I could see this as an argument for a "raw" mode to just write strings from a table without escaping. If so, I think this should be enabled on a per-column basis.
This would require an update to the
XMLWriterclass to allow data to be written to an element without HTML entity escapes. It would also require an update to theastropy.io.ascii.html.HTMLclass to accept an optional sequence of columns in which to allow raw HTML, and an update toHTML.writeto support that.I think also as a security concern, insecure tags like
<script>or<iframe>should be disabled even in raw HTML mode, unless explicitly whitelisted (this is why I bumped this up to effort-medium).pllim commentedon Jul 24, 2015
Meanwhile,
sedcan be used to manually fix the<a href=...>and</a>tags. http://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Commandmrobberto commentedon Dec 24, 2015
the functionality is present in pandas "to_html" writer. A pandas table "pd" containing html links can be printed to html setting "escape=False"
pd.to_html('fileout.html',escape=False)
Unfortunately, pandas writes vanilla html without sorting headers etc., so it would still be nice to get this added to astropy
pllim commentedon Dec 24, 2015
c/c @taldcroft ?
taldcroft commentedon Dec 29, 2015
Definitely 👍 on the idea. I've wanted this myself a few times, so a PR would definitely be welcome.
taldcroft commentedon Dec 30, 2015
See #4423 for code.
algerdnazgul commentedon Apr 19, 2016
Close?
pllim commentedon Apr 19, 2016
Yes, thanks.