delphidabbler / codesnip

A code bank designed with Pascal in mind
https://delphidabbler.com/software/codesnip
Other
111 stars 34 forks source link

Add option to emit Annotated Source (and units) in Markdown format #86

Open delphidabbler opened 1 year ago

delphidabbler commented 1 year ago

There's already the option to format annotated source code in RTF and XHTML.

Being able to render the source in Markdown format could be useful too.

delphidabbler commented 2 weeks ago

There's already the option to format annotated source code in RTF and XHTML.

While annotated source can be written to file in both XHTML & RTF only RTF is used in writing to the clipboard.

Since there is no special Markdown clipboard format that I can find, there's no way of writing Markdown to the clipboard since without overwriting the plain text format version.

delphidabbler commented 2 weeks ago

I'm wondering whether there's any point saving annotated source or units in Markdown format. Since only compilable Pascal is saved in either case, there's very little different between the plain text version and the Markdown version.

For example, take the annotated source code for the ArrayToStringList snippet, when saved in plain text format. It is

{
 * This code snippet was generated by DelphiDabbler CodeSnip Release 4.23.0 on
 * Wed, 23 Oct 2024 08:22:05 GMT.
 * 
 * It includes code taken from the DelphiDabbler Code Snippets database that is
 * copyright © 2005-2024 by Peter Johnson & Contributors and is licensed under
 * the MIT License (https://opensource.org/licenses/MIT).
}

{
  Required unit(s):
    Classes
}

{
  Copies the elements of string array Strings to string list SL, replacing any
  existing contents of SL.
}
procedure ArrayToStringList(const Strings: array of string;
  const SL: Classes.TStrings);
var
  Idx: Integer; // loops thru each string in array
begin
  SL.Clear;
  for Idx := 0 to Pred(Length(Strings)) do
    SL.Add(Strings[Idx]);
end;

whereas the Markdown equivalent, would be exactly the same as above except it would be wrapped in triple backtick (```) tokens .