Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for a open source PHP script to colorize the code inside
<code></code>
or
[code][/code] tags.
Thanks
You could also try a clientside/javascript highlighter: Google Code Prettify
Supports all C-like, Bash-like, and
XML-like languages.
(This is the one used on stackoverflow.com/ and code.google.com/)
Assuming you want something other than the built-in syntax highlighter, GeSHi looks like it might fit your requirements:
GeSHi started as an idea to create a generic syntax highlighter for the phpBB forum system, but has been generalised to this project. GeSHi aims to be a simple but powerful highlighting class, with the following goals:
Support for a wide range of popular languages
Easy to add a new language for highlighting
Highly customisable output formats
PHP has some built in functions for this purpose. Check if highlight_string or highlight_file will work for you
http://www.php.net/highlight_file
http://www.php.net/highlight_string
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
if is not in PHP, is possible use some command line tools which convert PO file into some structured format e.g. XML or some other which I can simple process in PHP?
Update: As of 2018/05, the best options are:
https://github.com/oscarotero/Gettext
https://symfony.com/doc/current/components/translation.html
https://docs.zendframework.com/zend-i18n/translation/
See http://www.phptherightway.com#i18n_l10n_title
There are some:
https://github.com/jyxo/php/tree/master/Jyxo/Gettext
https://github.com/clinisbut/PHP-po-parser
http://code.google.com/p/php-po-parser/
http://pear.php.net/package/File_Gettext/redirected
http://drupalcode.org/project/drupal.git/tree/HEAD:/core/lib/Drupal/Component/Gettext
The last one is part of Drupal, and it's probably the most maintained.
Some simple regular expressions will allow you to parse .PO/.POT files. I did a similar thing recently. Take the following regex from a script I have recently written:
$poMsgIdAndMsgStrRegex = '/^#\s*(.+?)\nmsgid "(.+?)"\nmsgstr "(.+?)"/m';
This does only capture the final comment line but it has so far been suitable for my purposes. You may need to adapt it.
Anyway, you can use the above regex with preg_match_all() to capture all MsgId and MsgStr strings into an array of matches. Once you have the array then you can put it into any format you wish.
There may be libraries for doing this but I have not seen any.
Edit: You may also want to check out the PHP class for converting.po files .mo format that is referred to in the 'possible duplicate' comment. It doesn't sound like it will solve your problem (since you want to convert .po files to XML), but it is worth examining anyway. It helped me a lot.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have an ancient version of Wordpress and its WYSIWYG editor really mucks up code examples in my blogs (removing lines and whitespace when saved, etc).
I wish to upgrade and install a theme/plugin that will make it easy to display code in a pleasant way.
Any suggestions?
Many sites use Google Code Prettify for syntax highlighting on code, and people have developed wordpress extensions that make it easy to add GCP to a blog. Here's an example of one:
http://www.deanlee.cn/wordpress/google-code-prettify-for-wordpress/
I recommend Syntax Highlighter Evolved.
http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/
You can use shortcodes like [php] or [css] to contain your source code, and it will be rendered nicely when you view the post/page.
I recommend WP-Syntax.
From the usage notes:
Wrap code blocks with <pre
lang="LANGUAGE" line="1"> and </pre>
where LANGUAGE is a GeSHi supported
language syntax. The line attribute is
optional.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to know the PHP code for Word to HTML conversion. When we retrive the Word document from the database and display in the frontend, the Word document should display as HTML page.
wvware
I don't completly understand your request but I think you can try TinyMCE for PHP, it's a Web based Wysiwyg editor, where all you type and format will be saved as HTML code, you can even paste and convert Word documents.
So like symcbean said, the best way to do is wvWare, otherwise,you could hardcode a class yourself, but it will be a difficult path.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Where can I find a one-page (any size) cheat sheet of PHP functions, syntax, and block constructs?
You mean something like a Cheat Sheet?
There's also a great page for the results of variable tests that I find very useful.
You may find a lot of PHP cheat sheets on TechPosters website.
PCRE, Smarty, PHP
WordPress, MySQL, Smarty...
PHP ( date formatting, regex...)
http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/
is more complete, but I think
http://www.addedbytes.com/cheat-sheets/php-cheat-sheet-version-1/
spaces it out more
These reference charts are usually referred to as cheatsheets.
Here are a few links, but Google will turn up many others:
http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/
http://www.addedbytes.com/cheat-sheets/php-cheat-sheet-version-1/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Does anyone here know of good batch file code indenters or beautifiers?
Specifically for PHP, JS and SGML-languages.
Preferably with options as to style.
The following page has code on it to tidy Javascript (written in javascript as well):
http://www.howtocreate.co.uk/tutorials/jsexamples/JSTidy.html
There are various ways to tidy SGML based files (i.e. XML) - HTMLTidy will often do the trick, and there are various 'pretty print' implementations in various languages out there.
And finally a link to a web site with PHP code for pretty printing PHP: http://tobyinkster.co.uk/blog/2007/07/17/php-pretty-printer/
For HTML/XML HTML Tidy is the best option:
http://tidy.sourceforge.net/