linkedtext


Namelinkedtext JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/kurotom/linkedText
SummaryEasily generate links and table of contents in Markdown files.
upload_time2024-03-02 03:58:56
maintainer
docs_urlNone
authorkurotom
requires_python>=3.7,<4.0
licenseLGPL-3.0-or-later
keywords text links index
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # linkedText

It allows to create a table of contents and link them to the different titles of a Markdown document, without altering the original file and generating a new one.

The idea came up to automate this manual process, it was tedious to write and check that each title has its link and create the table of contents. Now I simply write the content, run the program and I have the finished document.


## Installation

```bash
$ pip install linkedtext
```

## Usage CLI

1. Help

```bash
usage: linkedtext [-h] -f FILENAME

options:
  -h, --help            show this help message and exit
  -f FILENAME, --filename FILENAME
                        Markdown file.
```

2. In the terminal

```bash
$ linkedtext -f path/my_file.md
```


## Usage - Python

The `LinkedText` class supports both Markdown files (`markdown_file` parameter) and strings in Markdown format (`string` parameter).


* Markdown file

When passing a Markdown file, it will be parsed and processed, generating a new file with the same name as the original and ending with `_finish`. The original file is never altered. Writing is automatic.

```python
>>> from linkedtext import LinkedText
>>>
>>> c = LinkedText(markdown_file='my_file.md')
>>> c.process()
>>> c.to_write()
```


* Markdown string

When a Markdown string is used, the result will be displayed in the terminal, it can be written to a file, this will be named `linkedtext_finish.md` by default.


```python
>>> from linkedtext import LinkedText
>>>
>>> c = LinkedText(string=string_markdown)
>>> c.process()
>>> c.to_write()
```


## Sample

* String Markdown

```python
string = """
# First

First paragraph.

## Second

Second paragraph.

# Third

Third paragraph.


# Fourth

Fourth paragraph.
"""

from linkedtext import LinkedText

c = LinkedText(string=string)
c.process()
# c.to_write()   # write to the `linkedtext_finish.md` file.
```

* Output

```markdown
1. [First](#first)
    1. [Second](#second)
2. [Third](#third)
3. [Fourth](#fourth)

\pagebreak


<a name="first"></a>

# First

First paragraph.

<a name="second"></a>

## Second

Second paragraph.

<a name="third"></a>

# Third

Third paragraph.


<a name="fourth"></a>

# Fourth

Fourth paragraph.

```


# Tests

```bash
. run_tests.sh
# or
python -m unittest
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kurotom/linkedText",
    "name": "linkedtext",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "text,links,index",
    "author": "kurotom",
    "author_email": "55354389+kurotom@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/1e/ecd748a608f54e1be2d7ce8ca784a0196548887fcb989586fbc04e7b87f7/linkedtext-0.1.3.tar.gz",
    "platform": null,
    "description": "# linkedText\n\nIt allows to create a table of contents and link them to the different titles of a Markdown document, without altering the original file and generating a new one.\n\nThe idea came up to automate this manual process, it was tedious to write and check that each title has its link and create the table of contents. Now I simply write the content, run the program and I have the finished document.\n\n\n## Installation\n\n```bash\n$ pip install linkedtext\n```\n\n## Usage CLI\n\n1. Help\n\n```bash\nusage: linkedtext [-h] -f FILENAME\n\noptions:\n  -h, --help            show this help message and exit\n  -f FILENAME, --filename FILENAME\n                        Markdown file.\n```\n\n2. In the terminal\n\n```bash\n$ linkedtext -f path/my_file.md\n```\n\n\n## Usage - Python\n\nThe `LinkedText` class supports both Markdown files (`markdown_file` parameter) and strings in Markdown format (`string` parameter).\n\n\n* Markdown file\n\nWhen passing a Markdown file, it will be parsed and processed, generating a new file with the same name as the original and ending with `_finish`. The original file is never altered. Writing is automatic.\n\n```python\n>>> from linkedtext import LinkedText\n>>>\n>>> c = LinkedText(markdown_file='my_file.md')\n>>> c.process()\n>>> c.to_write()\n```\n\n\n* Markdown string\n\nWhen a Markdown string is used, the result will be displayed in the terminal, it can be written to a file, this will be named `linkedtext_finish.md` by default.\n\n\n```python\n>>> from linkedtext import LinkedText\n>>>\n>>> c = LinkedText(string=string_markdown)\n>>> c.process()\n>>> c.to_write()\n```\n\n\n## Sample\n\n* String Markdown\n\n```python\nstring = \"\"\"\n# First\n\nFirst paragraph.\n\n## Second\n\nSecond paragraph.\n\n# Third\n\nThird paragraph.\n\n\n# Fourth\n\nFourth paragraph.\n\"\"\"\n\nfrom linkedtext import LinkedText\n\nc = LinkedText(string=string)\nc.process()\n# c.to_write()   # write to the `linkedtext_finish.md` file.\n```\n\n* Output\n\n```markdown\n1. [First](#first)\n    1. [Second](#second)\n2. [Third](#third)\n3. [Fourth](#fourth)\n\n\\pagebreak\n\n\n<a name=\"first\"></a>\n\n# First\n\nFirst paragraph.\n\n<a name=\"second\"></a>\n\n## Second\n\nSecond paragraph.\n\n<a name=\"third\"></a>\n\n# Third\n\nThird paragraph.\n\n\n<a name=\"fourth\"></a>\n\n# Fourth\n\nFourth paragraph.\n\n```\n\n\n# Tests\n\n```bash\n. run_tests.sh\n# or\npython -m unittest\n```\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-or-later",
    "summary": "Easily generate links and table of contents in Markdown files.",
    "version": "0.1.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/kurotom/linkedText/issues",
        "Homepage": "https://github.com/kurotom/linkedText",
        "Repository": "https://github.com/kurotom/linkedText"
    },
    "split_keywords": [
        "text",
        "links",
        "index"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d62630db0f39ec0f4bad41ceb4e90755afb12dc6c5cc3e1d04ce52bba5a5687",
                "md5": "a83d1ba54055f4677e29b5b7c72218d0",
                "sha256": "461a90e0849cbeaf366ed5b2470ca82a60310857d04d41cb9805e13c73132c82"
            },
            "downloads": -1,
            "filename": "linkedtext-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a83d1ba54055f4677e29b5b7c72218d0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 6528,
            "upload_time": "2024-03-02T03:58:54",
            "upload_time_iso_8601": "2024-03-02T03:58:54.600902Z",
            "url": "https://files.pythonhosted.org/packages/7d/62/630db0f39ec0f4bad41ceb4e90755afb12dc6c5cc3e1d04ce52bba5a5687/linkedtext-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f1eecd748a608f54e1be2d7ce8ca784a0196548887fcb989586fbc04e7b87f7",
                "md5": "487d2f600cd85d3bfd9f9142435c0aee",
                "sha256": "2c365b735eaacceb8af8eee50046d2bf4f90ea116394d75d50a897c7c01b9482"
            },
            "downloads": -1,
            "filename": "linkedtext-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "487d2f600cd85d3bfd9f9142435c0aee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 5074,
            "upload_time": "2024-03-02T03:58:56",
            "upload_time_iso_8601": "2024-03-02T03:58:56.469037Z",
            "url": "https://files.pythonhosted.org/packages/6f/1e/ecd748a608f54e1be2d7ce8ca784a0196548887fcb989586fbc04e7b87f7/linkedtext-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-02 03:58:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kurotom",
    "github_project": "linkedText",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "linkedtext"
}
        
Elapsed time: 0.25020s