# Python Source Code Types For Inline Syntax Highlighting
> The original [Python Inline Source](https://github.com/samwillis/python-inline-source) by Sam Willis
> is no longer maintained. Please raise your issues and questions in
> [jurooravec/python-inline-source-2](https://github.com/jurooravec/python-inline-source-2).
>
> The PyPI package and VSCode extension have also been migrated:
> - PyPI: [sourcetypes](https://pypi.org/project/sourcetypes/) -> [sourcetypes2](https://pypi.org/project/sourcetypes2/)
> - VSCode: [samwillis.python-inline-source](https://marketplace.visualstudio.com/items?itemName=samwillis.python-inline-source) -> [jurooravec.python-inline-source-2](https://marketplace.visualstudio.com/items?itemName=jurooravec.python-inline-source-2)
>
> This fork is based on [v0.0.4](https://github.com/samwillis/python-inline-source/releases/tag/v0.0.4).
Type annotations for various languages, when applied to multi line strings will syntax
highlighting with the `python-inline-source-2` VS Code plugin.
Supports `html`, `css`, `javascript`, `typescript`, `sql`, `graphql`,
multiple *css extension languages*, *template languages* and many more,
[see below](#supported-languages) for a full list.
Uses [typing.Annotated](https://docs.python.org/3/library/typing.html#typing.Annotated)
to annotate the `str` type with the language used. You can use
[typing.get_type_hints](https://docs.python.org/3/library/typing.html#typing.get_type_hints)
at runtime to determine the language that a string has been annotated with.
On Python versions prior to 3.9 uses [typing_extensions](https://pypi.org/project/typing-extensions/) to support `Annotated` types.
## Installation
```
pip install sourcetypes2
```
## Example
[![Example](https://raw.githubusercontent.com/jurooravec/python-inline-source-2/main/sourcetypes/docs/examples.png)](docs/examples.py)
## Usage
Use a type decoration named for language that you are using:
```
import sourcetypes
my_html_string: sourcetypes.html = """
<h1>Some HTML</h1>
"""
```
or:
```
from sourcetypes import html
my_html_string: html = """
<h1>Some HTML</h1>
"""
```
## Supported Languages
- `markdown` (aliased as `md`)
- `html`
- `django_html` (aliased as `django`)
- `django_txt`
- `jinja`
- `jinja_html`
- `css` (aliased as `style`, and `styles`)
- `scss`
- `less`
- `sass`
- `stylus`
- `javascript` (aliased as `js`)
- `jsx` (aliased as `javascriptreact`, and `react`)
- `typescript` (aliased as `ts`)
- `tsx` (aliased as `typescriptreact`)
- `coffeescript` (aliased as `coffee`)
- `sql`
- `json`
- `yaml`
- `graphql`
- `xml`
- `python`
## Release Notes
### [0.0.5] - 2024-10-17
- Add `py.typed`. [#4](https://github.com/samwillis/python-inline-source/pull/4)
### [0.0.4] - 2024-10-17
- Forked from v0.0.4
## Dev notes
Install twine and build
```sh
pip install twine build
```
Packaging:
```sh
python -m build --sdist --wheel --outdir dist/ .
```
Publishing:
```sh
twine upload --repository pypi dist/* -u __token__ -p <pypi-token>
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jurooravec/python-inline-source-2/tree/main/sourcetypes",
"name": "sourcetypes2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Juro Oravec",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/c7/01/65372d32e6a3362ff78311a2e8c3963a338cc0b4be7a2c22bff2e28d7535/sourcetypes2-0.0.5.tar.gz",
"platform": null,
"description": "# Python Source Code Types For Inline Syntax Highlighting\n\n> The original [Python Inline Source](https://github.com/samwillis/python-inline-source) by Sam Willis\n> is no longer maintained. Please raise your issues and questions in\n> [jurooravec/python-inline-source-2](https://github.com/jurooravec/python-inline-source-2).\n>\n> The PyPI package and VSCode extension have also been migrated:\n> - PyPI: [sourcetypes](https://pypi.org/project/sourcetypes/) -> [sourcetypes2](https://pypi.org/project/sourcetypes2/)\n> - VSCode: [samwillis.python-inline-source](https://marketplace.visualstudio.com/items?itemName=samwillis.python-inline-source) -> [jurooravec.python-inline-source-2](https://marketplace.visualstudio.com/items?itemName=jurooravec.python-inline-source-2)\n>\n> This fork is based on [v0.0.4](https://github.com/samwillis/python-inline-source/releases/tag/v0.0.4).\n\nType annotations for various languages, when applied to multi line strings will syntax \nhighlighting with the `python-inline-source-2` VS Code plugin.\n\nSupports `html`, `css`, `javascript`, `typescript`, `sql`, `graphql`, \nmultiple *css extension languages*, *template languages* and many more, \n[see below](#supported-languages) for a full list.\n\nUses [typing.Annotated](https://docs.python.org/3/library/typing.html#typing.Annotated)\nto annotate the `str` type with the language used. You can use \n[typing.get_type_hints](https://docs.python.org/3/library/typing.html#typing.get_type_hints) \nat runtime to determine the language that a string has been annotated with.\n\nOn Python versions prior to 3.9 uses [typing_extensions](https://pypi.org/project/typing-extensions/) to support `Annotated` types.\n\n## Installation\n\n```\npip install sourcetypes2\n```\n\n## Example\n\n[![Example](https://raw.githubusercontent.com/jurooravec/python-inline-source-2/main/sourcetypes/docs/examples.png)](docs/examples.py)\n\n## Usage\n\nUse a type decoration named for language that you are using:\n\n```\nimport sourcetypes\n\nmy_html_string: sourcetypes.html = \"\"\"\n <h1>Some HTML</h1>\n\"\"\"\n```\n\nor:\n\n```\nfrom sourcetypes import html\n\nmy_html_string: html = \"\"\"\n <h1>Some HTML</h1>\n\"\"\"\n```\n\n## Supported Languages\n\n- `markdown` (aliased as `md`)\n- `html`\n- `django_html` (aliased as `django`)\n- `django_txt`\n- `jinja`\n- `jinja_html`\n- `css` (aliased as `style`, and `styles`)\n- `scss`\n- `less`\n- `sass`\n- `stylus`\n- `javascript` (aliased as `js`)\n- `jsx` (aliased as `javascriptreact`, and `react`)\n- `typescript` (aliased as `ts`)\n- `tsx` (aliased as `typescriptreact`)\n- `coffeescript` (aliased as `coffee`)\n- `sql`\n- `json`\n- `yaml`\n- `graphql`\n- `xml`\n- `python`\n\n## Release Notes\n\n### [0.0.5] - 2024-10-17\n- Add `py.typed`. [#4](https://github.com/samwillis/python-inline-source/pull/4)\n\n### [0.0.4] - 2024-10-17\n- Forked from v0.0.4\n\n## Dev notes\n\nInstall twine and build\n\n```sh\npip install twine build\n```\n\nPackaging:\n\n```sh\npython -m build --sdist --wheel --outdir dist/ .\n```\n\nPublishing:\n\n```sh\ntwine upload --repository pypi dist/* -u __token__ -p <pypi-token>\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Python Source Code Types For Inline Syntax Highlighting",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/jurooravec/python-inline-source-2/tree/main/sourcetypes"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d6114dfedddac39c11d064e2954f99fde452b0a0b1d1a4438feee41f4411e171",
"md5": "83679b1f7be43cdc5ccbfa1a72c584f0",
"sha256": "7b585fdc9d444ae8d4855bac96906c73f3551a387bde667f588440ec978379dc"
},
"downloads": -1,
"filename": "sourcetypes2-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "83679b1f7be43cdc5ccbfa1a72c584f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 3847,
"upload_time": "2024-10-17T17:38:07",
"upload_time_iso_8601": "2024-10-17T17:38:07.945984Z",
"url": "https://files.pythonhosted.org/packages/d6/11/4dfedddac39c11d064e2954f99fde452b0a0b1d1a4438feee41f4411e171/sourcetypes2-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c70165372d32e6a3362ff78311a2e8c3963a338cc0b4be7a2c22bff2e28d7535",
"md5": "0abdd43532a2179ca097022e9ed0a802",
"sha256": "6d37f8bb1a7bc05891a2c5d3a22f7ba54f734126e261df9faac3bd00dbf76b77"
},
"downloads": -1,
"filename": "sourcetypes2-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "0abdd43532a2179ca097022e9ed0a802",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 3611,
"upload_time": "2024-10-17T17:38:09",
"upload_time_iso_8601": "2024-10-17T17:38:09.700423Z",
"url": "https://files.pythonhosted.org/packages/c7/01/65372d32e6a3362ff78311a2e8c3963a338cc0b4be7a2c22bff2e28d7535/sourcetypes2-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-17 17:38:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jurooravec",
"github_project": "python-inline-source-2",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sourcetypes2"
}