Skip to content

Line break in link references inside lists #742

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

Closed
vincentbernat opened this issue Oct 27, 2018 · 1 comment · Fixed by #743
Closed

Line break in link references inside lists #742

vincentbernat opened this issue Oct 27, 2018 · 1 comment · Fixed by #743
Assignees
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.

Comments

@vincentbernat
Copy link

Hey!

Consider the following code:

Two things:

 - I would like to tell you about the [code of
   conduct][] we are using in this project.
 - Only one in fact.

[code of conduct]: https://github.com/Python-Markdown/markdown/blob/master/CODE_OF_CONDUCT.md

CommonMark is rendering the link correctly. GitHub as well (see below). PHP Markdown does render correctly too. However, Python-Markdown doesn't because of the space at the beginning of the line. I don't know if space at the beginning of a line should just be ignored inside a link or if only the exact amount of space used for list indent should be ignored.


Two things:

  • I would like to tell you about the code of
    conduct
    we are using in this project.
  • Only one in fact.
@facelessuser
Copy link
Collaborator

I took a look at this. It looks like we have bad id cleanup. I have a patch that I'll make a pull request for once I test it more.

diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index 3d3e65f..dc502c2 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -617,7 +617,7 @@ class ImageInlineProcessor(LinkInlineProcessor):

 class ReferenceInlineProcessor(LinkInlineProcessor):
     """ Match to a stored reference and return link element. """
-    NEWLINE_CLEANUP_RE = re.compile(r'[ ]?\n', re.MULTILINE)
+    NEWLINE_CLEANUP_RE = re.compile(r'\s+', re.MULTILINE)

     RE_LINK = re.compile(r'\s?\[([^\]]*)\]', re.DOTALL | re.UNICODE)

@facelessuser facelessuser self-assigned this Oct 27, 2018
@facelessuser facelessuser added bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code. labels Oct 27, 2018
waylan pushed a commit that referenced this issue Oct 30, 2018
Previously only newlines preceded by whitespace were collapsed. Fixes #742.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants