yafg


Nameyafg JSON
Version 0.3 PyPI version JSON
download
home_pagehttps://git.sr.ht/~ferruck/yafg
SummaryFigure and figcaption generator markdown extension
upload_time2020-07-13 19:03:28
maintainerPhilipp Trommler
docs_urlNone
authorPhilipp Trommler
requires_python>=2.7.15, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4
licenseGPLv3+
keywords markdown image figure caption html a11y
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # yafg - Yet Another Figure Generator

*yafg* is yet another figure generator plugin for Python's Markdown. It's
written and tested with Python 2.7 and Python 3.6 as well as Markdown 3.1.1, but
aims at supporting as many versions as possible. If you encounter any problems
with the given versions or find yourself using *yafg* without problems with any
others, please give me a hint using the e-mail address listed below.

It uses the `title` attribute given to an image within Markdown to generate a
`<figure>` environment with a `<figcaption>` containing the `title`'s text,
e.g.:

```markdown
![Alt text](/path/to/image.png "This is the title of the image.")
```

becomes

```html
<figure>
<img alt="Alt text" src="/path/to/image.png" title="This is the title of the image." />
<figcaption>This is the title of the image.</figcaption>
</figure>
```

## How?

### Install

*yafg* can be installed via PyPI using:

```
pip install yafg
```

### Standard Usage

When parsing your input, you can add *yafg* to Markdown as follows:

```python
import yafg

# ...

outputString = markdown.markdown(inputString, extensions = [yafg.YafgExtension(stripTitle=False)])
```

### Pelican

Pelican users can add *yafg* to their generator process by adding it to the
`MARKDOWN` variable in the `pelicanconf.py` as follows:

```python
MARKDOWN = {
    'extensions_configs': {
        'yafg': {
            'stripTitle': 'False',
        },
    },
}
```

### Options

Currently supported options are listed below:

* `stripTitle` (default: `False`):

    Removes the original `title` attribute from the `<img />` element. Since its
    usage is discouraged anyways (see below), this may be an option worth
    considering.

* `figureClass` (default: `""`):

    The CSS class to add to the generated `<figure />` element.

* `figcaptionClass` (default: `""`):

    The CSS class to add to the generated `<figcaption />` element.

* `figureNumbering` (default: `False`):

    Adds a figure number like "Figure 1:" in front of the caption. It's wrapped
    in a `<span />` for easier styling.

* `figureNumberClass` (default: `""`):

    The CSS class to add to the `<span />` element generated for the figure
    number.

* `figureNumberText` (default: `"Figure"`):

    The text to show in front of the figure number. A final non-breaking space
    is inserted between the content of `figureNumberText` and the actual figure
    number.

## Why?

yafg arose from the dissatisfaction with the existing solutions, namely:

* [markdown\_captions](https://github.com/evidlo/markdown_captions) which uses
  the `alt` attribute for the `<figcaption>`.
* [markdown-figcap](https://github.com/funk1d/markdown-figcap) which uses a
  cryptic syntax that doesn't integrate well into Markdown, IMHO.
* [figureAltCaption](https://github.com/jdittrich/figureAltCaption) which
  cannot handle multi-line descriptions and uses the `alt` attribute for the
  `<figcaption>`.

Using the `alt` attribute to fill the `<figcaption>` is not correct, because [as
the standard states](https://www.w3.org/wiki/Html/Elements/img)

> [...] the alternative text is a replacement for the image, not a description
> [...]

for the most common case of a text accompanied by an augmenting image. It should
be used for an exact reproduction of what can be seen on the image for those who
cannot see it, for example because they're blind or their internet connection is
too slow. A figure's caption in turn should provide a description helping to
understand the content of the image.

The `title` attribute on the other hand should contain "[a]dvisory information
associated with the element ([W3C Core Attribute
List](https://www.w3.org/wiki/Html/Attributes/_Global)). This is rather vague
and often used by browser vendors to show tooltips containing the title. Since
tooltips are highly problematic for a11y reasons and the browser support varies,
"[r]elying on the title attribute is currently discouraged" ([HTML Living
Standard](https://html.spec.whatwg.org/multipage/dom.html#the-title-attribute)).
This makes it an ideal candidate to store the wanted `figcaption` inside of the
standard Markdown syntax.

## Author

*yafg* has been written by:

* Philipp Trommler <yafg@philipp-trommler.me>

## License

*yafg* has been published under a GPL 3.0 or later license. See the `LICENSE`
file for more information.



            

Raw data

            {
    "_id": null,
    "home_page": "https://git.sr.ht/~ferruck/yafg",
    "name": "yafg",
    "maintainer": "Philipp Trommler",
    "docs_url": null,
    "requires_python": ">=2.7.15, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
    "maintainer_email": "yafg@philipp-trommler.me",
    "keywords": "markdown image figure caption html a11y",
    "author": "Philipp Trommler",
    "author_email": "yafg@philipp-trommler.me",
    "download_url": "https://files.pythonhosted.org/packages/e2/55/828d7210711349a40d9744bed3630902787db5b6c4b38d74852560ef9059/yafg-0.3.tar.gz",
    "platform": "",
    "description": "# yafg - Yet Another Figure Generator\n\n*yafg* is yet another figure generator plugin for Python's Markdown. It's\nwritten and tested with Python 2.7 and Python 3.6 as well as Markdown 3.1.1, but\naims at supporting as many versions as possible. If you encounter any problems\nwith the given versions or find yourself using *yafg* without problems with any\nothers, please give me a hint using the e-mail address listed below.\n\nIt uses the `title` attribute given to an image within Markdown to generate a\n`<figure>` environment with a `<figcaption>` containing the `title`'s text,\ne.g.:\n\n```markdown\n![Alt text](/path/to/image.png \"This is the title of the image.\")\n```\n\nbecomes\n\n```html\n<figure>\n<img alt=\"Alt text\" src=\"/path/to/image.png\" title=\"This is the title of the image.\" />\n<figcaption>This is the title of the image.</figcaption>\n</figure>\n```\n\n## How?\n\n### Install\n\n*yafg* can be installed via PyPI using:\n\n```\npip install yafg\n```\n\n### Standard Usage\n\nWhen parsing your input, you can add *yafg* to Markdown as follows:\n\n```python\nimport yafg\n\n# ...\n\noutputString = markdown.markdown(inputString, extensions = [yafg.YafgExtension(stripTitle=False)])\n```\n\n### Pelican\n\nPelican users can add *yafg* to their generator process by adding it to the\n`MARKDOWN` variable in the `pelicanconf.py` as follows:\n\n```python\nMARKDOWN = {\n    'extensions_configs': {\n        'yafg': {\n            'stripTitle': 'False',\n        },\n    },\n}\n```\n\n### Options\n\nCurrently supported options are listed below:\n\n* `stripTitle` (default: `False`):\n\n    Removes the original `title` attribute from the `<img />` element. Since its\n    usage is discouraged anyways (see below), this may be an option worth\n    considering.\n\n* `figureClass` (default: `\"\"`):\n\n    The CSS class to add to the generated `<figure />` element.\n\n* `figcaptionClass` (default: `\"\"`):\n\n    The CSS class to add to the generated `<figcaption />` element.\n\n* `figureNumbering` (default: `False`):\n\n    Adds a figure number like \"Figure 1:\" in front of the caption. It's wrapped\n    in a `<span />` for easier styling.\n\n* `figureNumberClass` (default: `\"\"`):\n\n    The CSS class to add to the `<span />` element generated for the figure\n    number.\n\n* `figureNumberText` (default: `\"Figure\"`):\n\n    The text to show in front of the figure number. A final non-breaking space\n    is inserted between the content of `figureNumberText` and the actual figure\n    number.\n\n## Why?\n\nyafg arose from the dissatisfaction with the existing solutions, namely:\n\n* [markdown\\_captions](https://github.com/evidlo/markdown_captions) which uses\n  the `alt` attribute for the `<figcaption>`.\n* [markdown-figcap](https://github.com/funk1d/markdown-figcap) which uses a\n  cryptic syntax that doesn't integrate well into Markdown, IMHO.\n* [figureAltCaption](https://github.com/jdittrich/figureAltCaption) which\n  cannot handle multi-line descriptions and uses the `alt` attribute for the\n  `<figcaption>`.\n\nUsing the `alt` attribute to fill the `<figcaption>` is not correct, because [as\nthe standard states](https://www.w3.org/wiki/Html/Elements/img)\n\n> [...] the alternative text is a replacement for the image, not a description\n> [...]\n\nfor the most common case of a text accompanied by an augmenting image. It should\nbe used for an exact reproduction of what can be seen on the image for those who\ncannot see it, for example because they're blind or their internet connection is\ntoo slow. A figure's caption in turn should provide a description helping to\nunderstand the content of the image.\n\nThe `title` attribute on the other hand should contain \"[a]dvisory information\nassociated with the element ([W3C Core Attribute\nList](https://www.w3.org/wiki/Html/Attributes/_Global)). This is rather vague\nand often used by browser vendors to show tooltips containing the title. Since\ntooltips are highly problematic for a11y reasons and the browser support varies,\n\"[r]elying on the title attribute is currently discouraged\" ([HTML Living\nStandard](https://html.spec.whatwg.org/multipage/dom.html#the-title-attribute)).\nThis makes it an ideal candidate to store the wanted `figcaption` inside of the\nstandard Markdown syntax.\n\n## Author\n\n*yafg* has been written by:\n\n* Philipp Trommler <yafg@philipp-trommler.me>\n\n## License\n\n*yafg* has been published under a GPL 3.0 or later license. See the `LICENSE`\nfile for more information.\n\n\n",
    "bugtrack_url": null,
    "license": "GPLv3+",
    "summary": "Figure and figcaption generator markdown extension",
    "version": "0.3",
    "split_keywords": [
        "markdown",
        "image",
        "figure",
        "caption",
        "html",
        "a11y"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "248192dcb2d2d141df86fcd83c5a057c",
                "sha256": "8f5c31a3f62f946b33aa9e1306017435ec2e43fe30b8109b7076eafc03f9ca8b"
            },
            "downloads": -1,
            "filename": "yafg-0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "248192dcb2d2d141df86fcd83c5a057c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7.15, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
            "size": 18864,
            "upload_time": "2020-07-13T19:03:26",
            "upload_time_iso_8601": "2020-07-13T19:03:26.999992Z",
            "url": "https://files.pythonhosted.org/packages/38/aa/427f208daf46348774f05c9c0b186f167a3a05ec258257c539db77284efa/yafg-0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "cf3c8d463aed998f5cea6a42ac4dd911",
                "sha256": "1fdc01f8169913a43daa520e90786027a497edc9ccc149aacdab1409e3b4d0c4"
            },
            "downloads": -1,
            "filename": "yafg-0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "cf3c8d463aed998f5cea6a42ac4dd911",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7.15, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
            "size": 5758,
            "upload_time": "2020-07-13T19:03:28",
            "upload_time_iso_8601": "2020-07-13T19:03:28.866780Z",
            "url": "https://files.pythonhosted.org/packages/e2/55/828d7210711349a40d9744bed3630902787db5b6c4b38d74852560ef9059/yafg-0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-07-13 19:03:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "yafg"
}
        
Elapsed time: 0.10299s