1- FileSaver.js
2- ============
1+ # FileSaver.js
32
43FileSaver.js implements the HTML5 W3C ` saveAs() ` [ FileSaver] [ 1 ] interface in browsers that do
54not natively support it. There is a [ FileSaver.js demo] [ 2 ] that demonstrates saving
@@ -12,8 +11,7 @@ sent to an external server.
1211Looking for ` canvas.toBlob() ` for saving canvases? Check out
1312[ canvas-toBlob.js] ( https://github.com/eligrey/canvas-toBlob.js ) for a cross-browser implementation.
1413
15- Supported Browsers
16- ------------------
14+ ## Supported Browsers
1715
1816| Browser | Constructs as | Filenames | Max Blob Size | Dependencies |
1917| -------------- | ------------- | ------------ | ------------- | ------------ |
@@ -29,8 +27,11 @@ Supported Browsers
2927
3028Feature detection is possible:
3129
32- try { var isFileSaverSupported = !!new Blob(); } catch(e){}
33-
30+ ``` js
31+ try {
32+ var isFileSaverSupported = !! new Blob ();
33+ } catch (e) {}
34+ ```
3435
3536### IE < 10
3637
@@ -44,29 +45,33 @@ Blobs may be opened instead of saved sometimes—you may have to direct your Saf
4445press <kbd >⌘</kbd >+<kbd >S</kbd > to save the file after it is opened. Further information is available
4546[ on the issue tracker] ( https://github.com/eligrey/FileSaver.js/issues/12 ) .
4647
47- Syntax
48- ------
48+ ## Syntax
4949
50- FileSaver saveAs(in Blob data, in DOMString filename)
50+ ``` js
51+ FileSaver saveAs (in Blob data, in DOMString filename)
52+ ```
5153
52- Examples
53- --------
54+ ## Examples
5455
5556### Saving text
5657
57- var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
58- saveAs(blob, "hello world.txt");
58+ ``` js
59+ var blob = new Blob ([" Hello, world!" ], {type: " text/plain;charset=utf-8" });
60+ saveAs (blob, " hello world.txt" );
61+ ```
5962
6063The standard W3C File API [ ` Blob ` ] [ 3 ] interface is not available in all browsers.
6164[ Blob.js] [ 4 ] is a cross-browser ` Blob ` implementation that solves this.
6265
6366### Saving a canvas
6467
65- var canvas = document.getElementById("my-canvas"), ctx = canvas.getContext("2d");
66- // draw to canvas...
67- canvas.toBlob(function(blob) {
68- saveAs(blob, "pretty image.png");
69- });
68+ ``` js
69+ var canvas = document .getElementById (" my-canvas" ), ctx = canvas .getContext (" 2d" );
70+ // draw to canvas...
71+ canvas .toBlob (function (blob ) {
72+ saveAs (blob, " pretty image.png" );
73+ });
74+ ```
7075
7176Note: The standard HTML5 ` canvas.toBlob() ` method is not available in all browsers.
7277[ canvas-toBlob.js] [ 5 ] is a cross-browser ` canvas.toBlob() ` that polyfills this.
0 commit comments