Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43591 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66343 invoked from network); 2 Apr 2009 12:08:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2009 12:08:18 -0000 Authentication-Results: pb1.pair.com header.from=kalle.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=kalle.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.154 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kalle.php@gmail.com X-Host-Fingerprint: 72.14.220.154 fg-out-1718.google.com Received: from [72.14.220.154] ([72.14.220.154:10760] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/58-22853-FAAA4D94 for ; Thu, 02 Apr 2009 07:08:17 -0500 Received: by fg-out-1718.google.com with SMTP id l26so766121fgb.0 for ; Thu, 02 Apr 2009 05:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=H80IM6g01Xh80FSzRv6c7h/8FIykQOnql4FzGeryt28=; b=ouTvmsWIcPPY8ngRlJE2vtNSEf8OoGj1PleQaISnJdnoXT4rYmTPwz/WKuyw/AofaE TSozESJ2GABnQtSwkNyZKog1UvHbGPjdyvdhpepmJ9NLettIUKAwhX6Eg0FX//VATFt9 2CEGdoS4YCXRhFw6+DFfuaFMNcd5sALtCBFbI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=AMq0Wb3D7OKbNsMtt9kejSGegsKwVR8gIng+BXY9AX/3L/bvNYNVEVqot+pM+v5mvm 2GuOl/YudMfR9JsnktIDzzQSHQ9XqN7lzsclYeZakNSKqN4u9qZwJS/VNeaUFT6n4iew xi735HLvL7CpCiFFwsHTwvnZdiac9g3nJlMGU= MIME-Version: 1.0 Sender: kalle.php@gmail.com Received: by 10.86.82.16 with SMTP id f16mr15235fgb.26.1238674092810; Thu, 02 Apr 2009 05:08:12 -0700 (PDT) In-Reply-To: <6F.F0.47115.84534D94@pb1.pair.com> References: <6F.F0.47115.84534D94@pb1.pair.com> Date: Thu, 2 Apr 2009 14:08:12 +0200 X-Google-Sender-Auth: fb6be9fe23614b01 Message-ID: <2dedb8a0904020508r6306c189peda001421d4e830f@mail.gmail.com> To: Justin Martin Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Update to Zend Highlighter From: kalle@php.net (Kalle Sommer Nielsen) Hi Justin 2009/4/2 Justin Martin : > Hello everyone, > > I'd like to propose a very small update, which would have no > backwards-compatibility problems, and would bring PHP closer to > standards compliance. inline styles are standards compliant, but I know what you mean, inline styles aren't always nice to work with ;) > > The update I'd like to propose is to the Zend Highlighter for PHP, > specifically related to the highlight_file and highlight_string > functions, as well as the php -s command. > > My proposal is a very simple one, which would add a third parameter, > which would be optional, which would select between "inline" styling, > and external styling. The proposed syntax for highlight_file would be: > > mixed highlight_file (string $filename [, bool $return= false [, bool > $inline= true]]); > > Currently, syntax highlighting is done inline, by means of the style > attribute of the span tag (...). My > proposition would be for a "class" attribute to be set instead of the > style attribute, based on the value of $inline ( class="phpcomment">...). I have written a quick and easy patch for this [1], which instead of adding a new parameter to the highlight functions adds 6 new ini settings: highlight.inline_class (yes I know the name is weird, but thought it was better than highlight.use_classes or similar) highlight.class_(comment|default|keyword|html|string) Each of the highlight.class_* sets a default class to use, these are editable so they won't conflict with class names your style might have defined to something else, therefore making it more modular. A simple: $ php -d highlight.inline_class=1 -s -f file.php Will now give: ... Instead of before giving: ... I thought using ini settings was more in place with how the current API works so I went that way. The patch isn't perfect but it does its job, note that its written for PHP_5_3, but since we're in RC stage theres really no chance of it getting added. > > The issue this modification is intended to fix is that many developers > who intend to provide syntax highlighting in their project end up > rolling their own code for such. By providing external styling code > rather than inline styling, it makes it possible to modify the style of > all highlighted code, without modifying the code itself. It also > provides the capability to extend the viewing experience with > Javascript, such as code folding functionality. > > I've taken the liberty to produce a very quick and dirty patch, which is > by no means complete, but provides a cursory example of what I intend. > > I'd like to clarify that this is the first time I've modified PHP's > code, and I know very little C. The only modifications I've done for PHP > in the past have been in the PHP-GTK branch, attempting to fix the > documentation generator to work with the non-standard extension > structure. If I've submitted my proposal poorly, I apologize. > > Please offer any comments you have. > > Thank you, > Justin Martin aka FrozenFire > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > [1] http://www.paste2.org/p/176166 -- Kalle Sommer Nielsen kalle@php.net