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

Parsing GFM code blocks in list is broken for Objective-C due to dashes #550

Closed
Mattieuga opened this issue Feb 23, 2015 · 2 comments
Closed

Comments

@Mattieuga
Copy link

If you add an objective-c code block in a list using GFM, the parsers seems to interpret the - in front of the objective-c function declaration as a new list item.

With a random JavaScript code snippet this works fine

> marked("This is a list\n1. Some first item\n2. Some second item\n```js\nvar a = 'a string';\n```\n3. Some third item")

'<p>This is a list</p>\n<ol>\n<li>Some first item</li>\n<li>Some second item<pre><code class="lang-js">var a = &#39;a string&#39;;\n</code></pre>\n</li>\n<li>Some third item</li>\n</ol>\n'

Now if add a dash in the beginning of the code snippet we'll see the misinterpretation:

> marked("This is a list\n1. Some first item\n2. Some second item\n```objc\n- (BOOL)someFun { ... }\n```\n3. Some third item")

'<p>This is a list</p>\n<ol>\n<li>Some first item</li>\n<li>Some second item\n```objc</li>\n<li>(BOOL)someFun { ... }\n```</li>\n<li>Some third item</li>\n</ol>\n'
@joshbruce
Copy link
Member

#983

@Feder1co5oave
Copy link
Contributor

Indent the content inside a list item:

$ bin/marked 
This is a list
1. Some first item
2. Some second item
    ```objc
    - (BOOL)someFun { ... }
    ``` 
3. Some third item
<p>This is a list</p>
<ol>
<li>Some first item</li>
<li>Some second item<pre><code class="lang-objc"> - (BOOL)someFun { ... }
</code></pre>
</li>
<li>Some third item</li>
</ol>

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

No branches or pull requests

3 participants