-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix typographic substitution in (pre|code|kbd|script) blocks when smartypants=true #1335
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<pre>&</pre> | ||
<p><code>--foo</code> | ||
<kbd>---foo</kbd></p> | ||
<script>--foo</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
smartypants: true | ||
description: SmartyPants does not modify characters within <pre>, <code>, <kbd>, or <script> tag blocks. | ||
spec: https://daringfireball.net/projects/smartypants/ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just trying to be helpful by linking to the "spec" that explains why. |
||
<pre>&</pre> | ||
<code>--foo</code> | ||
<kbd>---foo</kbd> | ||
<script>--foo</script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was pleasantly surprised by the form the test suite takes: adding a specification was so easy, good work Team Marked. 😍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some duplication here: it'd be nice to just have a simple list of tags in which no substitution is to be performed --
['pre', 'code', 'kbd', 'script']
-- 'cos that'd make it easy to add/remove tags; I did try that route but the regexes looked less "on the nose" than this version.I also experimented with alternate names for the
inRawBlock
field: they were all too darn long and made the code less readable: forex,isBlockInWhichNoSubstitutionIsToBePerformed
.Happy to take a steer here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change them to
/^<(pre|code|kbd|script)/i
and/^<\/(pre|code|kbd|script)>/i
I think that makes it a little easier to see what the regex is looking for