Skip to content

✨ NEW: Add simple typographic replacements #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 21, 2020

Conversation

tsutsu3
Copy link
Contributor

@tsutsu3 tsutsu3 commented Oct 19, 2020

Issue

#5

Summary

Implemented replacements (Simple typographic replacements) rule.

Change

  • Added a test to make sure that even a single capital letter is matched correctly.

@welcome
Copy link

welcome bot commented Oct 19, 2020

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

@tsutsu3 tsutsu3 marked this pull request as draft October 19, 2020 18:55
Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks! Just a minor nitpick

# - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
# - miltiplication 2 x 4 -> 2 × 4

RARE_RE = r"\+-|\.\.|\?\?\?\?|!!!!|,,|--"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RARE_RE = r"\+-|\.\.|\?\?\?\?|!!!!|,,|--"
RARE_RE = re.compile(r"\+-|\.\.|\?\?\?\?|!!!!|,,|--")

It's a bit more performant to pre-compile, then use e.g. RARE_RE.search

# or root check will fail every second time
# SCOPED_ABBR_TEST_RE = r"\((c|tm|r|p)\)"

SCOPED_ABBR_RE = r"\((c|tm|r|p)\)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SCOPED_ABBR_RE = r"\((c|tm|r|p)\)"
SCOPED_ABBR_RE = re.compile(r"\((c|tm|r|p)\)", flags=re.IGNORECASE)

same as above

@chrisjsewell
Copy link
Member

Also you can just pip install pre-commit, then pre-commit run -all to correctly format

"""
import logging
import re
from typing import List
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from typing import List
from typing import List, Match

Copy link
Contributor Author

@tsutsu3 tsutsu3 Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

I was just in trouble. 😄

}


def replaceFn(match: re.Match):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def replaceFn(match: re.Match):
def replaceFn(match: Match):

@codecov
Copy link

codecov bot commented Oct 20, 2020

Codecov Report

Merging #59 into master will decrease coverage by 0.06%.
The diff coverage is 91.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #59      +/-   ##
==========================================
- Coverage   95.37%   95.31%   -0.07%     
==========================================
  Files          73       74       +1     
  Lines        3571     3627      +56     
==========================================
+ Hits         3406     3457      +51     
- Misses        165      170       +5     
Flag Coverage Δ
#pytests 95.31% <91.22%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
markdown_it/rules_core/replacements.py 90.90% <90.90%> (ø)
markdown_it/parser_core.py 100.00% <100.00%> (ø)
markdown_it/rules_core/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8f82bc...4308e3f. Read the comment docs.

@tsutsu3
Copy link
Contributor Author

tsutsu3 commented Oct 20, 2020

If I add this line to conf.py:

nitpick_ignore = [("py:class", "Match")]

sphinx warning goes away, is it ok to add it?

How can I get rid of the warning?

@chrisjsewell
Copy link
Member

sphinx warning goes away, is it ok to add it?

yep thats absolutely fine, I don't think there is another "fix"

@tsutsu3 tsutsu3 closed this Oct 20, 2020
@tsutsu3 tsutsu3 reopened this Oct 20, 2020
@tsutsu3
Copy link
Contributor Author

tsutsu3 commented Oct 20, 2020

I added nitpick_ignore = [("py:class", "Match")] in conf.py.

With python 3.7 there is no warning, but with python 3.6 the warning is still there.

/home/circleci/.local/lib/python3.6/site-packages/markdown_it/rules_core/replacements.py:docstring of markdown_it.rules_core.replacements.replaceFn:: WARNING: py:class reference target not found: Match[~ AnyStr]
generating indices...  genindex py-modindexdone

Hmm..., it's going to take some time to fix... 🤔 😕

@chrisjsewell
Copy link
Member

looking good to me 👍 Is it ready for review?

@tsutsu3
Copy link
Contributor Author

tsutsu3 commented Oct 21, 2020

Should I put together a commit with a rebase?

@chrisjsewell chrisjsewell marked this pull request as ready for review October 21, 2020 00:11
@chrisjsewell
Copy link
Member

yeh weird, it normally has the button here to update the branch

if you could rebase then thanks

@tsutsu3
Copy link
Contributor Author

tsutsu3 commented Oct 21, 2020

I checked "Allow edits by maintainers"

My pc env has changed. 😢

I can't rebase, can you handle it for me? 🙏

@chrisjsewell
Copy link
Member

sorted thanks @tsutsu3 😄

@chrisjsewell chrisjsewell changed the title Add simple typographic replacements ✨ NEW: Add simple typographic replacements Oct 21, 2020
@chrisjsewell chrisjsewell merged commit f290ba9 into executablebooks:master Oct 21, 2020
@welcome
Copy link

welcome bot commented Oct 21, 2020

Congrats on your first merged pull request in this project! 🎉
congrats

Thank you for contributing, we are very proud of you! ❤️

tsutsu3 added a commit to tsutsu3/markdown-it-py that referenced this pull request Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants