Permalink
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
View
@@ -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: https://github.com/Kozea/WeasyPrint/blob/master/CHANGES
@@ -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: http://www.w3.org/TR/CSS21/
-.. _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: http://www.w3.org/TR/CSS21/tables.html#collapsing-borders
-.. _empty-cells: http://www.w3.org/TR/CSS21/tables.html#empty-cells
-.. _width: http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
-.. _height: http://www.w3.org/TR/CSS21/visudet.html#min-max-heights
-.. _Outlines: http://www.w3.org/TR/CSS21/ui.html#dynamic-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: http://www.w3.org/TR/CSS21/ui.html#dynamic-outlines
+.. _CSS 2.1: http://www.w3.org/TR/CSS21/
+.. _empty-cells: http://www.w3.org/TR/CSS21/tables.html#empty-cells
+.. _visibility\: collapse: http://www.w3.org/TR/CSS21/tables.html#dynamic-effects
+.. _width: http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
+.. _height: http://www.w3.org/TR/CSS21/visudet.html#min-max-heights
.. _font matching algorithm: http://www.w3.org/TR/CSS21/fonts.html#algorithm
.. _Bi-directional text: http://www.w3.org/TR/CSS21/visuren.html#direction
.. _System colors: http://www.w3.org/TR/CSS21/ui.html#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
+incomplete.
+
+.. _report a bug: /community/#issue-bug-tracker
+
CSS 3 Selectors
~~~~~~~~~~~~~~~
View
@@ -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 setup.py
View
@@ -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')
+
+
Errors
------

0 comments on commit 9a9b67b

Please sign in to comment.