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

Desktop: switch to plain markdown in codemirror #3448

Merged
merged 5 commits into from
Jul 12, 2020

Conversation

CalebJohn
Copy link
Collaborator

This removes gfm in favor of plain markdown (with a couple extensions).

This fixes the issue report by @yadayadaydadaa in the comments of #3440

I just noticed that also TV:three_letters_or_more is underlined. Why? the TV: bit is critical, other combinations like AB: don't trigger the underlining.

@CalebJohn
Copy link
Collaborator Author

While looking at the final part of #3440 I realize that everything was more related than I realized and the cleanest solution was to integrate them all, my final commit reflects this by adding a new editor mode (joplin-markdown) which supports katex blocks.

One unfortunate side affect of this change is that when the user starts typing in a new katex block ($x**2) but hasn't finished it yet, the rest of the document will no longer have markdown highlighting (the parts below the katex open). This same issue happens with code blocks and is due to the way codemirror handles inner modes, the same issue exists with code blocks in Ace Editor.

image

// and support for katex math blocks
export default function useJoplinMode(CodeMirror: any) {
CodeMirror.defineMode('joplin-markdown', (config: any) => {
const stex = CodeMirror.getMode({ inMathMode: true }, 'stex');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you use a mode specific for math expressions, so I'm wondering can we get this highlighted as well? On this page, they have the highlighting but I'm not sure if it can be done when it's within Markdown. It would be great if it was though!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take another stab at this. It should be as easy as including parseDelimiter: true but that doesn't seem to work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be as easy as including parseDelimiter: true

Yes that's what I was wondering. If it's as easy as switching a flag on, then let's do it but if it's more complicated don't worry about it, just let me know either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out to be as easy as switching a flag correctly

@CalebJohn
Copy link
Collaborator Author

@laurent22 his is ready to go now, sorry about the delay on this. I had a hunch that it was easy but didn't have time to devote to it. You'll notice that it was a matter of actually passing in the options correctly, this is unfortunately a less than intuitive aspect of codemirror 5.

@laurent22 laurent22 merged commit 452b41d into laurent22:master Jul 12, 2020
@CalebJohn CalebJohn deleted the remove-spice branch July 12, 2020 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants