Skip to content

Commit

Permalink
fix: Correct issues associated with bootstrapping pre-commit tests (#4)
Browse files Browse the repository at this point in the history
* fix:Remove pre-commit check to allow bootstrapping

Signed-off-by: Chris Butler <chris@thebutlers.me>

* fix:Remove pre-commit check to allow bootstrapping

Signed-off-by: Chris Butler <chris@thebutlers.me>

* fix:Remove pre-commit check to allow bootstrapping

Signed-off-by: Chris Butler <chris@thebutlers.me>
  • Loading branch information
butler54 authored Mar 8, 2021
1 parent ec97008 commit abb6cc3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
pip install .
- name: run pre-commit with plugin
continue-on-error: true
run: |
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ repos:
entry: mdformat
files: "tests/pre-commit-test.md"
types: [markdown]
language: system
language: python
additional_dependencies:
- mdformat-frontmatter
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov.io][cov-badge]][cov-link]
[![PyPI version][pypi-badge]][pypi-link]

An [mdformat](https://github.com/executablebooks/mdformat) plugin for ensuring that yaml frontmatter is respected. As we are unable
An [mdformat](https://github.com/executablebooks/mdformat) plugin for ensuring that yaml frontmatter is respected. As we are unable
to tell the intent of a user if the yaml is incorrectly formatted it will trigger an exception.

This package was built from the [template](https://github.com/executablebooks/mdformat-plugin) provided by [executable books](https://github.com/executablebooks) and customized (specifically to separate content PR's from the release cycle).
Expand Down
11 changes: 6 additions & 5 deletions mdformat_frontmatter/plugin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import List, Optional, Tuple

from markdown_it import MarkdownIt
from mdit_py_plugins.front_matter import front_matter_plugin
from markdown_it.token import Token
from mdformat.renderer import MDRenderer
from mdit_py_plugins.front_matter import front_matter_plugin


def update_mdit(mdit: MarkdownIt) -> None:
"""Update the parser, e.g. by adding a plugin: `mdit.use(myplugin)`"""
mdit.use(front_matter_plugin)


def render_token(
renderer: MDRenderer,
tokens: List[Token],
Expand All @@ -22,15 +23,15 @@ def render_token(
:returns: (text, index) where index is of the final "consumed" token
"""
return None
if tokens[index].type != "front_matter":
if tokens[index].type != "front_matter":
return None
else:
return None
if tokens[index].type != "front_matter":
if tokens[index].type != "front_matter":
return None
print(tokens[index])
content = ''
while index < len(tokens) and tokens[index].type == 'front_matter':
content = ""
while index < len(tokens) and tokens[index].type == "front_matter":
# Not sure

index += 1
Expand Down

0 comments on commit abb6cc3

Please sign in to comment.