Commits

Anonymous committed 01176bb

Added `.<ext>=<mimetype>` resource specifier syntax.

Comments (0)

Files changed (2)

                     die('missing resource directory: %s' % r)
             elif os.path.isdir(r):
                 self.resource_dirs.append(r)
+            elif r.startswith('.') and '=' in r:
+                ext, mimetype = r.split('=')
+                mimetypes.add_type(mimetype, ext)
             else:
                 self.resource_files.append(r)
         for p in (os.path.dirname(self.asciidoc), CONF_DIR):
                 item.setAttribute('id', 'a2x-%d' % count)
                 mimetype = mimetypes.guess_type(f)[0]
                 if mimetype is None:
-                    warning('unknown mimetype: %s' % f)
-                    mimetype = 'application/xhtml+xml'
+                    die('unknown mimetype: %s' % f)
                 item.setAttribute('media-type', mimetype)
                 manifest.appendChild(item)
         if count > 0:
   directory.
 
 Resources are specified by *--resource* option values and can be one
-of the following two formats:
+of the following formats:
 
   <resource_dir>
   <resource_file>[=<destination_file>]
   doc/README.txt=README.txt
   ~/images/tiger.png=images/tiger.png
 
+When adding resources to EPUB files the mimetype is infered from the
+`<destination file>` extension, if the mimetype cannot be guessed an
+error occurs. The `.<ext>=<mimetype>` resource syntax can be used to
+explicitly set mimetypes, for example:
+
+  .asciidoc=text/plain
+
 
 EXAMPLES
 --------