From 8691eae14e41844e33f0f2b27eb18742650a7c0b Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 9 Feb 2014 13:39:09 +0200 Subject: [PATCH] Improve README.md. Use code syntax when possible and be consistent with the headers syntax. --- README.md | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e804577..368cfbc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -FileSaver.js -============ +# FileSaver.js FileSaver.js implements the HTML5 W3C `saveAs()` [FileSaver][1] interface in browsers that do not natively support it. There is a [FileSaver.js demo][2] that demonstrates saving @@ -12,8 +11,7 @@ sent to an external server. Looking for `canvas.toBlob()` for saving canvases? Check out [canvas-toBlob.js](https://github.com/eligrey/canvas-toBlob.js) for a cross-browser implementation. -Supported Browsers ------------------- +## Supported Browsers | Browser | Constructs as | Filenames | Max Blob Size | Dependencies | | -------------- | ------------- | ------------ | ------------- | ------------ | @@ -29,8 +27,11 @@ Supported Browsers Feature detection is possible: - try { var isFileSaverSupported = !!new Blob(); } catch(e){} - +```js +try { + var isFileSaverSupported = !!new Blob(); +} catch (e) {} +``` ### IE < 10 @@ -44,29 +45,33 @@ Blobs may be opened instead of saved sometimes—you may have to direct your Saf press +S to save the file after it is opened. Further information is available [on the issue tracker](https://github.com/eligrey/FileSaver.js/issues/12). -Syntax ------- +## Syntax - FileSaver saveAs(in Blob data, in DOMString filename) +```js +FileSaver saveAs(in Blob data, in DOMString filename) +``` -Examples --------- +## Examples ### Saving text - var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); - saveAs(blob, "hello world.txt"); +```js +var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); +saveAs(blob, "hello world.txt"); +``` The standard W3C File API [`Blob`][3] interface is not available in all browsers. [Blob.js][4] is a cross-browser `Blob` implementation that solves this. ### Saving a canvas - var canvas = document.getElementById("my-canvas"), ctx = canvas.getContext("2d"); - // draw to canvas... - canvas.toBlob(function(blob) { - saveAs(blob, "pretty image.png"); - }); +```js +var canvas = document.getElementById("my-canvas"), ctx = canvas.getContext("2d"); +// draw to canvas... +canvas.toBlob(function(blob) { + saveAs(blob, "pretty image.png"); +}); +``` Note: The standard HTML5 `canvas.toBlob()` method is not available in all browsers. [canvas-toBlob.js][5] is a cross-browser `canvas.toBlob()` that polyfills this.