Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

blank spaces at the beginning of line will change to code block #75

Closed
hecor opened this issue Apr 3, 2019 · 10 comments
Closed

blank spaces at the beginning of line will change to code block #75

hecor opened this issue Apr 3, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@hecor
Copy link

hecor commented Apr 3, 2019

  • Editing status:
    image

  • Edit done status:
    image

thanks.

@tommoor tommoor added the bug Something isn't working label Apr 4, 2019
@tommoor
Copy link
Member

tommoor commented Apr 4, 2019

This is due to the markdown parser interpreting paragraphs indented by several spaces as code, which is definitely a standard.

I think the answer is to remove that from the parsing engine, it won't work with imported documents that use this formatting then but they can be easily fixed in the editor.

@smeijer
Copy link

smeijer commented Apr 4, 2019

It's a feature, not a bug.

I agree with @tommoor. Hmm, I don't agree. It's part of the standard, and thereby should not be changed.

Most of the times, I use backticks ` to wrap code. But plenty of sites use the four space indent formatting. (Reddit for example).

@hecor
Copy link
Author

hecor commented Apr 8, 2019

Thanks @tommoor and @smeijer, what's the easiest way to remove this feature, any suggestions ?

@smeijer
Copy link

smeijer commented Apr 8, 2019

Easiest way is change your behavior in writing docs.

Second easiest, would a css style override to make it visually look like normal (indented) text to you, qualify?

@tommoor
Copy link
Member

tommoor commented Apr 8, 2019

Hey @smeijer , please don't misquote me!

Whilst it is a feature of the Markdown standard to use spaces to indent code, this editor is not aiming to be an editor for any Markdown that you can throw at it – only the subset of valid Markdown that it produces.

I DO think that as the editor will never produce code indented with spaces (only backticks), that this parsing should be removed. As I mentioned, in the rare case that someone imports a doc with spaces then it is easily fixed either manually, or as part of the import process.

The code in question is around here:
https://github.com/tommoor/slate-md-serializer/blob/master/src/parser.js#L71

@hecor
Copy link
Author

hecor commented Apr 8, 2019

Thanks @tommoor, I removed this feature according to your suggestion. I should inform you the use cases. In Chinese, we often use blanks at the beginning of a paragraph.
Thanks again.

@hecor hecor closed this as completed Apr 8, 2019
@smeijer
Copy link

smeijer commented Apr 8, 2019

Hey @smeijer, please don't misquote me!

Sorry, about that. That wasn't on purpose. I totally misread your comment, and fixed mine by now.

Turns out, I don't agree with that post of you. But I do understand your addition.

in the rare case that someone imports a doc with spaces then it is easily fixed either manually, or as part of the import process.

I can agree with that.

@anniebabannie
Copy link

@smeijer or @hecor Do either of you know where this behavior is set in ProseMirror (since we've moved away from Slate)? I realize converting tabs or spaces to code blocks is expected behavior in some editors, but I'd love to know how to change this so users could put tabs in front of paragraphs (think school essays, or novels). It's just a style preference I'd like to offer, but I'm not sure where to tweak this behavior.

Any and all help is much appreciated 🙏

@tommoor
Copy link
Member

tommoor commented Jan 27, 2021

Honestly I'd consider it a bug now that 4 spaces at the beginning of a paragraph becomes code when you reload, but lets create a new issue as this is so old.

@anniebabannie
Copy link

Hmmm I can no longer reproduce the issue actually, weird! If it comes back I'll report it as a bug, but honestly I think I might try to tackle this with CSS anyway, to avoid polluting the original document with extra characters.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants