Comments (4)
This could be solved in at least two ways, depending on the current behaviour and limitations of the current API.
- The TwineLinkParser could be edited to explicitly check for a newline and modify the
TwineLinkNode
to add a new line during rendering. - Or possibly the newline is already included as parse of the next but ignored due to the renderer. In this case it would be possible to translate any newlines to
<br />
.
First options is preferred, though further investigations is needed.
from spiner.
Currently all links are handled by the WikiLinks parsing feature of Pegdown. Using the custom TwineLinkParser is not possible because parser plugins appear to be called after link parsing, and thus the links are parsed as reflinks instead.
I've tried subclassing the Parser to override this behaviour, but that does not appear to be possible, see sirthias/pegdown#54.
This behaviour by Twine is not valid markdown. In order to solve this properly this has to be changed at the parser level because otherwise the linebreaks (which do not mean anything in valid Markdown in this context) are lost.
from spiner.
I checked the different Twine story formats and it turns out that each story format handles their own markdown parsing. And all but snowman appear to just replace all newlines with <br />
while Snowman appears to be the only one that actually adhere to the markdown "spec".
For example:
In Markdown it is possible
to write on several lines, but
in the rendered result is should be one single line.
This allows you to treat you text as if it were code.
And use the practice of having one sentence per line.
When rendered should appear as
In Markdown it is possible to write on several lines, but in the rendered result is should be one single line.
This allows you to treat you text as if it were code. And use the practice of having one sentence per line.
Story format | Adheres to MD |
---|---|
Harlowe 2.1.0 | No |
Harlowe 1.2.4 | No |
Snowman 1.3.0 | Yes |
SugarCube 2.21.0 | No |
SugarCube 1.0.35 | No |
Because even different Twine story formats are not consistent I don't think fixing this even on the parser side it a good thing because not we need to know which template we're using. I don't think it's a smart idea to take templates into account, because that can easily break when using custom templates, or when the templates are updated.
It appears that one of Markdowns major flaws, lack of spec, strikes again. A quick search for a couple of editors shows several that behave differently:
Editor | Adheres to MD |
---|---|
https://jbt.github.io/markdown-editor/ | Yes |
https://dillinger.io/ | No |
https://stackedit.io/editor | No |
from spiner.
In order to keep the burden on the complexity of the code down the only solution I'm comfortable with at this point is to do the following based on a custom option (it is up to the user which behaviour they want):
- Somehow replace all linebreaks with
<br />
(this is what Harlowe does, because it renders the custom HTML tags directly, no<p>
are ever used) - Only replace single linebreaks with
<br />
so that proper<p />
tags are still used.
I think it's best it should default to replacing linebreaks in order to support the majority of the default Twine templates.
So I've created a new issue #49 in order to support custom options. I've also created a new issue #50 to signify this decision, it that describes the LINEBREAK behaviour as described above.
from spiner.
Related Issues (20)
- Invalid XML character (Unicode: 0x0) (NULL) HOT 2
- Support custom options HOT 2
- Add LINEBREAK options to switch between linebreak behaviours HOT 1
- Fix vulnerabilities in XML parsing
- Implement a proper and safe automatic release procedure
- Add AppEngine health and performance monitoring
- Automatically deploy tagged releases to AppEngine. HOT 1
- Set up GitHub Actions HOT 2
- Support for Java > 8 HOT 2
- Add support for "->" style links
- Decide fate on LaTeX transformer HOT 1
- Example story with all available Spiner features
- Metadata is being shared accross transforms
- Replace local JavaFX GUI with web-based version
- Spiner Story Format HOT 3
- Embed images declare using HTML `<img />` tag
- Transform to DocBook HOT 1
- 🚨 Look here for better alternatives 📙
- Rewrite
- Fix/upgrade SonarQube GitHub Action
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 spiner.