dict2str


Namedict2str JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/arcturus-script/dict2str
SummaryA tool supports converting dictionary to markdown, html and txt.
upload_time2024-10-03 09:09:46
maintainerNone
docs_urlNone
authorARCTURUS
requires_pythonNone
licenseMIT Licence
keywords dict markdown html txt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dict2str

Support converting dictionary to markdown, html and txt

## Usage

### Input list

```python
d = dict2str(
    [
        {
            "taskList": {
                "contents": [
                    {
                        "content": "run 100 kilometers",
                        "style": "color: red",
                    },
                    {
                        "content": "do homeworks",
                        "complete": True,
                    },
                ]
            },
        },
    ],
    type="html",
)

print(d)

d.set("markdown")

print(d)

d.set("txt")

print(d)

# <label>
#   <input style='color: red' type='checkbox' disabled='true'>run 100 kilometers</input>
# </label>
# <label>
#   <input type='checkbox' disabled='true' checked>do homeworks</input>
# </label>

# - [ ] run 100 kilometers
# - [x] do homeworks

# 馃敶 run 100 kilometers
# 馃煝 do homeworks
```

```python
d = dict2str(
    [
        {
            "orderedList": {
                "contents": [
                    {
                        "content": "A",
                        "items": {
                            "unOrderedList": {
                                "contents": [
                                    {
                                        "content": "B",
                                        "items": {
                                            "orderedList": {
                                                "contents": [
                                                    {
                                                        "content": "C",
                                                    },
                                                    {
                                                        "content": "D",
                                                    },
                                                ],
                                            }
                                        },
                                    },
                                    {
                                        "content": "E",
                                        "items": {
                                            "unOrderedList": {
                                                "contents": [
                                                    {
                                                        "content": "F",
                                                    },
                                                    {
                                                        "content": "G",
                                                    },
                                                ],
                                            }
                                        },
                                    },
                                ],
                            }
                        },
                    },
                    {
                        "content": "H",
                    },
                ],
            },
            "unOrderedList": {
                "contents": [
                    {
                        "content": "run 100 kilometers",
                    },
                    {
                        "content": "do homeworks",
                    },
                ],
            },
        },
    ],
    type="markdown",
)

print(d)

# 1. A
#   - B
#     1. C
#     2. D
#   - E
#     - F
#     - G
# 2. H
# - run 100 kilometers
# - do homeworks
```

### Input dictionary

```python
d = dict2str(
    {
        "img": {
            "url": "https://abc.png",
            "alt": "this is an image",
        }
    },
    type="markdown",
)

print(d)

# ![this is an image](https://abc.png)
```

## Support elements

| type            | Element        | Example                                                                                                            |
| --------------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |
| `h1`            | Heading 1      | `{ "h1": { "content": "title 1" } }`                                                                               |
| `h2`            | Heading 2      | `{ "h2": { "content": "title 2" } }`                                                                               |
| `h3`            | Heading 3      | `{ "h3": { "content": "title 3" } }`                                                                               |
| `h4`            | Heading 4      | `{ "h4": { "content": "title 4" } }`                                                                               |
| `h5`            | Heading 5      | `{ "h5": { "content": "title 5" } }`                                                                               |
| `h6`            | Heading 6      | `{ "h6": { "content": "title 6" } }`                                                                               |
| `blockquote`    | Blockquote     | `{ "blockquote": { "content": "This is a blockquote" } }`                                                          |
| `img`           | Image          | `{ "img": { "url": "https://abc.png", "alt": "this is an image", } }`                                              |
| `ul`            | Unordered list | `{ "unOrderedList": { "contents": [{"content": "run 100 kilometers"}, {"content": "do homeworks"}]}}`              |
| `ol`            | Ordered list   | `{ "orderedList": { "contents": [{"content": "run 100 kilometers"}, {"content": "do homeworks"}]}}`                |
| `table`         | Table          | `{ "table": { "contents": [("desc", "content"), ("A", "B")], "position": "left" }`                                 |
| `link`          | Link           | `{ "link": { "url": "https://google.com", "content": "this is a link" }`                                           |
| `tasklist`      | Task list      | `{ "tasklist": "contents": [{"content": "run 100 kilometers" },{ "content": "do homeworks", "complete": True }] }` |
| `code`          | Code           | `{ "code": { "content": "print('hello')" } }`                                                                      |
| `italic`        | Italic         | `{ "italic": { "content": "good" } }`                                                                              |
| `strikethrough` | Strikethrough  | `{ "strikethrough": { "content": "nice" } }`                                                                       |
| `bold`          | Bold           | `{ "bold": { "content": "excellent", "end": "\n" } }`                                                              |

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arcturus-script/dict2str",
    "name": "dict2str",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "dict, markdown, html, txt",
    "author": "ARCTURUS",
    "author_email": "ice99125@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/24/d1c90f2de53b269fae0a993663bed486ab84d351e6df7924625b8faab1bd/dict2str-0.0.3.tar.gz",
    "platform": "any",
    "description": "# dict2str\r\n\r\nSupport converting dictionary to markdown, html and txt\r\n\r\n## Usage\r\n\r\n### Input list\r\n\r\n```python\r\nd = dict2str(\r\n    [\r\n        {\r\n            \"taskList\": {\r\n                \"contents\": [\r\n                    {\r\n                        \"content\": \"run 100 kilometers\",\r\n                        \"style\": \"color: red\",\r\n                    },\r\n                    {\r\n                        \"content\": \"do homeworks\",\r\n                        \"complete\": True,\r\n                    },\r\n                ]\r\n            },\r\n        },\r\n    ],\r\n    type=\"html\",\r\n)\r\n\r\nprint(d)\r\n\r\nd.set(\"markdown\")\r\n\r\nprint(d)\r\n\r\nd.set(\"txt\")\r\n\r\nprint(d)\r\n\r\n# <label>\r\n#   <input style='color: red' type='checkbox' disabled='true'>run 100 kilometers</input>\r\n# </label>\r\n# <label>\r\n#   <input type='checkbox' disabled='true' checked>do homeworks</input>\r\n# </label>\r\n\r\n# - [ ] run 100 kilometers\r\n# - [x] do homeworks\r\n\r\n# \u9983\u6576 run 100 kilometers\r\n# \u9983\u715d do homeworks\r\n```\r\n\r\n```python\r\nd = dict2str(\r\n    [\r\n        {\r\n            \"orderedList\": {\r\n                \"contents\": [\r\n                    {\r\n                        \"content\": \"A\",\r\n                        \"items\": {\r\n                            \"unOrderedList\": {\r\n                                \"contents\": [\r\n                                    {\r\n                                        \"content\": \"B\",\r\n                                        \"items\": {\r\n                                            \"orderedList\": {\r\n                                                \"contents\": [\r\n                                                    {\r\n                                                        \"content\": \"C\",\r\n                                                    },\r\n                                                    {\r\n                                                        \"content\": \"D\",\r\n                                                    },\r\n                                                ],\r\n                                            }\r\n                                        },\r\n                                    },\r\n                                    {\r\n                                        \"content\": \"E\",\r\n                                        \"items\": {\r\n                                            \"unOrderedList\": {\r\n                                                \"contents\": [\r\n                                                    {\r\n                                                        \"content\": \"F\",\r\n                                                    },\r\n                                                    {\r\n                                                        \"content\": \"G\",\r\n                                                    },\r\n                                                ],\r\n                                            }\r\n                                        },\r\n                                    },\r\n                                ],\r\n                            }\r\n                        },\r\n                    },\r\n                    {\r\n                        \"content\": \"H\",\r\n                    },\r\n                ],\r\n            },\r\n            \"unOrderedList\": {\r\n                \"contents\": [\r\n                    {\r\n                        \"content\": \"run 100 kilometers\",\r\n                    },\r\n                    {\r\n                        \"content\": \"do homeworks\",\r\n                    },\r\n                ],\r\n            },\r\n        },\r\n    ],\r\n    type=\"markdown\",\r\n)\r\n\r\nprint(d)\r\n\r\n# 1. A\r\n#   - B\r\n#     1. C\r\n#     2. D\r\n#   - E\r\n#     - F\r\n#     - G\r\n# 2. H\r\n# - run 100 kilometers\r\n# - do homeworks\r\n```\r\n\r\n### Input dictionary\r\n\r\n```python\r\nd = dict2str(\r\n    {\r\n        \"img\": {\r\n            \"url\": \"https://abc.png\",\r\n            \"alt\": \"this is an image\",\r\n        }\r\n    },\r\n    type=\"markdown\",\r\n)\r\n\r\nprint(d)\r\n\r\n# ![this is an image](https://abc.png)\r\n```\r\n\r\n## Support elements\r\n\r\n| type            | Element        | Example                                                                                                            |\r\n| --------------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |\r\n| `h1`            | Heading 1      | `{ \"h1\": { \"content\": \"title 1\" } }`                                                                               |\r\n| `h2`            | Heading 2      | `{ \"h2\": { \"content\": \"title 2\" } }`                                                                               |\r\n| `h3`            | Heading 3      | `{ \"h3\": { \"content\": \"title 3\" } }`                                                                               |\r\n| `h4`            | Heading 4      | `{ \"h4\": { \"content\": \"title 4\" } }`                                                                               |\r\n| `h5`            | Heading 5      | `{ \"h5\": { \"content\": \"title 5\" } }`                                                                               |\r\n| `h6`            | Heading 6      | `{ \"h6\": { \"content\": \"title 6\" } }`                                                                               |\r\n| `blockquote`    | Blockquote     | `{ \"blockquote\": { \"content\": \"This is a blockquote\" } }`                                                          |\r\n| `img`           | Image          | `{ \"img\": { \"url\": \"https://abc.png\", \"alt\": \"this is an image\", } }`                                              |\r\n| `ul`            | Unordered list | `{ \"unOrderedList\": { \"contents\": [{\"content\": \"run 100 kilometers\"}, {\"content\": \"do homeworks\"}]}}`              |\r\n| `ol`            | Ordered list   | `{ \"orderedList\": { \"contents\": [{\"content\": \"run 100 kilometers\"}, {\"content\": \"do homeworks\"}]}}`                |\r\n| `table`         | Table          | `{ \"table\": { \"contents\": [(\"desc\", \"content\"), (\"A\", \"B\")], \"position\": \"left\" }`                                 |\r\n| `link`          | Link           | `{ \"link\": { \"url\": \"https://google.com\", \"content\": \"this is a link\" }`                                           |\r\n| `tasklist`      | Task list      | `{ \"tasklist\": \"contents\": [{\"content\": \"run 100 kilometers\" },{ \"content\": \"do homeworks\", \"complete\": True }] }` |\r\n| `code`          | Code           | `{ \"code\": { \"content\": \"print('hello')\" } }`                                                                      |\r\n| `italic`        | Italic         | `{ \"italic\": { \"content\": \"good\" } }`                                                                              |\r\n| `strikethrough` | Strikethrough  | `{ \"strikethrough\": { \"content\": \"nice\" } }`                                                                       |\r\n| `bold`          | Bold           | `{ \"bold\": { \"content\": \"excellent\", \"end\": \"\\n\" } }`                                                              |\r\n",
    "bugtrack_url": null,
    "license": "MIT Licence",
    "summary": "A tool supports converting dictionary to markdown, html and txt.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/arcturus-script/dict2str"
    },
    "split_keywords": [
        "dict",
        " markdown",
        " html",
        " txt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f24d1c90f2de53b269fae0a993663bed486ab84d351e6df7924625b8faab1bd",
                "md5": "217d5fdae5b3cc6f0a605a7802677c15",
                "sha256": "d7203f211607a9e9ebb862929b77bc95c67c14dcc09c3c347d1d64e911151091"
            },
            "downloads": -1,
            "filename": "dict2str-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "217d5fdae5b3cc6f0a605a7802677c15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5956,
            "upload_time": "2024-10-03T09:09:46",
            "upload_time_iso_8601": "2024-10-03T09:09:46.033142Z",
            "url": "https://files.pythonhosted.org/packages/3f/24/d1c90f2de53b269fae0a993663bed486ab84d351e6df7924625b8faab1bd/dict2str-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-03 09:09:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arcturus-script",
    "github_project": "dict2str",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dict2str"
}
        
Elapsed time: 0.33453s