Comments (26)
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.
Most of the editors show it in the bottom right somewhere.
from marktext.
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.
That would be the text wrapping. Line numbers would help users avoid this issue.
from marktext.
@surferjoeit how do you create a .txt file with Mark Text? Mark Text is a markdown editor, can only create .md file.
from marktext.
@surferjoeit It a bug in windows system, I will fix it, or anyone help with this issue. thank you!
from marktext.
I can't help, sorry, i'm not a developer, i can only thank you.
from marktext.
I assume this is some electron flag soemwhere maybe but I am a Python/Ruby/C++ dev not .js/electron.
from marktext.
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.
@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.
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 ( 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.src/editor/parser/marked.js
) fully supports CRLF.
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.
@fxha The platform
state is already is the store, You can determine use which line ending by this state.
from marktext.
@Jocs When I thought about it, it seems there are two possible solutions:
- If we load a file replace all
\n\r
with\n
and save line encoding instate
. 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
). - see post above. We have to change a lot of files.
from marktext.
@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.
Can we determine use CRLF or LF by platform?
We could, but the problem is if some one using LF on Windows and vice versa 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.
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.
@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.
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.
@fxha some questions(opinions):
- If user use mixed
CRLF
andLF
how we treat this situation? - I agree with you
use CRLF default on Windows, but also analyse file endings.
- 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.
- Convert them all to one or the other.
- You can change it in Notepad++. Edit> EOL Conversion.
from marktext.
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.
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.
@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.
@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.
Maybe we can use the auto. update statusbar to notify or native message box/notifications to prompt the user?
from marktext.
I prefer the first solution, use the auto update status bar.
from marktext.
Related Issues (20)
- Unexpected error: Failed to execute 'setStart' on 'Range': There is no child at offset 597.
- Blank lines are auto inserted no matter what - request for settings that align rendering with Discord
- 在copy 时不应该将我刻意复制的空格给过滤掉
- Unrecognized formula
- Unexpected error: Cannot read properties of null (reading 'type')
- error during dpkg install -
- ERROR:sandbox_linux.cc(374) HOT 2
- Bold/italics sometimes fails to render with escaped dollar signs
- Unexpected error: EISDIR: illegal operation on a directory, watch '\\wsl.localhost\Ubuntu\home\eric\Projects-client\subatomic\client-import\md-images'
- Cannot Search Text Properly HOT 1
- Flathub Verification
- Unexpected error: Failed to execute 'setStart' on 'Range': The offset 4294967292 is larger than the node's length (14).
- Line numbers overlap text in long files
- Can you join Debian's APT source or create a PPA?
- Unexpected error: Cannot read properties of null (reading 'parentNode')
- cannot open MD file correctly
- What does the 'A' mean on the header?
- 每次保存都会显示文件被重载是什么原因?
- Unexpected error: Cannot read properties of null (reading 'type')
- Unexpected error: Failed to execute 'setStart' on 'Range': There is no child at offset 490.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marktext.