Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Using Sugarcube 2 with Twine 2, how can I comment out lines?

The standard Harlow symbols don't seem to work and using // makes everything after it italic. =)

Many thanks,

--Rev

Comments

  • edited October 2016
    SugarCube supports block comments in three flavors: C-style, TiddlyWiki, and HTML. Of the three, the C-style block comment is supported everywhere--i.e. within markup, JavaScript, and CSS. The latter two are only supported within markup.

    For example:
    /* C-style */
    
    /% TiddlyWiki %/
    
    <!-- HTML -->
    
  • As far as I know Harlowe's documentation only describes the HTML comment <!-- Comment --> element, which can also be used within standard passages in SugarCube (1 & 2).

    SugarCube (1 & 2) supports a number of different comment markups depending on which passage type you are editing.

    1. Standard Passage:
    <!-- HTML Comment element -->
    
    /* Javascript / CSS multi-line comment block */
    
    /% Wiki multi-line comment block %/
    

    2. Story Javascript passage:
    // Javascript single-line comment.
    
    /* Javascript multi-line comment block */
    
    /% Wiki multi-line comment block %/
    

    3. Story Stylesheet (CSS) passage:
    /* CSS multi-line comment block */
    
  • greyelf wrote: »
    2. Story Javascript passage:
    // Javascript single-line comment.
    
    /* Javascript multi-line comment block */
    
    /% Wiki multi-line comment block %/
    
    TiddlyWiki-style block comments are not supported within JavaScript.
  • TiddlyWiki-style block comments are not supported within JavaScript.
    Ok.

    But they didn't produce an error when I tested them before answering so I assumed you were escaping them.
  • JavaScript code chunks are never processed by the Wikifier in any way. Some do pass through the Wikifier, generally as arguments to or the contents of macros, however, no actual processing is done.

    Where did you see this behavior?
  • Where did you see this behavior?
    I added content like the following to the Story Javascript area, and it outputted the text in the console without any errors.
    // Javascript single-line comment.
    
    /* Javascript multi-line comment block */
    
    /% Wiki multi-line comment block %/
    
    console.log("hello world");
    
  • edited October 2016
    In JavaScript, /…/ is the regular expression literal syntax. So, the following:
    /% Wiki multi-line comment block %/
    
    Yields a RegExp object, whose source is:
    % Wiki multi-line comment block %
    
    So, while you did not receive an error, you definitely weren't doing what you though you were there.

    I asked where you saw that behavior because it should be different in JavaScript—yields a RegExp object—versus CSS—parsing error. For example, the following CSS will stop processing at the invalid comment, thus making the <body> background lime, rather than red:
    body {
    	background-color: lime;
    }
    
    /% OMGWTFBBQ %/
    
    body {
    	background-color: red;
    }
    

    Recommendation: In most cases, just use the C-style block comment—e.g. /* comment */—since it is supported everywhere.
Sign In or Register to comment.