https://ragt.ag
- Paweł Miech https://pawelmhm.github.io
- Sven Knebel https://www.svenknebel.de
mf2py-2.0.1/LICENSE 0000664 0000000 0000000 00000002064 14534511526 0013564 0 ustar 00root root 0000000 0000000 Copyight (c) 2013, 2014 Tom Morris and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
mf2py-2.0.1/Makefile 0000664 0000000 0000000 00000000377 14534511526 0014224 0 ustar 00root root 0000000 0000000 install:
poetry install
tests:
poetry run pytest -s -vv --doctest-modules --doctest-glob README*
lint:
poetry run black .
poetry run isort .
docs_dev:
poetry run mkdocs serve
docs_deploy:
poetry run mkdocs gh-deploy
publish:
poetry publish --build
mf2py-2.0.1/README.md 0000664 0000000 0000000 00000010733 14534511526 0014040 0 ustar 00root root 0000000 0000000 
[](https://badge.fury.io/py/mf2py)
[](https://pypistats.org/packages/mf2py)
[](https://github.com/microformats/mf2py/blob/main/LICENSE)
[](https://badge.fury.io/py/mf2py)
## Welcome 👋
`mf2py` is a Python [microformats](https://microformats.org/wiki/microformats) parser with full support for `microformats2`, backwards-compatible support for `microformats1` and experimental support for `metaformats`.
## Installation 💻
To install `mf2py` run the following command:
```bash
$ pip install mf2py
```
## Quickstart 🚀
Import the library:
```pycon
>>> import mf2py
```
### Parse an HTML Document from a file or string
```pycon
>>> with open("test/examples/eras.html") as fp:
... mf2json = mf2py.parse(doc=fp)
>>> mf2json
{'items': [{'type': ['h-entry'],
'properties': {'name': ['Excited for the Taylor Swift Eras Tour'],
'author': [{'type': ['h-card'],
'properties': {'name': ['James'],
'url': ['https://example.com/']},
'value': 'James',
'lang': 'en-us'}],
'published': ['2023-11-30T19:08:09'],
'featured': [{'value': 'https://example.com/eras.jpg',
'alt': 'Eras tour poster'}],
'content': [{'value': "I can't decide which era is my favorite.",
'lang': 'en-us',
'html': "I can't decide which era is my favorite.
"}],
'category': ['music', 'Taylor Swift']},
'lang': 'en-us'}],
'rels': {'webmention': ['https://example.com/mentions']},
'rel-urls': {'https://example.com/mentions': {'text': '',
'rels': ['webmention']}},
'debug': {'description': 'mf2py - microformats2 parser for python',
'source': 'https://github.com/microformats/mf2py',
'version': '2.0.1',
'markup parser': 'html5lib'}}
```
```pycon
>>> mf2json = mf2py.parse(doc="James")
>>> mf2json["items"]
[{'type': ['h-card'],
'properties': {'name': ['James'],
'url': ['https://example.com']}}]
```
### Parse an HTML Document from a URL
```pycon
>>> mf2json = mf2py.parse(url="https://events.indieweb.org")
>>> mf2json["items"][0]["type"]
['h-feed']
>>> mf2json["items"][0]["children"][0]["type"]
['h-event']
```
## Experimental Options
The following options can be invoked via keyword arguments to `parse()` and `Parser()`.
### `expose_dom`
Use `expose_dom=True` to expose the DOM of embedded properties.
### `metaformats`
Use `metaformats=True` to include any [metaformats](https://microformats.org/wiki/metaformats)
found.
### `filter_roots`
Use `filter_roots=True` to filter known conflicting user names (e.g. Tailwind).
Otherwise provide a custom list to filter instead.
## Advanced Usage
`parse` is a convenience function for `Parser`. More sophisticated behaviors are
available by invoking the parser object directly.
```pycon
>>> with open("test/examples/festivus.html") as fp:
... mf2parser = mf2py.Parser(doc=fp)
```
#### Filter by Microformat Type
```pycon
>>> mf2json = mf2parser.to_dict()
>>> len(mf2json["items"])
7
>>> len(mf2parser.to_dict(filter_by_type="h-card"))
3
>>> len(mf2parser.to_dict(filter_by_type="h-entry"))
4
```
#### JSON Output
```pycon
>>> json = mf2parser.to_json()
>>> json_cards = mf2parser.to_json(filter_by_type="h-card")
```
## Breaking Changes in `mf2py` 2.0
- Image `alt` support is now on by default.
## Notes 📝
- If you pass a BeautifulSoup document it may be modified.
- A hosted version of `mf2py` is available at [python.microformats.io](https://python.microformats.io).
## Contributing 🛠️
We welcome contributions and bug reports via GitHub.
This project follows the [IndieWeb code of conduct](https://indieweb.org/code-of-conduct). Please be respectful of other contributors and forge a spirit of positive co-operation without discrimination or disrespect.
## License 🧑⚖️
`mf2py` is licensed under an MIT License.
mf2py-2.0.1/docs/ 0000775 0000000 0000000 00000000000 14534511526 0013505 5 ustar 00root root 0000000 0000000 mf2py-2.0.1/docs/banner.png 0000664 0000000 0000000 00000123574 14534511526 0015474 0 ustar 00root root 0000000 0000000 PNG
IHDR ', pHYs sRGB gAMA a IDATxk\yO^^(TJ !AJbA[ڱ%9Ƴ6g#v=Y{7;㍍=bYKkmKזD5EH$H
IQ@+39̪s?dVf%\Rw? PHI @a X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ XP NyDvM)?u:R)ʻh&7/;~] F [Zܱ>94w|`ߗ\Ws?jrc{I$n*o.{ F [\{imebdVП펹?n˕E %,Heuh]-K2&egDq1kL]f&nwvUO;'/djtVg[P lO 㔤\J4*m]6%7w緞g'ɞ23~/~fo ]UJ F` u|rtL햝n91Sn
קeߎcW^r*^7+܇QZ~+@y{yɣO;huZ>pgݟޓo\+ys^_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