Skip to content

Commit 632d71b

Browse files
committed
Initial commit
0 parents  commit 632d71b

File tree

12 files changed

+403
-0
lines changed

12 files changed

+403
-0
lines changed

.github/workflows/tests.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
10+
jobs:
11+
12+
pre-commit:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.7
21+
- uses: pre-commit/[email protected]
22+
23+
tests:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
python-version: [3.6, 3.7, 3.8, 3.9.0-rc.1]
28+
os: [ubuntu-latest, windows-latest]
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
38+
- name: Installation (deps and package)
39+
run: |
40+
pip install .[testing]
41+
42+
- name: Run pytest
43+
run: |
44+
pytest --cov=mdformat_tables --cov-report=xml --cov-report=term-missing
45+
46+
- name: Upload to Codecov
47+
if: matrix.python-version == 3.7
48+
uses: codecov/codecov-action@v1
49+
with:
50+
name: pytests-py3.7
51+
flags: pytests
52+
file: ./coverage.xml
53+
fail_ci_if_error: true
54+
55+
pre-commit-hook:
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v2
60+
- name: Set up Python
61+
uses: actions/setup-python@v2
62+
with:
63+
python-version: 3.7
64+
65+
- name: Installation (deps and package)
66+
run: |
67+
pip install pre-commit
68+
pip install .
69+
70+
- name: run pre-commit with plugin
71+
run: |
72+
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
73+
74+
publish:
75+
name: Publish to PyPi
76+
needs: [pre-commit, tests, pre-commit-hook]
77+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout source
81+
uses: actions/checkout@v2
82+
- name: Set up Python 3.7
83+
uses: actions/setup-python@v1
84+
with:
85+
python-version: 3.7
86+
- name: install flit
87+
run: |
88+
pip install flit~=3.0
89+
- name: Build and publish
90+
run: |
91+
flit publish
92+
env:
93+
FLIT_USERNAME: __token__
94+
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: mixed-line-ending
7+
- id: trailing-whitespace
8+
- id: check-yaml
9+
- id: check-toml
10+
- repo: https://github.com/pre-commit/pygrep-hooks
11+
rev: v1.6.0
12+
hooks:
13+
- id: python-check-blanket-noqa
14+
- repo: https://github.com/timothycrosley/isort
15+
rev: 5.5.3
16+
hooks:
17+
- id: isort
18+
- repo: https://github.com/psf/black
19+
rev: 20.8b1
20+
hooks:
21+
- id: black
22+
- repo: https://gitlab.com/pycqa/flake8
23+
rev: 3.8.3
24+
hooks:
25+
- id: flake8
26+
additional_dependencies:
27+
- flake8-bugbear==20.1.4
28+
- flake8-builtins==1.5.3
29+
- flake8-comprehensions==3.2.3

.pre-commit-test.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: mdformat
5+
name: mdformat
6+
entry: mdformat
7+
files: "tests/pre-commit-test.md"
8+
types: [markdown]
9+
language: system
10+
additional_dependencies:
11+
- mdformat-tables

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Executable Books
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# mdformat-tables [IN-DEVELOPMENT]
2+
3+
[![Build Status][ci-badge]][ci-link]
4+
[![codecov.io][cov-badge]][cov-link]
5+
[![PyPI version][pypi-badge]][pypi-link]
6+
7+
An [mdformat](https://github.com/executablebooks/mdformat) plugin for rendering tables.
8+
9+
[ci-badge]: https://github.com/executablebooks/mdformat-tables/workflows/CI/badge.svg?branch=master
10+
[ci-link]: https://github.com/executablebooks/mdformat/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush
11+
[cov-badge]: https://codecov.io/gh/executablebooks/mdformat-tables/branch/master/graph/badge.svg
12+
[cov-link]: https://codecov.io/gh/executablebooks/mdformat-tables
13+
[pypi-badge]: https://img.shields.io/pypi/v/mdformat-tables.svg
14+
[pypi-link]: https://pypi.org/project/mdformat-tables

mdformat_tables/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""An mdformat plugin for rendering tables."""
2+
3+
from .plugin import render_token, update_mdit # noqa: F401
4+
5+
__version__ = "0.0.1"

mdformat_tables/plugin.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import List, Optional, Tuple
2+
3+
from markdown_it import MarkdownIt
4+
from markdown_it.token import Token
5+
from mdformat.renderer import MDRenderer
6+
7+
8+
def update_mdit(mdit: MarkdownIt) -> None:
9+
"""Update the parser, e.g. by adding a plugin: `mdit.use(myplugin)`"""
10+
pass
11+
12+
13+
def render_token(
14+
renderer: MDRenderer,
15+
tokens: List[Token],
16+
index: int,
17+
options: dict,
18+
env: dict,
19+
) -> Optional[Tuple[str, int]]:
20+
"""Convert token(s) to a string, or return None if no render method available.
21+
22+
:returns: (text, index) where index is of the final "consumed" token
23+
"""
24+
return None

pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[build-system]
2+
requires = ["flit_core >=2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[tool.flit.metadata]
6+
module = "mdformat_tables"
7+
author = "Chris Sewell"
8+
author-email = "[email protected]"
9+
description-file = "README.md"
10+
home-page = "https://github.com/executablebooks/mdformat-tables"
11+
classifiers = [
12+
"Intended Audience :: Developers",
13+
"License :: OSI Approved :: MIT License",
14+
"Programming Language :: Python :: 3",
15+
"Topic :: Software Development :: Libraries :: Python Modules",
16+
]
17+
keywords = "mdformat,markdown,markdown-it"
18+
19+
requires-python=">=3.6"
20+
requires=["mdformat~=0.3.1"]
21+
22+
[tool.flit.metadata.requires-extra]
23+
testing = [
24+
"pytest~=6.0",
25+
"coverage",
26+
"pytest-cov",
27+
]
28+
29+
[tool.flit.entrypoints."mdformat.parser_extension"]
30+
tables = "mdformat_tables"
31+
32+
[tool.flit.sdist]
33+
include = []
34+
exclude = [".github/", "tests/"]
35+
36+
[tool.isort]
37+
skip = ["venv"]
38+
# Force imports to be sorted by module, independent of import type
39+
force_sort_within_sections = true
40+
# Group first party and local folder imports together
41+
no_lines_before = ["LOCALFOLDER"]
42+
43+
# Configure isort to work without access to site-packages
44+
known_first_party = ["mdformat_tables", "tests"]
45+
46+
# Settings for Black compatibility
47+
profile = "black"

tests/pre-commit-test.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# hallo
2+
3+
there

0 commit comments

Comments
 (0)