HTML到降价转换器。
html2md的Python项目详细描述
HTML2md
HTML到降价转换器
安装
pip install -U html2md
用法
作为命令行工具:
# To convert a file. html2md examples/hello.html # To convert from stdin. cat examples/hello.html | html2md
来自python脚本:
importhtml2mdhtml='''<h1>Header</h1><b><i>Hello</i></b> from <code>html2md</code><pre class="py"><code>print('Hello')</code></pre>'''md=html2md.convert(html)print(md)
贡献
克隆存储库
首先,从项目开始。
# Clone your fork into your local machine.# This will create the `origin` remote pointing to your fork. git clone git@github.com:<your-username>/html2md.git cd html2md # Add an `upstream` remote pointing to the original repository. git remote add upstream git@github.com:davidcavazos/html2md.git
设置您的环境
确保已安装virtualenv
。
pip install -U virtualenv
创建并激活新的virtualenv
。
python -m virtualenv env
source env/bin/activate
Note: Once you are all done, you can deactivate it by running
deactivate
.
安装需求。
pip install -U -r requirements.txt
修改代码
首先,确保你是最新版本的。
git checkout master git pull upstream master
现在,为您的更改创建一个新分支。 尝试对更改使用简短的描述性名称。
# Create a new branch and change to it.
git checkout -b your-branch
你现在可以修改任何你想要的。
运行测试
确保为任何新功能添加测试或修复。
如果它在新文件中,请将*_test.py
前缀附加到该文件。
# To run all the tests. python setup.py test# To run a specific test suite.# python setup.py test -s <package>.<test_file>.<TestSuite> python setup.py test -s html2md.convert_test.ConvertTest # To run a specific test.# python setup.py test -s <package>.<test_file>.<TestSuite>.<test_name> python setup.py test -s html2md.convert_test.ConvertTest.test_code_block
创建拉取请求
在所有测试通过后,您必须创建一个包含更改的“拉取请求”。 您可以创建一个包含所有更改的提交。
Note: You can check your changes with
git status
.
# Create a commit and push it to your fork's branch. git add . git commit -m 'One line description of your changes' git push origin your-branch
然后,您可以跟随终端中的链接,或导航到html2md,以创建“拉取请求”。
If you need to add further modifications, you'll have to:
git add . git commit -m 'One line description of further changes' git push origin your-branch
Afterwards, it will reflect automatically on the Pull Request.
一旦一切都好了,就可以合并了。
发布新版本
确保安装了更多工具。
pip install -U twine
生成分发存档。
# Make sure there are no previous builds. rm -rf dist/ # Build the distribution package. python setup.py sdist bdist_wheel # Check any problems with the README. twine check dist/*
Note: It is highly recommended to publish to
TestPyPI
before publishing toPyPI
.# To upload to TestPyI. twine upload --repository-url https://test.pypi.org/legacy/ dist/* # To install from TestPyPI. pip install --index-url https://test.pypi.org/simple/ --no-deps html2mdIf everything is working correctly, go ahead and publish to
PyPI
.
上传到PyPI
。
twine upload dist/*