Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 01.09.08 13:25 
Hallo,

mal ne Frage an die Web-Programmierer:
Es gibt ja BBCodes wie Quote, Size etc. Die einen Parameter haben (können)
Nun haben Boards ja die Kontrolle, ob es gleich viele öffnende, wie schließende Tags gibt, das ist auch nicht das Problem...

Mein Problem ist eher: Wie kriege ich die entsprechenden Codes nach HTML geparst?
Weil ich ja zuerstmal den [size= in den entsprechenden Code ändere, dann hab ich aber das Problem, was ich mit dem ] am ende anfangen soll... dazwischen steht die Zahl, aber die kann ja beliebig sein...

Kann mir da jemand nen Tipp geben?
einfach alle [ in < und alle ] in > zu ändern führt ja zu Problemen, wenn man nen Fehler bei den Tags hat...

Danke im Vorraus,
Wolle

_________________
1405006117752879898543142606244511569936384000000000.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 01.09.08 14:29 
Google mal nach Suche bei Google BBCODE PARSER PHP. Das erste Ergebnis sieht recht vielversprechend aus: BBCode-Parserklasse für PHP
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 01.09.08 15:10 
Okay, ich baus mal ein gucke wies wird...

@Irgendwer ders hier weiß: Wie läuft das denn hier im Forum?

_________________
1405006117752879898543142606244511569936384000000000.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 01.09.08 18:07 
irgendwie versteh ich die callback-funktionen nicht wirklich...

_________________
1405006117752879898543142606244511569936384000000000.
j.klugmann
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 01.09.08 18:10 
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 01.09.08 18:30 
was callback-funktionen sind, das weiß ich, nur nicht, wie die bei dem Parser aufgebaut sein müssen...
Bin halt mal wieder etwas zu doof ;)

_________________
1405006117752879898543142606244511569936384000000000.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 01.09.08 20:57 
user profile iconWolle92 hat folgendes geschrieben:
Wie läuft das denn hier im Forum?

Wie die erste Footer-Zeile verkündet:

Entwickler-Ecke.de 3.1.5 based on phpBB

Du kannst dir natürlich auch phpBB anschauen, aber das sind sehr, sehr viele Dateien. Bis du da den Teil gefunden hast, der den BBCode parst, ist einige Zeit verstrichen. Vor allem, weil phpBB3 auch noch benutzerdefinierte Tags unterstützt.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 01.09.08 21:03 
Hm, ok, lassen wir das mit hier... ;)

_________________
1405006117752879898543142606244511569936384000000000.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 05.09.08 13:00 
Die Callbacks in PHP sind recht einfach:

ausblenden Quelltext
1:
2:
$Callback = 'Funktionsname';
$Callback($Param1, $Param2);


bzw. für Klassen:
ausblenden Quelltext
1:
2:
$StaticCallback = array('Classname', 'Methodname');
$StaticCallback($Param1, $Param2);


ausblenden Quelltext
1:
2:
$DynamicCallback = array($Instance, 'Methodname');
$DynamicCallback($Param1, $Param2);

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Di 09.09.08 09:03 
RegExe sind ein ein ungeheuer mächtige Werkzeug um das zu bewerkstelligen.

Also angenommen, es geht um das tag
ausblenden Quelltext
1:
<span style="font-size: 6px; line-height: normal">Ein Text in Schriftgröße 6</span>					

Dann wäre ein passendere Regex um das Ding zu finden:
ausblenden Quelltext
1:
\[size=(\d*)\](.*)\[\/size\]					


das ganze in die funktion preg_replace() gepackt und schon werden alle [size]-Tags in <span style="font-size:6pt">Ein Text in Schriftgröße 6</span> umgewandelt

ausblenden Quelltext
1:
2:
3:
4:
5:
$text = preg_replace(
  '/\[size=(\d*)\](.*)\[\/size\]/i',
  '<span style="font-size:\\1pt>\\2</span>',
  $text
);


Das kann man dann natürlich beliebig für andere Tags wiederholen. Streckt den Code zwar ein wenig, aber es erfüllt seinen Zweck.

Zum Verständnis von RegExen empfehle ich diese Seite

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 09.09.08 12:25 
Wobei phpBB hier noch (?R) nutzt, d.h. Rekursiv matcht, um bei verschachtelten Regechsen das richtige Ende zu finden ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.