Pasting code - a test

procedure TForm1.Button1Click(Sender: TObject);
const
  bigString = 'Look for a the strings in this strang of strungs.';
  littlestring = '(str)([iau]ng)';
var
  regex : TRegEx;
  i, j  : integer;
  mygrps: TGroupCollection;
begin
  regex      := TRegEx.Create(littlestring);
  mycoll     := regex.Matches(bigString);
  Edit1.Text := 'Count: ' + IntToStr(mycoll.Count);
  memo1.Lines.Add('First Collection: ');
  for i := 0 to mycoll.Count-1 do
  begin
    memo1.Lines.Add('Match #' + IntToStr(i) + ': ' + mycoll.Item[i].Value);
    memo1.Lines.Add('Group: ' + IntToStr(i));
    mygrps:= mycoll.Item[i].Groups;
    for j := 0 to mygrps.Count-1 do
        memo1.Lines.Add('Value: ' + mygrps.Item[j].Value);
  end;
end;

The iframe element + CSS

Paul,
Was that the “—” technique in action?
And, is the Mac screen snapshot just pasted in?
It looks great!
Thanks

1 Like

Hi @Shaun_Cunniffe.
I was looking to see if we could have something that looked like the 2nd one, but was editable / copyable.
It is from this website: https://carbon.now.sh/
They can export an iframe … maybe with some fiddling that could be turned into something that would play nice with the forum. (?)
Or maybe the highlighting in the forum might be updateable?
Cheers,
Paul McGee

Actually, comparing the two, it looks like the tokenising is the same between the two
and it’s only the colouring and font that is different.

Standard snippet in the material design theme:

No syntax highlighting with ADUG Material Dark theme …

What theme/colour combinations are these two?

I have theme Material Design Theme and colour ADUG Material Dark.

This is giving me syntax highlighting, unless it changes when I send the reply.

procedure TForm1.Button1Click(Sender: TObject);

Paul,
when we share source code I prefer the text option as it can be searched. We do have support for syntax highlighting built-in Discourse.
Salut, Mathias

1 Like

Perhaps we can get better code themes using something like this - Codeblock Theme Picker - theme - Discourse Meta

I’ll investigate this later today

1 Like

@SueKing Ah yes. It displays according to the viewer’s settings (makes sense).
I was just poking around to see what the options are.
Paul McGee

@Mathias Hi. Yes. The first post has the standard code via ```
It was not especially good looking in the default theme I had, so I was trying to see if something else could give us different colours + copyable text.

An over-complicated option would be pasting in a graphic from the Carbon website, plus the link to the code.
I’m sure the standard will be fine - especially if @vincent gets some time to look into that option he linked.

Cheers,
Paul McGee

I added the Codeblock theme picker component - unfortunately it doesn’t allow the user to choose a theme - it’s site wide so we have to chose between light and dark - I vote dark :wink:

I’ll keep investigating to see if there are any better options.

Just fyi, at the moment, the code view varies with dark / light settings …

Try refreshing your page - I have added a plugin that allows us to choose a theme - unfortunately it doesn’t allow chosing different themes for light and dark.

I have asked over on meta.discourse about this.

Got it. Yes. :+1: Looks ok to me.

1 Like

I’m curious what we get if I attach a PAS and DFM file to my post.
Unit1.pas (533 Bytes)

So I tried both a PAS and a DFM and the DFM was disallowed.

When you upload an attachment to your post there’s a whitelist of allowed file extensions, that obviously the committee has configured since among others it includes *.pas and *.dpr. Excluding *.dfm from that list is probably wise, they can get large if they contain images.

Zip files were among the list of allowed extensions so you could always include DFMs in those.

I have just added dfm and fmx.

I was happy without DFM but I guess people are probably only likely to upload DFMs from demo projects, not their whole main form DFM with 50 embedded images in it.

For completeness here’s my test DFM

Unit1.dfm (498 Bytes)

The dark code box looks better than the light one. Much more readable.