proselint
proselint copied to clipboard
typography.symbols.curly_quotes fails to ignore code blocks in markdown in certain situations.
I am using proselint 0.6.1. typography.symbols.curly_quotes complains about double quotation characters on several sections in code blocks. Here's an example:
Here is some preformatted code with double quotation marks:
\```
"hello world"
"{hello world}"
"hello world"
\```
results in the error:
/home/catherine/markdown_test.md:6:1: typography.symbols.curly_quotes Use curly quotes “”, not straight quotes "". Found once elsewhere.
/home/catherine/markdown_test.md:6:15: typography.symbols.curly_quotes Use curly quotes “”, not straight quotes "".
The error pops up in several situations like this. Notice that the error is fine with both quotations above and below. I'm wondering if the markdown interpreter is doing something unexpected.
Yes, you've found a bug. However, it's not that the Markdown interpreter is misbehaving, it's that there is no Markdown interpreter. One of the highest-priority improvements for Proselint is to do a better job of handling markups.
Okay, I have an idea for a fix for this. I will test it out and create a PR if it works.
@CatherineH I gave you permissions to write to branches, which I think should let you look at code climate and fix your pr.
Right now you seem to be catching <code>
tags in for html, but not <pre>
tags. are there any common cases for using <pre>
tags where its not indicating code via a monospaced font? I'm sure there are, but I can't think of them.
Its leaving out
in markdown which is the official way to actually indicate a codeblock according to daring fireball's documentation. Could you add that as well? I think the test case would be something like (following your example)
text = '\nHere is some preformatted code with double quotation ' \
'marks:\n\n test = "hello world"\n\n'
I don't know whether single backticks \
…`` warrant inclusion as well? They certainly are designated as code in the documentation.
It looks like some of this machinery might be related to the more general problem of silencing rules in subparts of documents that have different formats.
We should think of a way for people to use the .proselintrc
to have different settings for different formats, so people could disable the straightquotes for a particular format type, even if we don't want to disable the straight quotes for Markdown in general. Especially since Smartypants converts straight quotes to curly quotes I know this has been one of the most contentious rules to date. And straightquotes technically are written in the spec for links and many other Markdown syntactic constructions as straight quotes (I haven't checked whether curly quotes cause it to err… but based on this SO Question I worry about it).
Are there other markup languages (e.g., rst
, mmd
, &c.) that could also benefit from this kind of check?
This code also triggers the problem:
```json
{
"path1": "dir/"
"path2: "file"
}
`` `
proselint complains about the dir/
with the trailing slash; without that, the warning does not happen.
This could be solved with a plugins system, potentially.
Hi,
we are running into the same problem on a code block within a reStructuredText document.
Example
Usage::
def test_basic_mqtt(mosquitto, capmqtt):
capmqtt.publish(topic="foo", payload="bar")
Error
README.rst:48:32: typography.symbols.curly_quotes Use curly quotes “”, not straight quotes "". Found 6 times elsewhere.
With kind regards, Andreas.
This .proselintrc.json
works well for us.
{
"checks": {
"annotations.misc": false,
"typography.symbols": false
}
}
References
- https://github.com/amperser/proselint/issues/491#issuecomment-296782491
- https://github.com/amperser/proselint/issues/393
We encountered the same issue in a code span (delimited by one backtick instead of three): "true"
.