Skip to content
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

Spurious bold/italic in inline code #172

Closed
peniblec opened this issue Oct 15, 2016 · 4 comments
Closed

Spurious bold/italic in inline code #172

peniblec opened this issue Oct 15, 2016 · 4 comments
Labels

Comments

@peniblec
Copy link
Contributor

Hi! I have noticed that in blocks such as headers or blockquotes,
inline code containing bold/italic markers will behave as if the
inline code markers were not here. IOW text between asterisks or
underscores will be shown as bold/italic.

Some test cases I wrote:

(ert-deftest test-markdown-font-lock/snake-case-in-code-in-heading ()
  "Test underscores in inline code in headings"
  (markdown-test-string
   "# Title with `snake_case_code`"
   (should-error (markdown-test-range-has-face 21 24 markdown-italic-face))))

(ert-deftest test-markdown-font-lock/stars-in-code-in-heading ()
  "Test asterisks in inline code in headings"
  (markdown-test-string
   "# Title with `char** foo, int* bar`"
   (should-error (markdown-test-range-has-face 20 29 markdown-italic-face))))

(ert-deftest test-markdown-font-lock/stars-in-code-in-blockquote ()
  "Test asterisks in inline code in blockquote"
  (markdown-test-string
   "> Quote with `**stars**`"
   (should-error (markdown-test-range-has-face 17 21 markdown-bold-face))))

(Not sure that (should-error (markdown-test-range-has-face …)) is
the most idiomatic way to test this, though I do mean to check the
absence of bold/italic fontification)

I tried poking around in the code, but I could not pinpoint the cause
of the issue. Some things I noticed, which may or may not be related:

  • (markdown-match-bold (point-at-eol)) will match these strings when
    the point is at the beginning of each line:

      # Title with **bold**
      > Blockquote with **bold**
    
  • In similar conditions, (markdown-match-code (point-at-eol)) fails
    to match, though (markdown-match-code (point-max)) does match:

      # Title with `inline`
      > Blockquote with `inline`
    

That's all I have for now.

@jrblevin jrblevin added the bug label May 11, 2017
jrblevin added a commit that referenced this issue Jun 13, 2017
Two of the three are still failing, but one has been fixed.

Thanks to Kévin Le Gouguec (GH-172).
jrblevin added a commit that referenced this issue Jun 13, 2017
@jrblevin
Copy link
Owner

Thank you. I have added these test cases (although I screwed them up the first time) and am working on a fix.

I'm not sure which way best, but previously in such cases I used (should-not (markdown-range-property-any …)), so that's the approach I used again.

@jrblevin
Copy link
Owner

I think these should be fixed now, but please let me know if not.

@peniblec
Copy link
Contributor Author

As far as I can tell, these bugs are now fixed. Thanks a lot!

I just have a comment about one of the tests: while fixing test-markdown-font-lock/stars-in-code-in-blockquote in c812747, a check changed from (markdown-test-range-has-face 17 21 markdown-bold-face) to (markdown-range-property-any 17 21 'face '(markdown-italic-face)); I think the check should still read markdown-bold-face. If I checkout 2.2 to reproduce the issue, and C-u C-x = on the word "stars", the faces applied are (markdown-blockquote-face markdown-bold-face).

I watched the commit log this past month and I have to say, the amount of work you have put on markdown-mode is incredible! Thank you for working so hard on this package. Clickable links, code block fontification/edition are wonderful quality-of-life improvements; I played around with markup-hiding and even though I do not see myself using it all that much, it does look very polished!

jrblevin added a commit that referenced this issue Jun 13, 2017
Thanks to Kévin Le Gouguec for catching the problem
in c812747.  See GH-172 for details.
@jrblevin
Copy link
Owner

Thanks for spotting that! I was fixing several problems related to italics last night and that slipped through. It shouldn't be italic or bold, so I updated the test to check the absence of both.

I'm glad you like the recent changes. I'm glad to be able to give the package some needed attention lately!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants