You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be nice if I could pass a flag when calling Story.toTwine2HTML() to allow publishing without a start point set. In this case, I would expect it to not emit a startnode attribute on tw-storydata.
The text was updated successfully, but these errors were encountered:
That makes sense to me. Like I mentioned on #446, I'm okay with being stricter on the required attributes (name and ifid) and looser on the optional ones. Like you mention, if they are not set, they should not be emitted.
Only name and ifid are required, as per the spec. Parsing valid Twine 2 HTML requires these attributes; optional attributes will not be emitted if they are not set.
import{parseTwine2HTML}from'extwee';// `name` and `ifid` are required attributes.// (Errors will be thrown if they are missing.)constsource=`<tw-storydata name="Blah" ifid="1234"></tw-storydata>`;// Parse the HTML into a Story.consts2=parseTwine2HTML(source);// `creator` and `creator-version` are optional attributes.// Extwee sets them to its own name and version by default.s2.creator='';s2.creatorVersion='';// Convert back into HTML.// Produces `<tw-storydata name="Blah" ifid="1234" options hidden>\n</tw-storydata>`console.log(s2.toTwine2HTML());
The method generateIFID() is now exposed as separate functionality.1
import{Story,generateIFID}from'extwee';// Create a new storyconsts=newStory();// Generate a new IFID.s.IFID=generateIFID();// Output the story as Twine 2 HTML.console.log(s.toTwine2HTML());
Conversion is less restrictive than compilation
Calls to toTwine2HTML() will convert whatever is available. However, trying to call compileTwine2HTML() when missing required attributes (either name or ifid) or when the IFID is not in the UUIDv4 format will throw errors. Technically, since startnode is optional per the spec, it is also now possible to create a story that will never play.
Footnotes
Ideally, there should be a separate repo for generating IFIDs authoring and archiving tools following the Treaty of Babel can all use. There is ifid, but it has not been updated in six years and is GPL licensed. Maybe, as a future project, I'll do an updated fork. ↩
It'd be nice if I could pass a flag when calling Story.toTwine2HTML() to allow publishing without a start point set. In this case, I would expect it to not emit a
startnode
attribute ontw-storydata
.The text was updated successfully, but these errors were encountered: