iquercorb / OpenModMan

Open Mod Manager - Open source and generic Mod ("Modifications") manager.
GNU General Public License v3.0
95 stars 5 forks source link

[Suggestion] Change symbol of line break for description in modpack.xml #108

Closed lmiol closed 3 months ago

lmiol commented 3 months ago

I decided to automatically create the package.xml file using a simple solution in BATCH.

@echo off
set category=MAP
set "description=## Name1"
set "description1=**blabla:** blabla [homepage](https://blabla)"  
set "description2=**blabla2:** blabla [forkpage](https://blabla2)"
set description3=**blabla date:** 1 Dec, 2023
set thumbnail=codeforbase64 (nevermind this)

echo ^<?xml version="1.0"?^> > modpack.xml
echo ^<Open_Mod_Manager_Package^> >> modpack.xml
echo ^<install^>%install%^</install^> >> modpack.xml
echo ^<category^>%category%^</category^> >> modpack.xml
echo ^<description^>%description%^ >> modpack.xml
echo %description1% >> modpack.xml
echo %description2% >> modpack.xml
echo %description3% ^</description^> >> modpack.xml
echo    ^<thumbnail^>%thumbnail%^</thumbnail^> >> modpack.xml
echo ^</Open_Mod_Manager_Package^> >> modpack.xml

after generation it looks like modpack.xml what created from Mod-package editor from OMM buttttttttttttttttttttttttt.... my genereated modpack.xml lools like this in preview image

but expected like this (this screen made after created file from Mod-package editor from OMM) image

I did investigate and find out My symbol of line break (what created by echo) is not the same as yours.

I tried a lot of variants and I think its not possible to do right line break symbol as yours via BATCH

Could you do recognizing of your symbol of line break kinda \r\n for example?

Also xml doesn't support line breakes inside tag (its only 1 line). so it seems is only one solution to fix this - is to make \r\n support and if someone want to write \r or \n in description - you can save as \\r \\n and read as \r \n in preview there is no conflict

iquercorb commented 3 months ago

Actually, the supported new line sequence in Mod descriptions is CRLF ( \r\n or 0D 0A ASCII sequence) which is the Windows standard, and this is saved as this (with CRLF) in the XML file. You problem is, I think, that the BATCH ECHO command generate a single LF ('\n', 0A'). You'd better use PowerShell which allow more sophisticated string manipulation.

lmiol commented 3 months ago

Actually, the supported new line sequence in Mod descriptions is CRLF ( \r\n or 0D 0A ASCII sequence) which is the Windows standard, and this is saved as this (with CRLF) in the XML file. You problem is, I think, that the BATCH ECHO command generate a single LF ('\n', 0A'). You'd better use PowerShell which allow more sophisticated string manipulation.

line break character not supported by xml format (doesnt matter ascii or utf8) it should be <description> some text \r\n new line text </description> instead of a symbol which any editor show up it like a line break. i tried notepad.exe notepad++.exe sublime.exe akelpad.exe wordpad.exe

i mean if someone to try to generate custom xml by any method he doesn't need to investigate how to support right character of line break to right view in open mod manager

And by the way. ASCII is old Americal standard bounded old programs with only english characters. Even new Sublime Text doesn't support it by default. UTF-8 is usual common in everyday apps Windows 1252 and Windows 1250 is common for Windows

lmiol commented 3 months ago

I don't deny that I'm pursuing my goal and it benefits me if you do it this way. But that doesn't negate the fact that it's the right thing to do and that it will be convenient for everyone who wants to create XML descriptions themselves. But I won't insist. I'll figure out how to insert line breaks with CRLF.

Therefore, if you're against it, we can close the issue.

iquercorb commented 3 months ago

line break character not supported by xml format (doesnt matter ascii or utf8) it should be <description> some text \r\n new line text </description> instead of a symbol which any editor do it like a line break. i tried notepad.exe notepad++.exe sublime.exe akelpad.exe wordpad.exe

I understand what you are asking for now. But, you are wrong, the only characters that must be escaped within XML text nodes are <> &. Furthermore "\r" or "\n" are not valid XML escape sequences... however you could use the &#xD;&#xA; to insert CRLF sequence as escaped ASCII code, the parser should properly transcode it... try it.

i mean if someone to try to generate xml by any method he doesn't need to investigate how to support right character of line break for open mod manager in his xml

There is no investigation... CRLF is the Windows standard, and this can be put within the XML text node as this, without escaping...

And by the way. ASCII is old Americal standard bounded old programs with only english characters. Even new Sublime Text doesn't it support by default. UTF-8 is common

The parser is UTF-8 standard, it encode and decode UTF-8, to/From Windows UTF-16... CR ( 0D ) and LF ( 0A ) are ASCII basic codes that are shared by UTF-8 and almost all known and used code pages.

lmiol commented 3 months ago

&#xD;&#xA

single &#xB; is fixed broblem

iquercorb commented 3 months ago

single &#xB; is fixed broblem

0b is code for vertical tabulation... glad to know it works (I don't know how) however I recommend to use 0d 0a which is the proper sequence for new line...