textadventures / squiffy

a tool for creating interactive fiction
MIT License
158 stars 37 forks source link

Javascript rendered as <pre> code instead of executed #29

Closed ergodicbreak closed 9 years ago

ergodicbreak commented 9 years ago

Something seems to be broken recently; even examples with JS (for example https://github.com/textadventures/squiffy/blob/master/examples/transitions/transitions.squiffy ) return output like:

Restart You are standing in a room. You can see a hammer.

It's nice and weighty. Perhaps you want to hit yourself in the face with it?

squiffy.ui.transition(function()null); Bang.

alexwarren commented 9 years ago

Works for me here. What OS are you using? Also make sure that JavaScript lines begin with four spaces or a tab.

ergodicbreak commented 9 years ago

I'm on Windows 7 with Chrome. Also got the same result with IE and Firefox. Here's my practice file, https://gist.github.com/georgeoliver/a514078a18411c481619

edit: looking at the debugger it doesn't seem like there's ever anything in section.js?

edit2: I added some console.log to the compiler, and it appears that passage and section .js.length is never greater than 0, so something is eating the JS? Checking the regex against my practice file it seems to match OK though.

ergodicbreak commented 9 years ago

Alex, could you gist a working file and let me know what browser you're using? Maybe I can try from the other end.

alexwarren commented 9 years ago

That file works for me both on OS X and Windows 7. I just took your gist, clicked Raw, then used Save As to create the file.

There may be something about your file that's not there when it's pasted as a gist - could you email me the file as an attachment?

On 1 November 2014 19:47, George Oliver notifications@github.com wrote:

Alex, could you gist a working file and let me know what browser you're using? Maybe I can try from the other end.

— Reply to this email directly or view it on GitHub https://github.com/textadventures/squiffy/issues/29#issuecomment-61380714 .

ergodicbreak commented 9 years ago

There may be something about your file that's not there when it's pasted as a gist

You nailed it, it's a DOS/Unix line ending problem. For whatever reason the compiler doesn't like DOS line endings when parsing JS.

edit: I believe I have a fix by changing this line in squiffy.js: https://github.com/textadventures/squiffy/blob/master/squiffy.js#L161

to:

    var inputLines = inputFile.toString().split(/\r?\n|\r/);

I can submit a pull request if that looks correct to you.

alexwarren commented 9 years ago

Great! I've just pushed a fix for this.

On 2 November 2014 18:55, George Oliver notifications@github.com wrote:

There may be something about your file that's not there when it's pasted as a gist

You nailed it, it's a DOS/Unix line ending problem. For whatever reason the compiler doesn't like DOS line endings when parsing JS.

— Reply to this email directly or view it on GitHub https://github.com/textadventures/squiffy/issues/29#issuecomment-61418525 .