docpad / docpad-plugin-cson

Adds support for CSON to JSON compilation to DocPad
Other
2 stars 2 forks source link

Error with plugin (but not `cson.parseFileSync`) #1

Closed Zearin closed 10 years ago

Zearin commented 10 years ago

I keep getting this error:

Parse error on line 22: unexpected dedent

It seems to always happen at line 22, even when I delete the content (and even the entire object) located there.

Here’s my CSON (after many modifications in my attempts to fix the error):

"freebies":
    "Buttons": [
        {
            "name": "Round Jewels"
            "urlPrefix": "/buttons/round_jewels"
            "alt": "round button"
        }

        {
            "name": "Square Jewels"
            "urlPrefix": "/buttons/square_jewels"
            "alt": "square button"
        }
    ]

    "Icons": [
        {
            "name": "Computer Icons"
            "urlPrefix": "/jenae-icons/Computer_Icons"
            "alt": "computer icons"
        }

        {
            "name": "Design Icons"
            "urlPrefix": "/jenae-icons/Design_Icons"
            "alt": "design icons"
        }

        {
            "name": "Writing Icons"
            "urlPrefix": "/jenae-icons/Writing_Icons"
            "alt": "writing icons"
        }
    ]

    "Patterns": [
        {
            "name": "Chain Weave"
            "urlPrefix": "/patterns/chain_weave"
            "alt": "chain weave"
        }

        {
            "name": "Circles"
            "urlPrefix": "/patterns/circles"
            "alt": "circles"
        }

        {
            "name": "Cooking"
            "urlPrefix": "/patterns/cooking"
            "alt": "cooking"
        }

        {
            "name": "Diagonal Stripes"
            "urlPrefix": "/patterns/diagonal_stripes"
            "alt": "diagonal stripes"
        }

        {
            "name": "Greek Double Key"
            "urlPrefix": "/patterns/greek_double_key"
            "alt": "Greek double key"
        }

        {
            "name": "Hatching"
            "urlPrefix": "/patterns/hatching"
            "alt": "hatching"
        }

        {
            "name": "Hexagons"
            "urlPrefix": "/patterns/hexagons"
            "alt": "hexagons"
        }

        {
            "name": "Japanese"
            "urlPrefix": "/patterns/japanese"
            "alt": "Japanese"
        }

        {
            "name": "Lorem Ipsum"
            "urlPrefix": "/patterns/lorem_ipsum"
            "alt": "Lorem ipsum"
        }

        {
            "name": "Maple"
            "urlPrefix": "/patterns/maple"
            "alt": "maple"
        }

        {
            "name": "Oak"
            "urlPrefix": "/patterns/oak"
            "alt": "oak"
        }

        {
            "name": "Ovals"
            "urlPrefix": "/patterns/ovals"
            "alt": "ovals"
        }

        {
            "name": "Pointillism"
            "urlPrefix": "/patterns/pointillism"
            "alt": "pointillism"
        }

        {
            "name": "Trees"
            "urlPrefix": "/patterns/trees"
            "alt": "trees"
        }

        {
            "name": "Vertical Stripes"
            "urlPrefix": "/patterns/vertical_stripes"
            "alt": "vertical stripes"
        }

        {
            "name": "Volume"
            "urlPrefix": "/patterns/volume"
            "alt": "volume"
        }

        {
            "name": "Watercolors"
            "urlPrefix": "/patterns/watercolors"
            "alt": "watercolors"
        }

    ]

    "Stock Photos": [
        {
            "name": "Audio"
            "urlPrefix": "/stock/audio"
            "alt": "audio"
        }

        {
            "name": "Digital"
            "urlPrefix": "/stock/digital"
            "alt": "digital"
        }

        {
            "name": "Drafting"
            "urlPrefix": "/stock/drafting"
            "alt": "drafting"
        }

        {
            "name": "Drawing"
            "urlPrefix": "/stock/drawing"
            "alt": "drawing"
        }

        {
            "name": "Fashion"
            "urlPrefix": "/stock/fashion"
            "alt": "fashion"
        }

        {
            "name": "Painting"
            "urlPrefix": "/stock/painting"
            "alt": "painting"
        }

        {
            "name": "Photography"
            "urlPrefix": "/stock/drawing"
            "alt": "photography"
        }

        {
            "name": "Writing"
            "urlPrefix": "/stock/written"
            "alt": "written"
        }
    ]
Zearin commented 10 years ago

Forgot to mention: this parsed fine for me with both cson2json and programmatically (in the interactive CoffeeScript REPL).

Zearin commented 10 years ago

So, it looks like this isn’t a bug after all.

DocPad’s error reporting (which I hope will get better) led me to believe otherwise.

It always claimed line 22 of the file in question, which was part of the CSON. However, I started toying with my HTML + Eco code below, and noticed that the line number in the error report changed.

Very annoying. But, I’ll link this post in that Issue for the benefit of discussion and others working on better error messages. :)