Name | t-python-markdown JSON |
Version |
1.4.1
JSON |
| download |
home_page | |
Summary | A simple to use markdown generator for Python. |
upload_time | 2023-05-21 12:26:58 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2023 Toyne 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. |
keywords |
markdown
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# t-python-markdown
A simple to use markdown generator for Python.
## Installation
```
pip install t-python-markdown
```
## Example
```python
from t_python_markdown import Document, Header, Paragraph, Sentence, Bold, Table, UnorderedList
import time
import requests
j = requests.get("https://api.coindesk.com/v1/bpi/currentprice.json").json()
bpi = j["bpi"]
front_matter = {
"title": j["chartName"],
"authors": ["A.U.Thor"],
"date": time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
}
doc = Document(front_matter)
doc >> Header(j["chartName"], 1)
doc >> Paragraph([j["disclaimer"]])
al = [("--:" if isinstance(_, (int, float)) else ":-:" if _.startswith("&") else ":--") for _ in bpi[list(bpi.keys())[0]].values()]
t = Table([_.replace("_", " ").title() for _ in bpi[list(bpi.keys())[0]].keys()], alignment=al)
doc >> t
ul = UnorderedList()
doc >> Paragraph("Bitcoin Price Index")
doc >> ul
for k, v in bpi.items():
t >> [_ for _ in bpi[k].values()]
ul >> Sentence([Bold(k), bpi[k]["description"]])
# Write markdown to file
doc.write("example.md")
```
Saved as `example.py` then running `python example.py` results in:
```markdown
---
title: Bitcoin
authors:
- A.U.Thor
date: '2023-02-25T14:17:02Z'
...
# Bitcoin
This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org
| **Code** | **Symbol** | **Rate** | **Description** | **Rate Float** |
| :-- | :-: | :-- | :-- | --: |
| USD | $ | 23,007.6135 | United States Dollar | 23007.6135 |
| GBP | £ | 19,224.9778 | British Pound Sterling | 19224.9778 |
| EUR | € | 22,412.7746 | Euro | 22412.7746 |
Bitcoin Price Index
- **USD** United States Dollar.
- **GBP** British Pound Sterling.
- **EUR** Euro.
```
## Usage
For usage, see https://www.cix.co.uk/~toyne/t-python-markdown/usage/
## Recent Changelog
**1.4.1**
- Resolve issue where embedding tables in lists in tables in lists in tables (etc...) would not render correctly
**1.4.0**
- Improve support for embedded lists and tables. Now able to wrap child items in other markdown elements
**1.3.2**
- Add support for attribute lists when processing embedded lists
**1.3.1**
- Add support for attribute lists when processing embedded tables
**1.3.0**
- Add support for tables and lists embedded in other tables and lists
**1.2.1**
- Bring into line with docs site
**1.2.0**
- Add support for Strikethrough
Raw data
{
"_id": null,
"home_page": "",
"name": "t-python-markdown",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "t-python-markdown <t-python-markdown@toyne.cix.co.uk>",
"keywords": "markdown",
"author": "",
"author_email": "t-python-markdown <t-python-markdown@toyne.cix.co.uk>",
"download_url": "https://files.pythonhosted.org/packages/35/5a/9b02308c3575aca1a8aa2332044be0510bff0a66bd611661b60784b0e473/t_python_markdown-1.4.1.tar.gz",
"platform": null,
"description": "# t-python-markdown\n\nA simple to use markdown generator for Python.\n\n\n## Installation\n```\npip install t-python-markdown\n```\n\n\n## Example\n\n```python\nfrom t_python_markdown import Document, Header, Paragraph, Sentence, Bold, Table, UnorderedList\nimport time\nimport requests\n\nj = requests.get(\"https://api.coindesk.com/v1/bpi/currentprice.json\").json()\nbpi = j[\"bpi\"]\n\nfront_matter = {\n \"title\": j[\"chartName\"],\n \"authors\": [\"A.U.Thor\"],\n \"date\": time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),\n}\n\ndoc = Document(front_matter)\ndoc >> Header(j[\"chartName\"], 1)\ndoc >> Paragraph([j[\"disclaimer\"]])\nal = [(\"--:\" if isinstance(_, (int, float)) else \":-:\" if _.startswith(\"&\") else \":--\") for _ in bpi[list(bpi.keys())[0]].values()]\nt = Table([_.replace(\"_\", \" \").title() for _ in bpi[list(bpi.keys())[0]].keys()], alignment=al)\ndoc >> t\nul = UnorderedList()\ndoc >> Paragraph(\"Bitcoin Price Index\")\ndoc >> ul\n\nfor k, v in bpi.items():\n t >> [_ for _ in bpi[k].values()]\n ul >> Sentence([Bold(k), bpi[k][\"description\"]])\n\n# Write markdown to file\ndoc.write(\"example.md\")\n```\n\nSaved as `example.py` then running `python example.py` results in:\n\n```markdown\n---\ntitle: Bitcoin\nauthors:\n- A.U.Thor\ndate: '2023-02-25T14:17:02Z'\n...\n\n# Bitcoin\n\nThis data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org\n\n| **Code** | **Symbol** | **Rate** | **Description** | **Rate Float** |\n| :-- | :-: | :-- | :-- | --: |\n| USD | $ | 23,007.6135 | United States Dollar | 23007.6135 |\n| GBP | £ | 19,224.9778 | British Pound Sterling | 19224.9778 |\n| EUR | € | 22,412.7746 | Euro | 22412.7746 |\n\nBitcoin Price Index\n\n- **USD** United States Dollar.\n- **GBP** British Pound Sterling.\n- **EUR** Euro.\n```\n\n\n## Usage\nFor usage, see https://www.cix.co.uk/~toyne/t-python-markdown/usage/\n\n\n## Recent Changelog\n**1.4.1** \n- Resolve issue where embedding tables in lists in tables in lists in tables (etc...) would not render correctly\n\n**1.4.0** \n- Improve support for embedded lists and tables. Now able to wrap child items in other markdown elements\n\n**1.3.2** \n- Add support for attribute lists when processing embedded lists\n\n**1.3.1** \n- Add support for attribute lists when processing embedded tables\n\n**1.3.0** \n- Add support for tables and lists embedded in other tables and lists\n\n**1.2.1** \n- Bring into line with docs site\n\n**1.2.0** \n- Add support for Strikethrough\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Toyne 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. ",
"summary": "A simple to use markdown generator for Python.",
"version": "1.4.1",
"project_urls": {
"documentation": "https://www.cix.co.uk/~toyne/t-python-markdown/",
"homepage": "https://www.cix.co.uk/~toyne/t-python-markdown/"
},
"split_keywords": [
"markdown"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "583be04cf490060f74168e0cd0448a4536032baf905b62b7d93e1d57eeec6964",
"md5": "0f6bdd848aa0a38bd113c37ca940a42f",
"sha256": "64c9cc1b88abbb41d77b4811b5dff775f1ee8ef7ff91889ebba83a2a48643aa6"
},
"downloads": -1,
"filename": "t_python_markdown-1.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0f6bdd848aa0a38bd113c37ca940a42f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8180,
"upload_time": "2023-05-21T12:26:56",
"upload_time_iso_8601": "2023-05-21T12:26:56.349234Z",
"url": "https://files.pythonhosted.org/packages/58/3b/e04cf490060f74168e0cd0448a4536032baf905b62b7d93e1d57eeec6964/t_python_markdown-1.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "355a9b02308c3575aca1a8aa2332044be0510bff0a66bd611661b60784b0e473",
"md5": "1c5da49e56468a63dec0984db3dae5e7",
"sha256": "7f6541c03d9a53fb6521e8ac27b5fd57225ec2b773b38b6717736033e5ebd649"
},
"downloads": -1,
"filename": "t_python_markdown-1.4.1.tar.gz",
"has_sig": false,
"md5_digest": "1c5da49e56468a63dec0984db3dae5e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8448,
"upload_time": "2023-05-21T12:26:58",
"upload_time_iso_8601": "2023-05-21T12:26:58.206700Z",
"url": "https://files.pythonhosted.org/packages/35/5a/9b02308c3575aca1a8aa2332044be0510bff0a66bd611661b60784b0e473/t_python_markdown-1.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-21 12:26:58",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "t-python-markdown"
}