An open API service indexing awesome lists of open source software.

https://github.com/proxzima/string_to_markdown_id

Convert string to GitLab Flavored Markdown Header ID
https://github.com/proxzima/string_to_markdown_id

glfm markdown python python-package

Last synced: about 2 months ago
JSON representation

Convert string to GitLab Flavored Markdown Header ID

Awesome Lists containing this project

README

          

String to Markdown Id
#####################

.. image:: https://readthedocs.org/projects/string-to-markdown-id/badge/?version=latest
:target: https://string-to-markdown-id.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

Convert string to GitLab Flavored Markdown Header ID `[1] `_

Quickstart
==========

String to Markdown Id is available on PyPI and can be installed with `pip `_.

.. code-block:: console

$ pip install string_to_markdown_id

After installing String to Markdown Id you can use it like any other Python module.

Here is a simple example:

.. code-block:: python

from string_to_markdown_id import convertToMarkdownId

testQueries = [
r"""(This) --- --v - " "" ' ' has 2.5, πŸ˜€, ν•œκΈ€, :thumbsup:, , \n, \r, \t, \f, \u, \a, \x, \\t""",
"this-------v-------has-25--ν•œκΈ€-thumbsup--n-r-t-f-u-a-x-t",
]
expected = [
"this-v-has-25-ν•œκΈ€-thumbsup-n-r-t-f-u-a-x-t",
"this-v-has-25-ν•œκΈ€-thumbsup-n-r-t-f-u-a-x-t-1",
]
expectedHyphenIgnore = [
"this-------v-------has-25--ν•œκΈ€-thumbsup--n-r-t-f-u-a-x-t",
"this-------v-------has-25--ν•œκΈ€-thumbsup--n-r-t-f-u-a-x-t-1",
]
print(f"\nGiven queries:\n{testQueries}\n")

gens = convertToMarkdownId(testQueries)
print(f"Generated IDs:\n{gens}\n")

print(f"Expected IDs:\n{expected}\n")

gens = convertToMarkdownId(testQueries, ignore_multi_hyphens=True)
print(f"Generated IDs (Hyphen Ignored):\n{gens}\n")

print(f"Expected IDs (Hyphen Ignored):\n{expectedHyphenIgnore}\n")

The `API Reference `_ provides API-level documentation.