Big Header'
+ ''
+ 'Small Header
'
+ ''
+ 'Hello world, let me stress how '
+ 'happy this component is.'
+ 'Infact, any user could use it.'
+ ''
+ 'Just refer to the code and see how TagFormat handler '
+ 'is working'
+ ''
+ 'begin'
+ ' if a < b then '
+ ' writeln(''hello world'');'
+ 'end;'
+ '
'
+ ''
+ 'Really easy! Right?'
+ )
+ TabOrder = 1
+ end
+ object Splitter1: TSplitter
+ Left = 299
+ Height = 353
+ Top = 0
+ Width = 5
+ end
+ end
+end
diff --git a/components/richmemo/samples/mlparse/unit1.pas b/components/richmemo/samples/mlparse/unit1.pas
new file mode 100644
index 000000000..5f3f8d2ae
--- /dev/null
+++ b/components/richmemo/samples/mlparse/unit1.pas
@@ -0,0 +1,77 @@
+unit Unit1;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
+ ExtCtrls, RichMemo, richmemoml;
+
+type
+
+ { TForm1 }
+
+ TForm1 = class(TForm)
+ Button1: TButton;
+ Memo1: TMemo;
+ Panel1: TPanel;
+ RichMemo1: TRichMemo;
+ Splitter1: TSplitter;
+ procedure Button1Click(Sender: TObject);
+ private
+ { private declarations }
+ public
+ { public declarations }
+ procedure TagFormat(Sender: TObject; var atagName: string; tagattr: TStrings;
+ var afont: TFontParams; var txt: string; var tagCloses: Boolean );
+ procedure EntReplace(Sender: TObject; var txt: string; tagsStack: TStrings);
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.Button1Click(Sender: TObject);
+begin
+ RichMemo1.Clear;
+ Parse(Memo1.Text, RichMemo1, @TagFormat, @EntReplace);
+end;
+
+procedure TForm1.TagFormat(Sender: TObject; var atagName: string; tagattr: TStrings;
+ var afont: TFontParams; var txt: string; var tagCloses: Boolean);
+begin
+ if atagName='b' then
+ Include(afont.Style, fsBold)
+ else if atagName='i' then
+ Include(afont.Style, fsItalic)
+ else if atagName='s' then
+ Include(afont.Style, fsStrikeOut)
+ else if atagName='u' then
+ Include(afont.Style, fsUnderline)
+ else if atagName='h1' then begin
+ Include(afont.Style, fsBold);
+ afont.Size:=afont.Size*2;
+ end else if atagName='h2' then begin
+ Include(afont.Style, fsBold);
+ afont.Size:=round(afont.Size*1.5)
+ end else if atagName='pre' then begin
+ afont.Name:='Courier New'
+ end;
+end;
+
+procedure TForm1.EntReplace(Sender: TObject; var txt: string;
+ tagsStack: TStrings);
+begin
+ txt:=StringReplace(txt, '<', '<', [rfReplaceAll, rfIgnoreCase]);
+ txt:=StringReplace(txt, '>', '>', [rfReplaceAll, rfIgnoreCase]);
+ txt:=StringReplace(txt, '"', '"', [rfReplaceAll, rfIgnoreCase]);
+end;
+
+end.
+