Howdy, Stranger!

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

How does Twine parse line breaks from storage-area?

litlit
edited June 2014 in Help! with 1.x
I'm writing a script that retrieves the html content of divs from the storage-area based on their tiddler attribute when an internal link is clicked and displays it in a custom div independent of the passages element.

The passage divs in the store area use "\n" to mark line breaks (I assume this has something to do with Twee code). How to I change these to <br /> tags when I get the content so it displays properly? I know it's possible; Twine does it somehow. But, I don't know how, and I haven't been getting anywhere examining the Twine script on the html page source.

I suppose this is just one part of the underlying problem: finding a way to make Tiddly Wiki syntax work with this custom div.

Comments

  • Why are you even trying?  The tale variable, an instance of Tale, loads the passage/tiddler data from the store area at initialization.  Just get it from there.

    tale.has(TITLE) // Method; Returns whether a Passage object matching TITLE exists
    tale.get(TITLE) // Method; Returns the Passage object matching TITLE, or an empty Passage object if it did not exist
    Once you have the Passage object, you can access the data you want in a couple ways:

    {obj}.text // Field; The decoded text of the passage
    {obj}.processText() // Method; Returns the decoded text of the passage after it has also undergone nobr tag processing and/or image passage processing, if necessary
    Assuming you have a reference to the element you're trying to populate with the passage text, you could simply do this:

    new Wikifier(ELEMENT_OBJECT, tale.get(TITLE).processText());
Sign In or Register to comment.