Problem with javascript, link class and section names

Bluetea
I have three problems after doing the basic Squiffy tutorials.

1. Link classes
I would like to be able to display passage links and section links in a slightly different way. They play different roles, but they look the same. Both have class "squiffy-link". How to add class "passage" to passage links and "section" to section links? As a result, the HTML would look something like below, and it would be possible to style both links differently in CSS:

<p>Looking around the room, you can see a <a class="squiffy-link link-passage" data-passage="TV">TV</a>, a <a class="squiffy-link  link-passage" data-passage="book">book</a> and a piece of <a class="squiffy-link  link-passage" data-passage="paper">paper</a> with some handwriting scribbled on it.</p>
<p>Do you want to have the <a class="squiffy-link link-section" data-section="roast chicken">roast chicken</a> or skip straight to <a class="squiffy-link link-section" data-section="dessert">dessert</a>?</p>


2. Section names
Here is my short story:

Do you want to see the [[first_section]], the [[second section]](second_section) or skip straight to [[dessert]]?

[[first_section]]:
This is the first section.

[[second_section]]:
This is the second section.

[[dessert]]:
Three different flavours of ice cream - yum!


Upon compilation, it fires an error:

Squiffy 2.1
Loading J:\squiffy\error1\error1.squiffy
Writing story.js
WARNING: J:\squiffy\error1\error1.squiffy line 3: In section "_default" there is a link to a section called [
[second section</a> or skip straight to [[dessert]], which doesn't exist
Writing index.html
Writing style.css
Done.



And the result HTML file is messed. What is wrong with the code?

3. Javascript

This is my another short story:

Do you want to see a [[javascript demo]](js_demo)?
[[js_demo]]:
Clicking this [link] will show an alert.

[link]:
alert ("Hello!");

Text for the passage.


There is one "tab" before the word "alert". After running it and clicking, it just displays text 'alert ("Hello!")' in "pre" tags, instead of calling a javascript alert function. Like this:
prtscr3.jpg

george
I'm just getting started with Squiffy myself, but some of these look like genuine bugs. You'd be best off entering them in the issue tracker, here, https://github.com/textadventures/squiffy/issues

Alex
I've now fixed the bug reported in point 2 above - it was to do with the "first_section" link, which doesn't have a name in brackets, being followed by the "second_section" link, which does.

This is fixed and I've published version 2.2, so update it from npm (just reinstall using the same instructions) and it should work now.

As for the JavaScript, make sure you're using 4 spaces or a tab character. If it still doesn't work, attach the .squiffy file here and I'll take a look.

Alex
Also, logged the Link Classes request here: https://github.com/textadventures/squiffy/issues/30

Alex
Thanks to George we've worked out the problem with JavaScript was to do with Windows line endings, so if you're using Windows please update to v2.2.1.

This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums