khajavi / pandoc

Automatically exported from code.google.com/p/pandoc
GNU General Public License v2.0
0 stars 0 forks source link

Footnotes are mangled by invisible whitespace differences #282

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run pandoc on the following file, (written with $==\n and _==SPACE, since 
I'm not sure if google cleans up whitespace).

This_is_body.[^1]$
$
[^1]:_This_is_footnote.$
$
$
This_is_body_again.$ 

2. Now run it on a file with same content, but with four spaces in the 
second-to-last line:

This_is_body.[^1]$
$
[^1]:_This_is_footnote.$
$
____$
This_is_body_again.$ 

What is the expected output? What do you see instead?

The two files appear identical to the naked eye so, given the goal of markdown, 
they should produce the same output. 

But while the first one produces the footnote as expected, the second one (with 
the four spaces) prints everything literally. In JSON:

example 1 (no spaces):

[
    {
        "docAuthors": [], 
        "docDate": [], 
        "docTitle": []
    }, 
    [
        {
            "Para": [
                {
                    "Str": "This"
                }, 
                "Space", 
                {
                    "Str": "is"
                }, 
                "Space", 
                {
                    "Str": "body"
                }, 
                {
                    "Note": [
                        {
                            "Para": [
                                {
                                    "Str": "This"
                                }, 
                                "Space", 
                                {
                                    "Str": "is"
                                }, 
                                "Space", 
                                {
                                    "Str": "footnote"
                                }, 
                                {
                                    "Str": "."
                                }
                            ]
                        }
                    ]
                }
            ]
        }, 
        {
            "Para": [
                {
                    "Str": "This"
                }, 
                "Space", 
                {
                    "Str": "is"
                }, 
                "Space", 
                {
                    "Str": "body"
                }, 
                "Space", 
                {
                    "Str": "again"
                }, 
                {
                    "Str": "."
                }
            ]
        }
    ]
]

example 2 (four spaces in 2nd-to-last line)

[
    {
        "docAuthors": [], 
        "docDate": [], 
        "docTitle": []
    }, 
    [
        {
            "Para": [
                {
                    "Str": "This"
                }, 
                "Space", 
                {
                    "Str": "is"
                }, 
                "Space", 
                {
                    "Str": "body"
                }, 
                {
                    "Str": "["
                }, 
                {
                    "Str": "^"
                }, 
                {
                    "Str": "1"
                }, 
                {
                    "Str": "]"
                }
            ]
        }, 
        {
            "Para": [
                {
                    "Str": "["
                }, 
                {
                    "Str": "^"
                }, 
                {
                    "Str": "1"
                }, 
                {
                    "Str": "]"
                }, 
                {
                    "Str": ":"
                }, 
                "Space", 
                {
                    "Str": "This"
                }, 
                "Space", 
                {
                    "Str": "is"
                }, 
                "Space", 
                {
                    "Str": "footnote"
                }, 
                {
                    "Str": "."
                }
            ]
        }, 
        {
            "Para": [
                {
                    "Str": "This"
                }, 
                "Space", 
                {
                    "Str": "is"
                }, 
                "Space", 
                {
                    "Str": "body"
                }, 
                "Space", 
                {
                    "Str": "again"
                }, 
                {
                    "Str": "."
                }
            ]
        }
    ]
]

What version of the product are you using? On what operating system?

pandoc 1.8, ghc 6.12.3, on MacOS 10.5.8

Original issue reported on code.google.com by jesse.k....@gmail.com on 31 Jan 2011 at 6:20

GoogleCodeExporter commented 9 years ago
I've attached a patch that fixes this and passes the tests. It just makes sure 
that an indent isn't followed by a newline. I'm not sure if there's a 
special-purpose combinator that takes care of this, but if so, I couldn't find 
it.

Original comment by jesse.k....@gmail.com on 31 Jan 2011 at 10:43

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks - pushed f282b462bb81b271604c533ea176a1e6fde52b12, and test case added.

Original comment by fiddloso...@gmail.com on 1 Feb 2011 at 4:07