Giter Club home page Giter Club logo

Comments (26)

surferjoeit avatar surferjoeit commented on May 17, 2024 2

I can use any software i want, for me it's not a problem. But if i exchange files with others i can't force them to use a particular editor, so in my opinion it should be better to use CR LF on Windows instead of LF only.
It's a matter of portability of the files.
Thanks for this great editor anyway!

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024 2

Most of the editors show it in the bottom right somewhere.

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024 1

Under Windows you can change the extension when you save choose Save type as: All Files. You would need to add some categories to that menu that contains *.md, *mdtxt, etc. like the open dialog. You can change the extension but it gets saved as .md anyway (Maybe a bug?):

When opening the file with the dumb default notepad editor line breaks are missing:

Looking into Notepad++ we only have linux line breaks that the dumb MS Notepad does not understand:

Adding some line breaks with the dumb notepad and then showing them in Notepad++ shows that you would have to use CR LF on Windows instead of only LF.

My suggestion: @surferjoeit change to Notepad++. It is great in every aspect.
@Jocs Use CR LF on Windows instead of LF only.

from marktext.

notAlaanor avatar notAlaanor commented on May 17, 2024

That would be the text wrapping. Line numbers would help users avoid this issue.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@surferjoeit how do you create a .txt file with Mark Text? Mark Text is a markdown editor, can only create .md file.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@surferjoeit It a bug in windows system, I will fix it, or anyone help with this issue. thank you!

from marktext.

surferjoeit avatar surferjoeit commented on May 17, 2024

I can't help, sorry, i'm not a developer, i can only thank you.

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024

I assume this is some electron flag soemwhere maybe but I am a Python/Ruby/C++ dev not .js/electron.

from marktext.

fxha avatar fxha commented on May 17, 2024

Maybe you can add this as a feature too: line endings --> { CRLF (windows), LF (else) }. This will allow us to switch file encodings.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@fxha yeah, Good idea! 😢 I need a windows system, the VM is too slow, I don't want to install windows system on VM.

from marktext.

fxha avatar fxha commented on May 17, 2024

It looks like src/editor/utils/exportMarkdown.js translates html to markdown, that's means we can manipulate the line endings there. The problem is, if the user switches the line encoding we have to replace all \n (not followed by \r) to \n\r or \n\r to \n. Additionally, we have to convert the user input (copy & past content) to the selected line encoding. It is still unclear to me whether the parser (src/editor/parser/marked.js) fully supports CRLF. marked.js and our parser are not compatible with CRLF. Also, we need to change some new lines in parser too. Correct me if I'm wrong.

Well, this feature/bug seems like a major change - if it is done correctly. There may be other/better ways to support LF and CRLF line endings.

One quick and dirty workaround would be to replace the new lines before saving but I think it's no a good solution and not performant as well.


In addition, when loading a file the parser must determine which line ending is used.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@fxha The platform state is already is the store, You can determine use which line ending by this state.

from marktext.

fxha avatar fxha commented on May 17, 2024

@Jocs When I thought about it, it seems there are two possible solutions:

  1. If we load a file replace all \n\r with \n and save line encoding in state. Then we can internally work with LF encoding. When we save a file change \n to selected line encoding (LF (\n): nothing to do; CRLF (\n\r): replace \n).
  2. see post above. We have to change a lot of files.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@fxha Can we determine use CRLF or LF by platform?

CRLF for windows and LF for mac and Linux.

Only windows system need to do the work which you described in solution 1?

from marktext.

fxha avatar fxha commented on May 17, 2024

Can we determine use CRLF or LF by platform?

We could, but the problem is if some one using LF on Windows and vi­ce ver­sa you "destroy" the file. You only have to do the work from CRLF -> LF -> CRLF. I think it's better to let the user choose line ending and/or use file line ending.

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024

User choice is always bad because the average user does not know what LF/CRLF line endings mean. CRLF works on most modern linux editors so I suggest to always use CRLF on windows no matter what and convert LF to CRLF.

from marktext.

fxha avatar fxha commented on May 17, 2024

@SuperSandro2000 Sorry, perhaps I was not clear enough. Use CRLF default on Windows, but also analyse file endings. If we found one CRLF use CRLF (ask user later when we found mixed ending). And create a menu entry Line Endings where the user can select LF/CRLF.

Visual Studio had the same problems with line endings. VS git extension has still some problems.

Sure you can open LF/CRLF on every system, but sometime you have no choice (eg. in projects).

@Jocs If we allow CRLF on windows only you can't open CRLF files on macOS/Linux.

@Jocs @SuperSandro2000 What's your opinion on that?

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024

Now I get it. Sounds good.

Git under windows just converts all LF to CRLF by default and back on push. Don't think we could do it that fancy.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@fxha some questions(opinions):

  1. If user use mixed CRLF and LF how we treat this situation?
  2. I agree with you

    use CRLF default on Windows, but also analyse file endings.

  3. Do you find any other editor that user can select the 'LF/CRLF'?(is it necessary? as @SuperSandro2000 saied, maybe user do not know what LF/CRLF is.)

from marktext.

SuperSandro2000 avatar SuperSandro2000 commented on May 17, 2024
  1. Convert them all to one or the other.
  2. You can change it in Notepad++. Edit> EOL Conversion.

from marktext.

fxha avatar fxha commented on May 17, 2024

If user use mixed CRLF and LF how we treat this situation?

Maybe default to LF and CRLF on Windows (and show user notification). Or create a settings option line endings.

Do you find any other editor that user can select the 'LF/CRLF'

Atom, Typora, Sublimetext, Notepad++

saied, maybe user do not know what LF/CRLF is.)

Yeah, that may be true

from marktext.

Jocs avatar Jocs commented on May 17, 2024

When user create a markdown file by Mark Text, default to LF and CRLF on Windows .
If user open an existed file, We should not change the line break, But give a notification to tell the users the recommended line break to their platform, user can change the line break in menu.

@fxha do you mean this above?

from marktext.

fxha avatar fxha commented on May 17, 2024

@Jocs Yes, but:

the recommended line break to their platform, user can change the line break in menu.

Notify the user that we found mixed line endings and changed to default end of line character. So the user can change it by itself or not.

Also add settings option: default end of line character: EndOfLine: { LF, CRLF } - default to LF and CRLF on Windows.

from marktext.

Jocs avatar Jocs commented on May 17, 2024

@fxha we can set this plan first. I'll assign it to you first, but I don't need to rush to write code because I haven't thought about how to prompt the user. Do you have any good suggestions?

from marktext.

fxha avatar fxha commented on May 17, 2024

Maybe we can use the auto. update statusbar to notify or native message box/notifications to prompt the user?

from marktext.

Jocs avatar Jocs commented on May 17, 2024

I prefer the first solution, use the auto update status bar.

from marktext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.