Browse files

Update for 0.12

  • Loading branch information...
1 parent 23da9c4 commit 9a9b67b6e4f61728fc3e91fa30b70390abcf09ba @SimonSapin SimonSapin committed Jul 18, 2012
Showing with 54 additions and 22 deletions.
  1. +17 −21 pages/features.rst
  2. +1 −1 pages/install.rst
  3. +36 −0 pages/using.rst
@@ -6,7 +6,7 @@ Documentation
* `Hacking </hacking/>`_
* **Features**
-This page is for WeasyPrint 0.11. For older versions, see the changelog_.
+This page is for WeasyPrint 0.12. See the changelog_ for older versions.
.. _changelog:
@@ -69,38 +69,34 @@ CSS
CSS 2.1
-To the best of our knowledge, everything in `CSS 2.1`_ that applies to the
-“print” media but is not listed in this section is supported.
-Please `report a bug`_ if you find this list incomplete.
+The `CSS 2.1`_ features listed here are **not** supported:
-.. _CSS 2.1:
-.. _report a bug: /community/#issue-bug-tracker
-Some CSS 2.1 features are not supported yet but are on the *to do* list:
-* Table `border collapsing`_ and the `empty-cells`_ property.
+* Outlines_
+* On tables: `empty-cells`_ and `visibility: collapse`_.
* Minimum and maximum width_ and height_ on table-related boxes and
page-margin boxes.
-* Outlines_
-.. _border collapsing:
-.. _empty-cells:
-.. _width:
-.. _height:
-.. _Outlines:
-We have few or no use cases for others, but feel free to ask about them:
* Conforming `font matching algorithm`_. Currently ``font-family``
is passed as-is to Pango.
* Right-to-left or `bi-directional text`_.
- (May happen to kind of work in uninterrupted text thanks to Pango)
+ (May *kind of* work within uninterrupted text thanks to Pango)
* `System colors`_. They are deprecated in CSS 3
+.. _Outlines:
+.. _CSS 2.1:
+.. _empty-cells:
+.. _visibility\: collapse:
+.. _width:
+.. _height:
.. _font matching algorithm:
.. _Bi-directional text:
.. _System colors:
+To the best of our knowledge, everything else that applies to the
+print media **is** supported. Please `report a bug`_ if you find this list
+.. _report a bug: /community/#issue-bug-tracker
CSS 3 Selectors
@@ -32,7 +32,7 @@ WeasyPrint has been packaged for some Linux distributions:
For other distributions or if you want to install it yourself,
-WeasyPrint 0.11 depends on:
+WeasyPrint 0.12 depends on:
.. Note: keep this in sync with
@@ -104,6 +104,7 @@ You can also pass optional named arguments:
``<img src="../foo.png">``).
If not passed explicitly, try to use the input filename, URL, or
``name`` attribute of file objects.
+* ``url_fetcher``: override the URL fetcher. (See `below <#url-fetchers>`_.)
**Note:** In some cases like ``HTML(string=foo)`` you need to pass ``base_url``
explicitly, or relative URLs will be invalid.
@@ -170,6 +171,41 @@ The above warning on ``base_url`` and string input applies too: relative
URLs will be invalid if there is no base URL.
+URL fetchers
+The URL fetcher is used for resources with an ``url`` input as well as
+linked images and stylesheets. It is a function (or any callable) that
+takes a single parameter (the URL) and should raise any exception to
+indicate failure or return a dict with the following keys:
+* One of ``string`` (a byte string) or ``file_obj`` (a file-like object)
+* Optionally: ``mime_type``, a MIME type extracted eg. from a *Content-Type*
+ header. If not provided, the type is guessed from the file extension
+ in the URL.
+* Optionally: ``encoding``, a character encoding extracted eg.from a
+ *charset* parameter in a *Content-Type* header
+* Optionally: ``redirected_url``, the actual URL of the ressource in case
+ there were eg. HTTP redirects.
+URL fetchers can defer to the default fetcher:
+.. code-block:: python
+ from weasyprint import default_url_fetcher, HTML
+ def my_fetcher(url):
+ if url.startswith('graph:')
+ graph_data = map(float, url[6:].split(','))
+ return dict(string=generate_graph(graph_data),
+ mime_type='image/png')
+ else:
+ return weasyprint.default_url_fetcher(url)
+ source = '<img src="graph:42,10.3,87">'
+ HTML(string=source, url_fetcher=my_fetcher).write_pdf('out.pdf')

0 comments on commit 9a9b67b

Please sign in to comment.