sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

parse incorrect issue #219

Open fyobe opened 8 years ago

fyobe commented 8 years ago
- **4.8 具体结构**

    - **4.8.1 枚举类**

        枚举常量间用逗号隔开,换行可选。

        没有方法和文档的枚举类可写成数组初始化的格式:

        ```java
        private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS }
        ```

        由于枚举类也是一个类,因此所有适用于其它类的格式规则也适用于枚举类。

    - **4.8.2 变量声明**

        - **4.8.2.1 每次只声明一个变量**

            不要使用组合声明,比如int a, b;。

        - **4.8.2.2 需要时才声明,并尽快进行初始化**

            不要在一个代码块的开头把局部变量一次性都声明了(这是c语言的做法),而是在第一次需要使用它时才声明。 局部变量在声明时最好就进行初始化,或者声明后尽快进行初始化。

    - **4.8.3 数组**

        - **4.8.3.1 数组初始化:可写成块状结构**

            数组初始化可以写成块状结构,比如,下面的写法都是OK的:

            ```java
            new int[] {
              0, 1, 2, 3 
            }

            new int[] {
              0,
              1,
              2,
              3
            }

            new int[] {
              0, 1,
              2, 3
            }

            new int[]
                {0, 1, 2, 3}
            ```

        - **4.8.3.2 非C风格的数组声明**

            中括号是类型的一部分:String[] args, 而非String args[]。

    - **4.8.4 switch语句**

        术语说明:switch块的大括号内是一个或多个语句组。每个语句组包含一个或多个switch标签(case FOO:或default:),后面跟着一条或多条语句。

the words in github is ok, but use this parser to generate html it's incorrect. pls check the issue!

vsch commented 8 years ago

@yuminglong, could you please post the HTML as generated by pegdown in your system and point what should be different so I can see where it is going wrong.

Using a slightly modified version of pegdown which I use in my idea-multimarkdown plugin for IntelliJ, I am getting the following HTML, and the HTML preview looks OK, but I may not be able to notice the subtle error that you see.

Here is the preview of the markdown in GitHub and in my plugin, which uses pegdown to generate the HTML, other than slight spacing and font differences they look the same to my eyes:

screen shot 2016-01-20 at 11 03 08 am

Here is the HTML generated by pegdown, please let me know what should be different:

<ul>
    <li><strong>4.8 具体结构</strong>
        <ul>
            <li>
                <p><strong>4.8.1 枚举类</strong></p>
                <p>枚举常量间用逗号隔开,换行可选。</p>
                <p>没有方法和文档的枚举类可写成数组初始化的格式:</p>
        <pre><code class="java">private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS }
        </code></pre>
                <p>由于枚举类也是一个类,因此所有适用于其它类的格式规则也适用于枚举类。</p>
            </li>
            <li>
                <p><strong>4.8.2 变量声明</strong></p>
                <ul>
                    <li>
                        <p><strong>4.8.2.1 每次只声明一个变量</strong></p>
                        <p>不要使用组合声明,比如int a, b;。</p>
                    </li>
                    <li>
                        <p><strong>4.8.2.2 需要时才声明,并尽快进行初始化</strong></p>
                        <p>不要在一个代码块的开头把局部变量一次性都声明了(这是c语言的做法),而是在第一次需要使用它时才声明。 局部变量在声明时最好就进行初始化,或者声明后尽快进行初始化。</p>
                    </li>
                </ul>
            </li>
            <li>
                <p><strong>4.8.3 数组</strong></p>
                <ul>
                    <li>
                        <p><strong>4.8.3.1 数组初始化:可写成块状结构</strong></p>
                        <p>数组初始化可以写成块状结构,比如,下面的写法都是OK的:</p>
            <pre><code class="java">new int[] {
                0, 1, 2, 3
                }

                new int[] {
                0,
                1,
                2,
                3
                }

                new int[] {
                0, 1,
                2, 3
                }

                new int[]
                {0, 1, 2, 3}
            </code></pre>
                    </li>
                    <li>
                        <p><strong>4.8.3.2 非C风格的数组声明</strong></p>
                        <p>中括号是类型的一部分:String[] args, 而非String args[]。</p>
                    </li>
                </ul>
            </li>
            <li>
                <p><strong>4.8.4 switch语句</strong></p>
                <p>术语说明:switch块的大括号内是一个或多个语句组。每个语句组包含一个或多个switch标签(case FOO:或default:),后面跟着一条或多条语句。</p>
            </li>
        </ul>
    </li>
</ul>
fyobe commented 8 years ago

Sorry, my usage is incorrect, when i open the 'Extensions.ALL', It's ok. thank you. pls close this issue.