Commit 632e8c1d by Olle Jonsson Committed by GitHub

README: Use GitHub Markdown code fences

parent 94f0a8cf
...@@ -9,21 +9,25 @@ provided by freedesktop.org (see http://freedesktop.org/wiki/Software/shared-mim ...@@ -9,21 +9,25 @@ provided by freedesktop.org (see http://freedesktop.org/wiki/Software/shared-mim
Usage Usage
===== =====
require 'mimemagic' ```ruby
MimeMagic.by_extension('html').text? require 'mimemagic'
MimeMagic.by_extension('.html').child_of? 'text/plain' MimeMagic.by_extension('html').text?
MimeMagic.by_path('filename.txt') MimeMagic.by_extension('.html').child_of? 'text/plain'
MimeMagic.by_magic(File.open('test.html')) MimeMagic.by_path('filename.txt')
# etc... MimeMagic.by_magic(File.open('test.html'))
# etc...
```
Extra magic overlay Extra magic overlay
===== =====
Microsoft Office 2007+ formats (xlsx, docx, and pptx) are not supported by the mime database at freedesktop.org. These files are all zipped collections of xml files and will be detected as "application/zip". Mimemagic comes with extra magic you can overlay on top of the defaults to correctly detect these file types. Enable it like this: Microsoft Office 2007+ formats (xlsx, docx, and pptx) are not supported by the mime database at freedesktop.org. These files are all zipped collections of xml files and will be detected as "application/zip". Mimemagic comes with extra magic you can overlay on top of the defaults to correctly detect these file types. Enable it like this:
require 'mimemagic' ```ruby
require 'mimemagic/overlay' require 'mimemagic'
MimeMagic.by_magic(File.open('test.xlsx')) require 'mimemagic/overlay'
MimeMagic.by_magic(File.open('test.xlsx'))
```
You can add your own magic with `MimeMagic.add`. See `lib/mimemagic/overlay.rb`. You can add your own magic with `MimeMagic.add`. See `lib/mimemagic/overlay.rb`.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment