Inkdrop for Mac - preview panel crashing with unformatted JSX inline styles


(Bruno Del Frate) #1

Bug report

On Inkdrop for Mac, the preview panel crashes when I type JSX code that uses inline stylesheets.
Error message is: " Failed to render Markdown - If the problem persists, please report it. Sorry for the inconvenience".
Sample error log is here: https://pastebin.com/qm9sScjb

Info

  • Platform: macOS
  • Platform version: Mojave
  • App Version: 3.23.2

Reproduce

Paste the following text in a new note. Don’t apply any formatting, just put the raw text in the note.

<p style={{fontSize:'20px'}}>

Here’s another example:

<div style={divStyle}>
  <p style={pStyle}>Get started with inline style</p>
</div>

(Takuya Matsuyama) #2

Hi Bruno,

Thank you for reporting.
That’s not a bug because Markdown doesn’t support JSX syntax, just like browsers can’t parse it as HTML.
You have to enclose JSX code with ``` like so:

```
<p style={{fontSize:'20px'}}>
```

If you want to specify custom style in your inline html, write plain css in style attribute:

<p style="font-size: 20px">
  foo
</p>

(Bruno Del Frate) #3

Hi, and thanks for your reply.
I wasn’t expecting JSX support, and I know I can use backticks. I just wasn’t expecting a one-page error log filling the preview window, just because I forgot the backticks :slight_smile:
Perhaps the preview panel should just ignore JSX code and show it as it is, instead of trying to parse it - just like a web browser does for bad HTML code.
Anyway that’s just a suggestion, more “cosmetic” than else. Thanks for the support, and for an excellent piece of software!


(Tim P) #4

An application crashing because of bad user input is a standard example of a use case to prevent. Every software quality and user experience manual will tell you that users will input a lot of things which you would not expect as a developer and applications should be solid enough to deal with bad input (in this case JSX without code block).

I’m quite shocked that Inkdrop crashing is considered okay behavior!


(Takuya Matsuyama) #5

@Bruno_Del_Frate

Ah that makes sense - it’s confusing and it would be nice to make it error tolerant.

I will look into the current HTML parser to see if it supports.

Thank you for the suggestion!