Welcome to Markdown Superscript’s documentation!¶
This Python package is an extension to the Python Markdown project
which adds the ability to superscript text. To do so, the character
~
becomes a Markdown tag for text meant to be superscripted, and
is replaced with the HTML sup
tag.
For example, the extension transforms the text directly below into the HTML shown after it.
2^10^ is 1024.
<p>2<sup>10</sup> is 1024.</p>
The code is Simplified (2 Clause) BSD license and is available on Github.
Installation¶
Stable release¶
The easiest way to install Markdown Superscript is to use pip.
$ python -m pip install MarkdownSuperscript
This will install the latest stable version. If you need an older version, you may pin or limit the requirements.
$ python -m pip install 'MarkdownSuperscript==2.1.0'
$ python -m pip install 'MarkdownSuperscript>=2.0.0,<3'
If you don’t have pip installed, this Python installation guide can guide you through the process.
From source¶
The source files for Markdown Superscript can be downloaded from the Github repo.
You may use pip to install the latest version:
$ python -m pip install git+git://github.com/jambonrose/markdown_superscript_extension.git
Alternatively, you can clone the public repository:
$ git clone git://github.com/jambonrose/markdown_superscript_extension
Or download the tarball:
$ curl -OL https://github.com/jambonrose/markdown_superscript_extension/tarball/development
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage¶
Python¶
>>> from markdown import markdown
>>> from mdx_superscript import SuperscriptExtension
>>> text = "2^10^ is 1024."
>>> markdown(text, extensions=[SuperscriptExtension()])
'<p>2<sup>10</sup> is 1024.</p>'
You may also refer to the extension by module name or short module name.
>>> markdown(text, extensions=['mdx_superscript'])
>>> markdown(text, extensions=['superscript'])
Note
In older versions of Markdown, you will need to refer to the module
without the mdx
prefix (the second line of code above).
Command Line¶
$ echo '2^10^ is 1024.' > text.md
$ python -m markdown -o html -x 'mdx_superscript' -f text.html text.md
$ cat text.html
<p>2<sup>10</sup> is 1024.</p>
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs on Github issues.
If you are reporting a bug, please follow the guidelines shown to you while reporting the bug
Fix Bugs and Support Others¶
Look through the open GitHub issues. Anything tagged with “help wanted” is open to whoever wants to implement it. Anything tagged with “support” means someone needs help, and you may be the person to help them!
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
Markdown Superscript could always use more documentation, whether as part of the official Markdown Superscript docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue on Github.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up markdown_superscript_extension
for local development.
- Fork the
markdown_superscript_extension
repository on GitHub.
Create a directory for your project, and then create a virtual environment. If you new to virtual environments, RealPython’s Virtualenv Primer is for you! The code below demonstrates how to create a virtual project with Virtualenvwrapper
$ mkproject markdown_superscript_extension
Clone your fork locally into your new project.
$ git clone git@github.com:YOUR_USERNAME_HERE/markdown_superscript_extension.git .
Install the necessary dependencies using pip. If you don’t have pip installed, the Python installation guide can guide you through the process.
$ pip install -r requirements/dev_requirements.txt $ pip install -r requirements/lint_requirements.txt $ pip install -r requirements/test_requirements.txt $ python setup.py develop
Create a branch for local development and begin to make changes!
$ git checkout -b name-of-your-bugfix-or-feature
Make small, targeted changes. Commit often, and write clear messages! Remember that this is a volunteer-drive project. The clearer your intent and your changes, the easier it will be for us to review your work.
$ git add . $ git commit -m "Your detailed description of your changes."
The project is configured to use pre-commit. If you’d like to have each commit checked as you make it, install it as a hook for your repository, as demonstrated below.
$ pre-commit install
When you’re done making changes, check that your changes pass the test suite. If you’re not using pre-commit, you will also need to use the linters and auto-formatters.
$ make test # or python setup.py test $ # linters below $ flake8 mdx_superscript.py tests $ isort --verbose --check-only --diff mdx_superscript.py $ black mdx_superscript.py tests
If you have Python 2.7, 3.4, 3.5, 3.6, and 3.7 installed, as well as both PyPy and PyPy3, you may use
tox
to run all of the tests in all of the supported environments.$ tox
Once you’ve made the changes you want, push your branch to GitHub.
$ git push -u origin name-of-your-bugfix-or-feature
Submit a pull request from your new branch to the original repository through the GitHub website.
🎉 Thank you for taking the time to read this and for your potential contributions!
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- If a bug-fix or new feature, the pull request should include tests.
- If the pull request adds functionality, the docs should be updated.
- The pull request should work for all supported Python versions. If
you are unable to run
tox
locally, the CI will run the test suite for you (but please consider running the suite beforehand).
Package Release Guidelines¶
This document serves as a guide for the release manage of the project. The package is to be released on both Github and PyPI.
The project follows semantic versioning and uses the ‘Squash and Rebase’ git branch model.
If the version of the package has not been properly increased, please use
bumpversion
to increase the major, minor, or patch number as needed.
Add change notes to the history document.
Once the branch for bumping the version has been tested and squashed, the package release should occur on the development branch. Remember to pull/fast-forward the development branch from Github!
To release to PyPI, first run the Makefile dist
target. If all goes
well, upload the release using the release
target.
$ make dist
$ make release
Tag the latest commit with the new version (the version should be
prefixed with a v
for consistency), and then push to Github.
$ git tag v2.0.1
$ git push origin --tags
🎉 That’s all! You’ve released on Github and PyPI!
Credits¶
Development Lead¶
- Andrew Pinkham <http://andrewsforge.com/>
Contributors¶
- Adrian <https://github.com/adi->
History¶
2.1.1 (2018-10-09)¶
- (Re-)Enable short-name module reference (specific to Markdown v3; PR #45)
- Write documentation in Sphinx
- Integrate Read The Docs
- Update badges in Read Me
2.1.0 (2018-10-07)¶
- Add support for Python-Markdown 3.0
- Add support for Python 3.7 and PyPy3
- Switch tests to use PyTest
- Tox now checks package distribution
- Integrate PyUp
2.0.0 (2017-04-17)¶
- Add test/support for Python-Markdown 2.6
- Drop Support For:
- Python 2.6 (EOL 2013)
- Python 3.2 (EOL 2016)
- Python-Markdown 2.4 (Superseded in 2014)
- Fix Issue #2 - Setup.py errors; Description.rst missing
1.0.1 (2014-10-17)¶
- Update for Python-Markdown 2.5
1.0.0 (2014-07-28)¶
- Initial Release of Markdown Superscript Extension
- Compatible with:
- Python-Markdown 2.4
- Python 2.6, 2.7
- Python 3.2, 3.3, 3.4