Syntax highlighter - Zvýraznění syntaxe v html
Občas je potřeba na webu zobrazit nějaké zdrojové kódy, např. v tutoriálech. Problém ale je, že bez zvýraznění syntaxe (čísla, rezervovaná slova atd) nevypadá kód příliš přehledně, splývá s textem. Jako řešení tohoto nedostatku vzniká (ve spolupráci s webem Jak na win) náš jednoduchý zvýrazňovač syntaxe.
Jako demonstraci přikládám ukázku několika kódů v různých jazycích - pokud jsou někomu povědomé, tak jsem je zkopíroval z http://jaknawin.com/ForumDisplayRe.aspx?ID=6&FI=6 .
Delphi
TMyComObjectFactory =
class
(TComObjectFactory)
public
procedure
UpdateRegistry(Register: Boolean); override;
end
;
function
CreateXMLTree:IXMLTree;
var
Factory: TComObjectFactory;
begin
Factory := ComClassManager.GetFactoryFromClassID(Class_XMLTreeRW);
Result := Factory.CreateComObject(
nil
)
as
IXMLTree;
end
;
function
CreateMSGRW:IMSGRW;
var
Factory: TComObjectFactory;
begin
Factory := ComClassManager.GetFactoryFromClassID(CLASS_MsgRW);
Result := Factory.CreateComObject(
nil
)
as
IMSGRW;
end
;
function
StringToWideStream(s:
string
):WideString;
begin
Result := s;
end
;
Syntax higlighted by Syntax highlighter, available at www.4ITDevelopers.net and www.JakNaWin.com
C#
public
void
TTPNaplnCmb(DropDownList aCmb, Cache aPageCache)
{
aCmb.Items.Clear();
string
[,] ATTP;
ATTP = (
string
[,])(aPageCache[
"ATTP"
]);
for
(
int
i=
0
; i <= (ATTP.Length /
2
) -
1
; i++)
aCmb.Items.Add(ATTP[i,
1
].ToString());
}
Syntax higlighted by Syntax highlighter, available at www.4ITDevelopers.net and www.JakNaWin.com
Java
public
void
InsertTopicToCache(Cache aPageCache)
{
DataSet ds = SelCmd(
"SELECT * FROM TTPList"
);
int
PocetTTP = (
int
)(ds.Tables[
0
].Rows.Count);
string
[,] ATTP =
new
string
[PocetTTP,
2
];
for
(
int
i1 =
0
; i1 <= PocetTTP -
1
; i1++)
{
ATTP[i1,
0
] = ds.Tables[
0
].Rows[i1][
"TTPNo"
].ToString();
ATTP[i1,
1
] = ds.Tables[
0
].Rows[i1][
"Name"
].ToString();
}
aPageCache[
"ATTP"
] = ATTP;
DataSet ds2 = SelCmd(
"SELECT * FROM ArticleEnv"
);
int
PocetAAT = (
int
)(ds2.Tables[
0
].Rows.Count);
string
[,] AAT =
new
string
[PocetAAT,
2
];
for
(
int
i2 =
0
; i2 <= PocetAAT -
1
; i2++)
{
AAT[i2,
0
] = ds2.Tables[
0
].Rows[i2][
"EnvNo"
].ToString();
AAT[i2,
1
] = ds2.Tables[
0
].Rows[i2][
"Name"
].ToString();
}
aPageCache[
"AAT"
] = AAT;
DataSet ds3 = SelCmd(
"SELECT * FROM ForumList"
);
int
PocetAFT = (
int
)(ds3.Tables[
0
].Rows.Count);
string
[,] AFT =
new
string
[PocetAFT,
2
];
for
(
int
i3 =
0
; i3 <= PocetAFT -
1
; i3++)
{
AFT[i3,
0
] = ds3.Tables[
0
].Rows[i3][
"ForumNo"
].ToString();
AFT[i3,
1
] = ds3.Tables[
0
].Rows[i3][
"Name"
].ToString();
}
aPageCache[
"AFT"
] = AFT;
}
Syntax higlighted by Syntax highlighter, available at www.4ITDevelopers.net and www.JakNaWin.com
Informace ke stavu builder.cz zde
vytvořil Mi.Chal. 23.7. 2005 12:53, naposledy změněnil Mi.Chal. 2.5. 2006 17:16
přečteno: 1752x