behave-contrib / behave-html-pretty-formatter

HTML Pretty formatter for Behave
GNU General Public License v3.0
13 stars 4 forks source link

Choose the extension of a downloadable file #38

Closed lu-maca closed 11 months ago

lu-maca commented 1 year ago

Hi guys,

is it possible to choose the extension of the file downloadable by "Download" button in embed data? I'm quite sure the answer is: no, at the moment.

One solution should be to add a check to the filename. If the pattern ".something" is present in the filename, do nothing; if not, append .txt to it.

A basic implementation: in function download_embed(id, filename):

if (tag === "span") {
  if (filename.search("(\\.\\w+)") == -1){
    filename += ".txt";
  }
  value = "data:text/plain," + encodeURIComponent(decodeHTMLEntities(child.innerHTML));

This shall also be done for other branches, but I'm not sure if this works for non text files. Also, I'm not sure if this is the best workaround for this problem.

Thanks Luca

fpokryvk commented 1 year ago

Hi,

currently the answer is no, filename is fixed to be embed caption and extension is appended by mime_type of embed. We can add the following support for this:

Thanks for raising this!

lu-maca commented 1 year ago

This looks good to me!