Page 1 of 1

Markdown rendering assistance needed

Posted: Thu Feb 29, 2024 1:44 pm
by michael_s
NOTE: I had to format the URLs below all wrong because this forum software doesn't allow me to paste in the complete links. I get a warning message that URLs can't be used. I tried including them using the "Insert URL" feature as well as in plain text. Just drop the [ and ] from the .io and those are the links.

I have downloaded the 22.2 trial for Delphi and am trying out the markdown functionality. Using the Delphi\Editors\Editor 1 demo, I've loaded a markdown file. I used the full sample seen here... https://markdown-it.github[.io]. I've also loaded that same markdown into https://stackedit[.io]. Both StackEdit and markdown-it.github[.io] render the document in a consistent manner. TRichViewEdit, on the other hand, compresses the newlines, does not show code blocks well, and the images are not shown.

For the whitespace I tried clearing the rvmdloCollapseWhitespace and rvmdloCollapseWhitespaceInCodeSpans options from MarkdownProperties.LoadOptions. I also set the rvmdloKeepLineBreaks option. I can't see any difference in the document rendering. I am not sure what to do about the code blocks and the images. Where should I be looking to render the document consistent with other well known markdown editors/viewers?

Thanks,
Michael

Re: Markdown rendering assistance needed

Posted: Thu Feb 29, 2024 9:03 pm
by Sergey Tkachenko
TRichView follows CommonMark specification (+ implements extensions for tables and footnotes).
Other Markdown extensions (not listed in the CommonMark Markdown specification) are not supported, including emoticons, sub/superscripts, inserted text, marked texts, typographic replacements and so on.
These extensions can be implemented on request.
In GitHub, you can check "CommonMark Strict" checkbox to see Markdown parsing without extensions.
compresses the newlines,
What do you mean?

In Markdown, to start a new paragraph, you need to put an empty line between text.
To add a line break, you need to finish line with two or more spaces, or with '\'.
Both TRichView and GitHub works identically here.
To process line breaks in Markdown as line breaks:
- In GitHub editor, you can check "breaks" checkbox
- in TRichView, include rvmdloKeepLineBreaks
Or do you mean something different?
does not show code blocks well
What do you mean? By default, code blocks are displayed with a monospace font, all spaces and line breaks are kept.
Do you mean that code blocks do not have fancy decorations like borders and background color?
But It is customizable.
If you use StyleTemplates (real named styles), paragraphs of code blocks are formatted using "HTML Preformatted" style. Additionally, all code text (both inline and in blocks) is formatted using "HTML Code" style.
If StyleTemplates are not used, you can define a background color and a font name for code blocks.

However, TRichView can only import code blocks, it cannot export them yet.

Additional info: https://www.trichview.com/help/idh_clas ... rties.html
images are not shown
These images are on remote locations and must be downloaded.
By default, TRichView does not download images, it can read them only from files.
But you can use OnImportPicture event to download them.
Or, if you use RichViewActions, you can assign a TRVIndyDownloadInterface component to RVAControlPanel.DownloadInterface, and images will be downloaded.

Re: Markdown rendering assistance needed

Posted: Wed Mar 06, 2024 6:02 pm
by michael_s
Thank you for the information. I will try the code block styles and images in the coming days. By compressed newlines I mean that the sample markdown I linked to in my original post does not render like it does at the source I shared nor in GitHub's viewer. There are blank lines that render in those two sources I cited and they are not present in the TRichView demo I was working from.

Re: Markdown rendering assistance needed

Posted: Thu Mar 07, 2024 7:56 am
by Sergey Tkachenko
Where are these blank lines? Please help me to find them in these documents.

Re: Markdown rendering assistance needed

Posted: Thu Mar 07, 2024 12:03 pm
by michael_s
Argh, my apologies, you are correct they are not real blank lines. They are single spaced, but the spacing is easier on the eyes in those two sources compared to TRichView. Like they are using 1.5 line height or so and compared to TRV they appeared to be blank lines, but it's just the spacing. I appreciate your help. I think this is enough for me to continue now. I will explore the styles.