Hello,
Test in version 22.4.
Markdown work fine under VCL but not with Firemonkey = TrichView FMX (On Windows) ?
How to reproduce ?
1) Try demo called "RichViewEdit demo" (in Demos\Delphi.FMX\Editors\Editor 1).
2) Try open a markdown file -> It will be displayed like a text file...
Markdown on Firemonkey version ?
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Markdown on Firemonkey version ?
Markdown loading is identical in VCL and FireMonkey version. The problem is in distinguishing text and markdown files.
In VCL, the program can use the open dialog's FilterIndex property to know which format is chosen.
In FireMonkey, it cannot (this property cannot be used). So, the demo recognizes the file format by the file extension.
On desktop OS, FireMonkey demo uses the following function to recognize format:
As you can see, Markdown is loaded only if the file extension is one of: markdown, mdown, mkdn, md, mkd, mdwn, mdtxt.
In VCL, the program can use the open dialog's FilterIndex property to know which format is chosen.
In FireMonkey, it cannot (this property cannot be used). So, the demo recognizes the file format by the file extension.
On desktop OS, FireMonkey demo uses the following function to recognize format:
Code: Select all
function GetFileOpenFormat(const FileName: String): TRVLoadFormat;
var
Ext: String;
begin
Ext := ExtractFileExt(FileName).ToLower;
if Ext = '.rvf' then
Result := rvlfRVF
else if Ext = '.rtf' then
Result := rvlfRTF
else if Ext = '.docx' then
Result := rvlfDocX
else if Pos('htm', Ext) <> 0 then
Result := rvlfHTML
else if (Ext = '*.markdown') or (Ext = '*.mdown') or (Ext = '*.mkdn') or
(Ext = '*.md') or (Ext = '*.mkd') or (Ext = '*.mdwn') or (Ext = '*.mdtxt') then
Result := rvlfMarkdown
else
Result := rvlfText;
end;
Re: Markdown on Firemonkey version ?
Hello Sergey,
Sorry I was using your Demos\Delphi.FMX\Editors\Editor 2 which doesn't work !
With you answer certainly because your code is not correct is this demo :
Correct must be :
'*.md' -> '.md'
etc.
Sorry I was using your Demos\Delphi.FMX\Editors\Editor 2 which doesn't work !
With you answer certainly because your code is not correct is this demo :
Code: Select all
function GetFileFormatByFileName(const FileName: String): TRVSaveFormat;
var
Ext: String;
begin
Ext := ExtractFileExt(FileName).ToLower;
if Ext = '.rvf' then
Result := rvsfRVF
else if Ext = '.rtf' then
Result := rvsfRTF
else if Ext = '.docx' then
Result := rvsfDocX
else if (Ext = '.htm') or (Ext = '.html') then
Result := rvsfHTML
else if (Ext = '*.markdown') or (Ext = '*.mdown') or (Ext = '*.mkdn') or
(Ext = '*.md') or (Ext = '*.mkd') or (Ext = '*.mdwn') or (Ext = '*.mdtxt') then
Result := rvsfMarkdown
else
Result := rvsfText;
end;
Code: Select all
function GetFileFormatByFileName(const FileName: String): TRVSaveFormat;
var
Ext: String;
begin
Ext := ExtractFileExt(FileName).ToLower;
if Ext = '.rvf' then
Result := rvsfRVF
else if Ext = '.rtf' then
Result := rvsfRTF
else if Ext = '.docx' then
Result := rvsfDocX
else if (Ext = '.htm') or (Ext = '.html') then
Result := rvsfHTML
else if (Ext = '.markdown') or (Ext = '.mdown') or (Ext = '.mkdn') or
(Ext = '.md') or (Ext = '.mkd') or (Ext = '.mdwn') or (Ext = '.mdtxt') then
Result := rvsfMarkdown
else
Result := rvsfText;
end;
etc.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Markdown on Firemonkey version ?
Thank you!
I'll fix the demos in the next update.
I'll fix the demos in the next update.