NetzSchleicher
Mitglied
Moin!
Da ich ja jetzt über eine Möglichkeit verfüge, HTML und PHP highlighten zu lassen, brauche ich das gleiche noch für CSS, damit die Grundsammlung beisammen ist. Ich orientiere mich da nach dem Highlight-Schema von Phase5, da mir dies sehr gut gefällt.
Zuerst schreibe ich alle validen Befehle in CSS, die auch jeder benutzt, in ein Array und lasse später die Replaces (preg_replace) in einer for-Schleife durchlaufen, da alles nacheinander zu aufwändig sein würde. Allerdings bekomme ich keinen Code zurückgegeben...
Funktion für das CSS-Highlighting:
Befehl im BBCode:
Leider bekomme ich da nichts ausgegeben...
Da ich ja jetzt über eine Möglichkeit verfüge, HTML und PHP highlighten zu lassen, brauche ich das gleiche noch für CSS, damit die Grundsammlung beisammen ist. Ich orientiere mich da nach dem Highlight-Schema von Phase5, da mir dies sehr gut gefällt.
Zuerst schreibe ich alle validen Befehle in CSS, die auch jeder benutzt, in ein Array und lasse später die Replaces (preg_replace) in einer for-Schleife durchlaufen, da alles nacheinander zu aufwändig sein würde. Allerdings bekomme ich keinen Code zurückgegeben...
Funktion für das CSS-Highlighting:
PHP:
<?php
/* Highlight Functions for Code */
function highlight_css($str)
{
//Bold Words in Array
$bolds = array(
# HTML Elements
"body",
"html",
"head",
# Div Element
"div",
# Table Elements
"table",
"tr",
"td",
# Frame Elements
"iframe",
"frame",
# Link Elements
"a",
# Text Elements
"span",
"label",
# Header Elements
"h1",
"h2",
"h3",
"h4",
"h5",
# Form Elements
"input",
"select",
"option",
"optgroup",
"textarea",
# Margin and Padding
"margin",
"margin-left",
"margin-bottom",
"margin-right",
"margin-top",
"padding",
"padding-left",
"padding-bottom",
"padding-right",
"padding-top",
# Position Values
"position",
"top",
"left",
"bottom",
"right",
# Color and Image Values
"img",
"background-image",
"background-repeat",
"background-attachment",
"background-color",
"background-position",
"color",
# Align Values
"middle",
"center",
"justify",
"align",
"text-align",
"vertical-align",
# Text Methods
"text-align",
"text-indent",
"text-transform",
# --> Text-Transform
"uppercase",
"lowercase",
"capitalize",
"text-top",
"text-bottom",
# Spacing Values
"letter-spacing",
"word-spacing",
# Overflow
"overflow",
# Font Values
"font-size",
# --> Line-height
"line-height",
"font-weight",
"font-style",
"font-family",
"font",
# Display
"display",
"visibility",
# --> Types
"visible",
"hidden",
# Borders
"border",
"border-color",
"border-width",
"border-style",
# --> Types
"solid",
"dashed",
"dotted",
"none",
"groove",
"inset",
"double",
"ridge",
"outset",
"border-bottom",
"border-bottom-color",
"border-bottom-style",
"border-bottom-width",
"border-top",
"border-top-color",
"border-top-style",
"border-top-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-spacing",
"border-collapse",
# --> Types
"collapse",
"seperate",
# Float and Clear
"float",
"clear",
# Extra Type
"both",
"all",
# Height and Width
"height",
"width",
# Lists
"list-style",
"list-style-type",
# Types
"none",
"circle",
"square",
"disc",
"decimal",
"lower-roman",
"upper-roman",
"decimal-leading-zero",
"lower-latin",
"upper-latin",
"lower-greek",
"armenian",
"georgian",
"list-style-image",
"list-style-position",
# Types
"inside",
"outside",
# Z-Index
"z-index",
# url()
"url",
# Classes
":hover",
":active",
":visited",
":link",
":lang",
":focus",
":first-line",
":first-letter",
":first-child",
":before",
":after",
);
for ( $i = 0; $i < count($bolds); $i++ )
{
$code = preg_replace("!(".$bolds[$i].")!","<strong class='bold'>".$bolds[$i]."</strong>",$code);
}
return $code;
}
?>
Befehl im BBCode:
PHP:
<?php
function bbcode($str)
...
$str = preg_replace("!\[css\](.*)\[/css\]!isUe","highlight_css('\\1', TRUE);",$str);
...
}
?>
Leider bekomme ich da nichts ausgegeben...