Comments (2)
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.
from extwee.
Three main changes to address this and #446:
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.)
const source = `<tw-storydata name="Blah" ifid="1234"></tw-storydata>`;
// Parse the HTML into a Story.
const s2 = 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 story
const s = new Story();
// 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
from extwee.
Related Issues (20)
- Add documentation on CLI
- Add documentation on API
- Add CLI support for de-compiling Twine 1 HTML into Twee 3
- Add browser testing of webpacked Extwee
- Fix: Add a Extwee 2.2.0 release
- Fix: Push Extwee 2.2 to NPM
- Output attributes aren't escaped in HTML or Twee HOT 3
- Consider TypeScript types HOT 4
- Parsing Twine 2 HTML doesn't unescape passage text HOT 1
- Allow direct access to story passages HOT 1
- Consider loose parsing modes HOT 6
- Double colons in passage text at the start of a line aren't escaped in Twee output HOT 3
- Stricter Twee output for required and optional StoryData properties
- Consider defaulting Story.zoom to 1, not 0 HOT 1
- Add: StoryFormat parsing should follow the "soft parsing" rule
- Add: Every parse and compile should reference spec or doc
- Add: All objects should be well-documented
- Add: Twine 2 Archive HTML parsing should follow the "soft parsing" rule
- Story types out of sync with changes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extwee.