Geschrieben von: meybohm 16.03.2004 - 10:28
QUELLTEXT
{
delete_html_tags.pas
Dieses Plugin löscht alle HTML-Tags innerhalb des geöffneten
Proton-Dokuments bzw. innerhalb des markierten Textes.
Beispielplugin
Proton Plugins mit dem Free Pascal Compiler erstellen.
Zum kompilieren folgenden Befehl aufrufen:
c:ppbinwin32ppc386 -Sd delete_html_tags.pas
Hinweis:
Um Proton als Free-Pascal IDE zu nutzen, einfach
folgenden Shortcut in den Programmeinstellungen
definieren:
command.com /k c:ppbinwin32ppc386 -Sd %A%
}
library delete_html_tags;
uses
regexpr;
const KEINE_RUECKGABE=0;
RUECKGABE_ERSETZT_MARKIERUNG = 1;
RUECKGABE_ERSETZT_EDITORTEXT = 2;
var RUECKGABETYP:integer;
function pluginStart(text:pchar; selstart,sellength:integer) : pchar; export;stdcall;
var
r : tregexprengine;
i,len : longint;
s:string;
begin
r:=GenerateRegExprEngine('<[^>]+>',[]);
SetString(s,text,strlen(text));
if (sellength=0) then
RUECKGABETYP:=RUECKGABE_ERSETZT_EDITORTEXT
else
begin
s:=copy(s,selstart+1,sellength);
RUECKGABETYP:=RUECKGABE_ERSETZT_MARKIERUNG;
end;
while RegExprPos(r,pchar(s),i,len) do
begin
delete(s,i+1,len);
end;
DestroyregExprEngine(r);
pluginStart := pchar(s);
end;
function pluginRueckgabetyp:Integer;export;stdcall;
begin
pluginRueckgabetyp :=RUECKGABETYP;
end;
function pluginInterfaceVersion: integer; export;stdcall;
begin
pluginInterfaceVersion := 1;
end;
exports
pluginRueckgabetyp,
pluginStart,
pluginInterfaceVersion;
end.
Geschrieben von: meybohm 16.03.2004 - 16:36
QUELLTEXT
library base64_encode;
uses classes, base64, sysutils;
const KEINE_RUECKGABE=0;
RUECKGABE_ERSETZT_MARKIERUNG = 1;
RUECKGABE_ERSETZT_EDITORTEXT = 2;
var RUECKGABETYP:integer;
function pluginStart(text:pchar; selstart,sellength:integer) : pchar; export;stdcall;
var
b64enc:TBase64EncodingStream;
BaseStream: TMemoryStream;
begin
BaseStream := TMemoryStream.Create;
b64enc:=TBase64EncodingStream.Create(BaseStream);
if (sellength>0) then
begin
RUECKGABETYP:=RUECKGABE_ERSETZT_MARKIERUNG;
b64enc.write((text+selstart)^,sellength);
end
else
begin
RUECKGABETYP:=RUECKGABE_ERSETZT_EDITORTEXT;
b64enc.write(text^,strlen(text));
end;
while (b64enc.size mod 3)<>0 do
b64enc.write(#0,1);
b64enc.free;
pluginStart := pchar(BaseStream.memory);
end;
function pluginRueckgabetyp:Integer;export;stdcall;
begin
pluginRueckgabetyp :=RUECKGABETYP;
end;
function pluginInterfaceVersion: integer; export;stdcall;
begin
pluginInterfaceVersion := 1;
end;
exports
pluginRueckgabetyp,
pluginStart,
pluginInterfaceVersion;
end.
Geschrieben von: meybohm 16.03.2004 - 16:38
QUELLTEXT
library base64_decode;
uses classes, base64, sysutils;
const KEINE_RUECKGABE=0;
RUECKGABE_ERSETZT_MARKIERUNG = 1;
RUECKGABE_ERSETZT_EDITORTEXT = 2;
var RUECKGABETYP:integer;
function pluginStart(text:pchar; selstart,sellength:integer) : pchar; export;stdcall;
var
b64dec:TBase64DecodingStream;
input: TMemoryStream;
s:string;
isend:boolean;
begin
Input := TMemoryStream.Create;
if (sellength>0) then
begin
input.write((text+selstart)^,sellength);
RUECKGABETYP:=RUECKGABE_ERSETZT_MARKIERUNG;
end
else
begin
input.write(text^,strlen(text));
RUECKGABETYP:=RUECKGABE_ERSETZT_EDITORTEXT;
end;
input.seek(0,soFromBeginning);
b64dec:=TBase64DecodingStream.Create(input);
IsEnd := False;
while not IsEnd do
try
s:=s+Chr(b64dec.ReadByte);
except
on e: EStreamError do IsEnd := True;
end;
pluginStart := pchar(s);
input.free;
b64dec.free;
end;
function pluginRueckgabetyp:Integer;export;stdcall;
begin
pluginRueckgabetyp :=RUECKGABETYP;
end;
function pluginInterfaceVersion: integer; export;stdcall;
begin
pluginInterfaceVersion := 1;
end;
exports
pluginRueckgabetyp,
pluginStart,
pluginInterfaceVersion;
end.
Geschrieben von: meybohm 21.03.2004 - 11:04
QUELLTEXT
{
html__generate_bullet_list.pas
Dieses Plugin erstellt aus dem markierten Zeilen bzw. aus dem
Proton-Dokument eine HTML-Bulletliste
<ul>
<li>line[0..n]</li>
</ul>
Beispielplugin
Proton Plugins mit dem Free Pascal Compiler erstellen.
Zum kompilieren folgenden Befehl aufrufen:
c:ppbinwin32ppc386 -Sd delete_html_tags.pas
Hinweis:
Um Proton als Free-Pascal IDE zu nutzen, einfach
folgenden Shortcut in den Programmeinstellungen
definieren:
command.com /k c:ppbinwin32ppc386 -Sd %A%
}
library html__generate_bullet_list;
uses classes;
const KEINE_RUECKGABE=0;
RUECKGABE_ERSETZT_MARKIERUNG = 1;
RUECKGABE_ERSETZT_EDITORTEXT = 2;
var RUECKGABETYP:integer;
function pluginStart(text:pchar; selstart,sellength:integer) : pchar; export;stdcall;
var
s:string;
list:TStrings;
i:integer;
begin
SetString(s,text,strlen(text));
if (sellength=0) then
RUECKGABETYP:=RUECKGABE_ERSETZT_EDITORTEXT
else
begin
s:=copy(s,selstart+1,sellength);
RUECKGABETYP:=RUECKGABE_ERSETZT_MARKIERUNG;
end;
list:=TStringlist.create;
list.text:=s;
for i:=0 to list.count-1 do
begin
list[i]:='<li>'+list[i]+'</li>';
end;
pluginStart := pchar('<ul>'+#10+list.text+#10+'</ul>');
end;
function pluginRueckgabetyp:Integer;export;stdcall;
begin
pluginRueckgabetyp :=RUECKGABETYP;
end;
function pluginInterfaceVersion: integer; export;stdcall;
begin
pluginInterfaceVersion := 1;
end;
exports
pluginRueckgabetyp,
pluginStart,
pluginInterfaceVersion;
end.