| Name | mobiledoc JSON |
| Version |
0.3.1
JSON |
| download |
| home_page | |
| Summary | A Python package aimed to simplify the processing of the mobiledoc format. |
| upload_time | 2023-10-26 02:39:00 |
| maintainer | |
| docs_url | None |
| author | |
| requires_python | >=3.7 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
mobiledoc
setuptools
markdownify
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# **Mobiledoc**
A Python package aimed to simplify the processing of the mobiledoc format.
## **Features**
- **Simple API**: Intuitive methods to easily add text, formatted text, dividers, and custom data.
- **Markdown-like Formatting**: Write using familiar markdown-like syntax, and let the package do the heavy lifting.
- **Convert HTML to Markdown**: Convert HTML to markdown using the `add_markdown_from_html()` method.
- **Serialization**: Serialize the mobiledoc object into a JSON-friendly format.
## **Installation**
`pip install mobiledoc`
[PyPi](https://pypi.org/project/mobiledoc/)
## **Example**
```python
from mobiledoc import Mobiledoc
import json
mobiledoc = Mobiledoc()
mobiledoc.add_basic_text("This is a basic text, which is not formatted.")
mobiledoc.add_basic_text(["You may also add a list of strings.", "To add multiple paragraphs."])
mobiledoc.add_divider() # add a divider
mobiledoc.add_formatted_text("Using **markdown-like** syntax, you can *format* the text.")
mobiledoc.add_formatted_text(["You may also add a `list of strings`.", "To ^add^ ^^multiple^^ paragraphs.",
"You can also add [hyperlinks](https://python.org)."])
mobiledoc = mobiledoc.serialize() # This will save the mobiledoc as a dictionary
with open('doc.json', 'w') as f:
json.dump(mobiledoc, f, indent=4) # check out the doc.json file to see the mobiledoc just created!
```
This will create redy-to-use mobiledoc like below. (click expand to see the mobiledoc)
<details>
<summary>Full mobiledoc</summary>
```json
{
"version": "0.3.2",
"markups": [
["b"],
["i"],
["code"],
["sub"],
["sup"],
["a", ["href", "https://python.org"]]
],
"atoms": [],
"cards": [
["hr", {}]
],
"sections": [
[1, "p", [
[0, [], 0, "This is a basic text, which is not formatted."]
]],
[1, "p", [
[0, [], 0, "You may also add a list of strings."]
]],
[1, "p", [
[0, [], 0, "To add multiple paragraphs."]
]],
[10, 0],
[1, "p", [
[0, [], 0, "Using "],
[0, [0], 1, "markdown-like"],
[0, [], 0, " syntax, you can "],
[0, [1], 1, "format"],
[0, [], 0, " the text."]
]],
[1, "p", [
[0, [], 0, "You may also add a "],
[0, [2], 1, "list of strings"],
[0, [], 0, "."]
]],
[1, "p", [
[0, [], 0, "To "],
[0, [3], 1, "add"],
[0, [], 0, " "],
[0, [4], 1, "multiple"],
[0, [], 0, " paragraphs."]
]],
[1, "p", [
[0, [], 0, "You can also add "],
[0, [5], 1, "hyperlinks"],
[0, [], 0, "."]
]]
]
}
```
</details>
## **API**
### Composing mobiledoc
- **`add_basic_text(text: Union[str, List[str]])`**: Adds basic text to mobiledoc.
- **`add_formatted_text(text: Union[str, List[str]])`**: Adds markdown-like formatted text to mobiledoc.
- **Supported Markdown-like Patterns:**
```
**: bold
*: italic
~~: strikethrough
^^: superscript
^: subscript
__: underline
`: code
[text](link): hyperlink
```
- **`add_divider()`**: Adds a divider to mobiledoc.
- **`add_image(url: str, caption: str = None)`**: Adds an image to mobiledoc.
- **`add_button(text: str, url: str, alignment:str = "center")`**: Adds a button to mobiledoc.
- **`add_HTML(self, html:str):`**: Adds raw HTML card to mobiledoc.
- **`add_markdown(self, markdown:str):`**: Adds raw markdown card to mobiledoc.
- **`add_file(self, url: str, filename: str, filetitle: str, filesize: int, filecaption: str = ""):`**: Adds a file to mobiledoc.
- **`add_callout(self, text: str, emoji: str = "", color: str = "accent"):`**: Adds a callout to mobiledoc.
- **`add_markdown_from_html(html_string: str):`**: Adds markdown from HTML to mobiledoc.
- **`custom_data(name: str, value)`**: Adds custom data to mobiledoc.
### Serializing mobiledoc
- **`serialize()`**: Returns the serialized mobiledoc Python dictionary that can be passed to `json.dump()`.
### Checking mobiledoc
- **`get_markups()`**: Returns the current markups.
- **`get_sections()`**: Returns the current sections.
- **`get_atoms()`**: Returns the current atoms.
- **`get_cards()`**: Returns the current cards.
- **`get_custom()`**: Returns the current custom data.
## **Contributing**
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
---
I hope this README provides a clear overview of the **`mobiledoc`** package. You can further customize it as per your needs!
Raw data
{
"_id": null,
"home_page": "",
"name": "mobiledoc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Suh Jae <wonyul@joseon.space>",
"download_url": "https://files.pythonhosted.org/packages/5e/9a/af76dff9e423436bc26c022a791a286ecab8852c01707867a6b105e11d3b/mobiledoc-0.3.1.tar.gz",
"platform": null,
"description": "# **Mobiledoc**\n\nA Python package aimed to simplify the processing of the mobiledoc format.\n\n## **Features**\n\n- **Simple API**: Intuitive methods to easily add text, formatted text, dividers, and custom data.\n- **Markdown-like Formatting**: Write using familiar markdown-like syntax, and let the package do the heavy lifting.\n- **Convert HTML to Markdown**: Convert HTML to markdown using the `add_markdown_from_html()` method.\n- **Serialization**: Serialize the mobiledoc object into a JSON-friendly format.\n\n## **Installation**\n\n`pip install mobiledoc`\n[PyPi](https://pypi.org/project/mobiledoc/)\n\n## **Example**\n\n```python\nfrom mobiledoc import Mobiledoc\nimport json\n\nmobiledoc = Mobiledoc()\nmobiledoc.add_basic_text(\"This is a basic text, which is not formatted.\")\nmobiledoc.add_basic_text([\"You may also add a list of strings.\", \"To add multiple paragraphs.\"])\nmobiledoc.add_divider() # add a divider\nmobiledoc.add_formatted_text(\"Using **markdown-like** syntax, you can *format* the text.\")\nmobiledoc.add_formatted_text([\"You may also add a `list of strings`.\", \"To ^add^ ^^multiple^^ paragraphs.\",\n \"You can also add [hyperlinks](https://python.org).\"])\n\nmobiledoc = mobiledoc.serialize() # This will save the mobiledoc as a dictionary\n\nwith open('doc.json', 'w') as f:\n json.dump(mobiledoc, f, indent=4) # check out the doc.json file to see the mobiledoc just created!\n\n```\nThis will create redy-to-use mobiledoc like below. (click expand to see the mobiledoc)\n<details>\n <summary>Full mobiledoc</summary>\n\n ```json\n {\n \"version\": \"0.3.2\",\n \"markups\": [\n [\"b\"],\n [\"i\"],\n [\"code\"],\n [\"sub\"],\n [\"sup\"],\n [\"a\", [\"href\", \"https://python.org\"]]\n ],\n \"atoms\": [],\n \"cards\": [\n [\"hr\", {}]\n ],\n \"sections\": [\n [1, \"p\", [\n [0, [], 0, \"This is a basic text, which is not formatted.\"]\n ]],\n [1, \"p\", [\n [0, [], 0, \"You may also add a list of strings.\"]\n ]],\n [1, \"p\", [\n [0, [], 0, \"To add multiple paragraphs.\"]\n ]],\n [10, 0],\n [1, \"p\", [\n [0, [], 0, \"Using \"],\n [0, [0], 1, \"markdown-like\"],\n [0, [], 0, \" syntax, you can \"],\n [0, [1], 1, \"format\"],\n [0, [], 0, \" the text.\"]\n ]],\n [1, \"p\", [\n [0, [], 0, \"You may also add a \"],\n [0, [2], 1, \"list of strings\"],\n [0, [], 0, \".\"]\n ]],\n [1, \"p\", [\n [0, [], 0, \"To \"],\n [0, [3], 1, \"add\"],\n [0, [], 0, \" \"],\n [0, [4], 1, \"multiple\"],\n [0, [], 0, \" paragraphs.\"]\n ]],\n [1, \"p\", [\n [0, [], 0, \"You can also add \"],\n [0, [5], 1, \"hyperlinks\"],\n [0, [], 0, \".\"]\n ]]\n ]\n }\n ```\n</details>\n\n## **API**\n\n### Composing mobiledoc\n- **`add_basic_text(text: Union[str, List[str]])`**: Adds basic text to mobiledoc.\n- **`add_formatted_text(text: Union[str, List[str]])`**: Adds markdown-like formatted text to mobiledoc.\n - **Supported Markdown-like Patterns:**\n ```\n **: bold\n *: italic\n ~~: strikethrough\n ^^: superscript\n ^: subscript\n __: underline\n `: code\n [text](link): hyperlink\n ```\n- **`add_divider()`**: Adds a divider to mobiledoc.\n- **`add_image(url: str, caption: str = None)`**: Adds an image to mobiledoc.\n- **`add_button(text: str, url: str, alignment:str = \"center\")`**: Adds a button to mobiledoc.\n- **`add_HTML(self, html:str):`**: Adds raw HTML card to mobiledoc.\n- **`add_markdown(self, markdown:str):`**: Adds raw markdown card to mobiledoc.\n- **`add_file(self, url: str, filename: str, filetitle: str, filesize: int, filecaption: str = \"\"):`**: Adds a file to mobiledoc.\n- **`add_callout(self, text: str, emoji: str = \"\", color: str = \"accent\"):`**: Adds a callout to mobiledoc.\n- **`add_markdown_from_html(html_string: str):`**: Adds markdown from HTML to mobiledoc.\n\n\n- **`custom_data(name: str, value)`**: Adds custom data to mobiledoc.\n\n### Serializing mobiledoc\n- **`serialize()`**: Returns the serialized mobiledoc Python dictionary that can be passed to `json.dump()`.\n\n### Checking mobiledoc\n- **`get_markups()`**: Returns the current markups.\n- **`get_sections()`**: Returns the current sections.\n- **`get_atoms()`**: Returns the current atoms.\n- **`get_cards()`**: Returns the current cards.\n- **`get_custom()`**: Returns the current custom data.\n\n\n## **Contributing**\n\nContributions are welcome! Please submit a pull request or open an issue on GitHub.\n\n---\n\nI hope this README provides a clear overview of the **`mobiledoc`** package. You can further customize it as per your needs!\n",
"bugtrack_url": null,
"license": "",
"summary": "A Python package aimed to simplify the processing of the mobiledoc format.",
"version": "0.3.1",
"project_urls": {
"Bug Tracker": "https://github.com/SuhJae/mobiledoc-py/issues",
"Homepage": "https://github.com/SuhJae/mobiledoc-py/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "542c615e05ed19e158c4cdc77de64b429fb5a95ad9472b3b8ab9471306b56318",
"md5": "3604dcf076866e8c3b56b8990aeb1edf",
"sha256": "6d88d9ec0a25be5bc215ccc9e6337ba37bb7c3359d511aad575a8daa3591ed3c"
},
"downloads": -1,
"filename": "mobiledoc-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3604dcf076866e8c3b56b8990aeb1edf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7904,
"upload_time": "2023-10-26T02:38:58",
"upload_time_iso_8601": "2023-10-26T02:38:58.212698Z",
"url": "https://files.pythonhosted.org/packages/54/2c/615e05ed19e158c4cdc77de64b429fb5a95ad9472b3b8ab9471306b56318/mobiledoc-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5e9aaf76dff9e423436bc26c022a791a286ecab8852c01707867a6b105e11d3b",
"md5": "fed62c369cca4f2d1186d2148c908fe4",
"sha256": "3e488fb576ea0c744a6f79f352e47b8d99d4dc9a3e4915c93cc755f5cc947245"
},
"downloads": -1,
"filename": "mobiledoc-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "fed62c369cca4f2d1186d2148c908fe4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7101,
"upload_time": "2023-10-26T02:39:00",
"upload_time_iso_8601": "2023-10-26T02:39:00.327653Z",
"url": "https://files.pythonhosted.org/packages/5e/9a/af76dff9e423436bc26c022a791a286ecab8852c01707867a6b105e11d3b/mobiledoc-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-26 02:39:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SuhJae",
"github_project": "mobiledoc-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "mobiledoc",
"specs": [
[
"~=",
"0.2.1"
]
]
},
{
"name": "setuptools",
"specs": [
[
"~=",
"68.2.2"
]
]
},
{
"name": "markdownify",
"specs": [
[
"~=",
"0.11.6"
]
]
}
],
"lcname": "mobiledoc"
}