shurcooL-legacy / atom-markdown-format

Formats your Markdown text on save.

Home Page:https://atom.io/packages/markdown-format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't handle "blockquote", "code blocks" and "table" within a list.

ccyanni opened this issue · comments

When "blockquote", "code blocks" and "table" are within a list. The formatter will eliminate the spaces/tabs. It makes the "blockquote", "code blocks" and "table" become outer the list.

For example, a markdown like this.

# codeblock within list

- list1

    ```java
    if(true) 
        break;
    ```

# blockquote within list

- list1

    > This a quote within a list

# table within list

- list1

    | Header One     | Header Two     |
    | :------------- | :------------- |
    | Item One       | Item Two       |

Which looks like this screenshot: http://d.pr/i/qVmt

Will be formatted to:

codeblock within list
=====================

- list1

` ``java
if(true)
    break;
` ``

blockquote within list
======================

- list1

> This a quote within a list

table within list
=================

- list1

| Header One | Header Two |
|:-----------|:-----------|
| Item One   | Item Two   |

Which become outer the list: http://d.pr/i/eP0i

Thanks for reporting, I will see what can be done here.

Thanks, this is a great package when writing Markdown in Atom.

Thanks for using it; I'm glad it's useful and I want to fix all bugs in it. This definitely seems fixable.

It may take a bit longer because I have to deal with moving right now, but I'll get to it as soon as I can.

I've written some code that fixes the test case you provided. But then I tried it with multi-level nested lists and realized a correct fix is more involved.

In any case, I've made some progress so this is going to be fixed relatively soon.

If you could provide a more complicated test case with multiple levels of indented lists containing text, blockquotes, blocks of code, etc., that'd be really useful. Here's what I'm using right now:

Nested Lists
============

### codeblock within list

- list1

    ```C
    if (true)
        break;
    ```

### blockquote within list

- list1

    > This a quote within a list

### table within list

- list1

    | Header One | Header Two |
    |:-----------|:-----------|
    | Item One   | Item Two   |

### multi-level nested

- Item 1

    Extra indent for some reason (it actually looks nicer with 2 spaces instead of a tab,
    so consider doing that).

- Item 2
    - Item 2a

        Things go here.

        > This a quote within a list

        And they stay here.

    - Item 2b
- Item 3

I'll clone this branch and help to do more tests. Thanks!

It's still a work in progress, but I've made some refinements to how I'm going to solve the issue, and started a PR.

shurcooL/markdownfmt#14

The PR is done now and should be ready to merge. It fixes the issue as far as I can tell.

If anyone wants to help, please test it and report any inputs on which it fails to produce sane results.

You can try it out in your browser here: https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/live-markdownfmt/live-markdownfmt.html

Still need to build and push out a new version of the Atom package.