Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown compiler handling line-breaks wrong #54

Closed
NQNStudios opened this issue Dec 23, 2017 · 4 comments
Closed

Markdown compiler handling line-breaks wrong #54

NQNStudios opened this issue Dec 23, 2017 · 4 comments
Assignees
Milestone

Comments

@NQNStudios
Copy link
Collaborator

What happened

When compiling Markdown files, Fractive is inserting a <br> element for every newline in the Markdown file. Here's the proper way to handle newlines.

@invicticide
Copy link
Owner

Try removing the softbreak: "<br/>" from the commonmark.HtmlRenderer constructor near the top of Compiler.ts, or alternately changing it to something else per the commonmark.js readme.

invicticide added a commit that referenced this issue Dec 24, 2017
- Added 'hardLineBreaks' option to fractive.json, default enabled to preserve existing functionality
- Added 'smartPunctuation' option to fractive.json while I was in there, because why not
@invicticide
Copy link
Owner

invicticide commented Dec 24, 2017

I added a hardLineBreaks option to fractive.json which controls this behavior. It's enabled by default which preserves the existing behavior without needing to rewrite our examples/documentation. It also feels easier and more intuitive to work with (to me), specifically for use cases like this:

{{Start}}

Here is some text in a regular ol' paragraph. This part is fine.

[Do a thing]({@DoThingA})
[Do another thing]({@DoThingB})

I find this sort of usage very natural. With hardLineBreaks:true this renders the links on two separate lines (not paragraphs) which is what I expect based on the Markdown source formatting:

Do a thing
Do another thing

With hardLineBreaks:false this renders the links side-by-side because the \n in the rendered HTML source is collapsed to a single space by the browser:

Do a thing Do another thing

That's fixable by putting the two trailing spaces after the first link, which is technically correct per the official Markdown spec, but is also counterintuitive and invisible, which makes me kind of hate it. 😒

Anyway, with the above-referenced commit this behavior can be switched on or off in fractive.json on a per-story basis so the only thing really left to resolve is what the default setting should be and why.

@invicticide invicticide self-assigned this Dec 24, 2017
@invicticide invicticide added this to the MVP milestone Dec 24, 2017
@NQNStudios
Copy link
Collaborator Author

You're right about the use-case where links are separated by line breaks. It's what I've been doing, and when I tried switching to markdown-it-attrs, those links appearing on the same line was one of the major things that bothered me.

On the other hand, if using a text editor with automatic line wrapping (which is really nice), Fractive devs will end up with a story where line breaks are placed according to their text editor's settings, making responsive design impossible. Which is a huge problem for making webgames.

The best of both worlds would be adopting hard line breaks as the default, but hacking in some kind of solution for the link situation. Not pretty, but better for an average Fractive dev.

@NQNStudios
Copy link
Collaborator Author

Or, just turn every set of links into an unordered list.

* [Do a thing]({#DoIT})
* [Do another thing]({#DoTHAT})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants