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

Correct beginning of inline code position #116

Closed
wants to merge 2 commits into from
Closed

Conversation

syohex
Copy link
Collaborator

@syohex syohex commented Mar 11, 2016

markdown-regex-code starts with **"(?:`\|[^\\]\)\(\(+\)..."**. If cursor is beginning of buffer, (match-beginning 0)is on backtick. While cursor is not beginning of buffer,(match-beginning 0)` is not on backtick and previous point of backtick.


---
foo:bar

---
`x`

In above example, (match-beginning 0) is point of after '---'. That point is a code block and '(markdown-code-block-at-pos pos)' returns non-nil, this causes infinite loop of markdown-match-inline-generic. (match-beginning 1) of markdown-regex-code always on backtick. We should use (match-beginning 1) instead of '(match-beginning 0') in such case.

This is related to #115.
CC: @dabrahams

@syohex
Copy link
Collaborator Author

syohex commented Mar 11, 2016

There is no error with this patch.

fix

markdown-regex-code starts with "\(?:\`\|[^\]\)\(\(`+\)...". If cursor is
beginning of buffer, "(match-beginning 0)" is on backtick. While cursor is not
beginning of buffer, "(match-beginning 0)" is not on backtick and previous point
of backtick.

---
foo:bar
---
`x`

In above example, "(match-beginning 0)" is point of after "---". That point is
a code block and "(markdown-code-block-at-pos pos)" returns non-nil,
this causes infinite loop of markdown-match-inline-generic.
"(match-beginning 1)" of markdown-regex-code always on backtick. We should
use "(match-beginning 1)" instead of "(match-beginning 0)" in such case.
@jrblevin
Copy link
Owner

Thanks--nice catch!

Merged with one minor docstring edit (metadata block, not code block).

@jrblevin jrblevin closed this Mar 11, 2016
@jrblevin jrblevin deleted the infinite-loop-issue branch March 11, 2016 12:48
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