How to use correct lang parameter? - syntax-highlighting

I have a fresh Mediawiki installed into fresh UBUNTU 18 LTS... The ''SyntaxHighlight'' extension not works for Unix shell, lang="sh", lang="shell", lang="bash", ... no one is working. It is not at #Supported_languages, and there are no clues about how to install "Other markup".
At mediawiki.org/list there are no clues.
So, how to solve the problem? It is a config, env or syntax problem?
NOTES AND TESTS
Notes.
It is a corporative Wiki, no way to offer public URL... But it is a fresh, standard and controlled installation, all reproductive and standard.
The Wiki was configured with skin "Vector" and language "Brazilian Portuguese".
Tests.
Usage tests of mediawiki.org/Extension:SyntaxHighlight, the Python example.
1.1. With tag <syntaxhighlight>. Result: no highlight, same as <pre>.
1.2. With tag <source>. Result: no highlight, same as <pre>.
PHP example, fragment from wikipedia.org/PHP Syntax.
2.1. With tag <syntaxhighlight>. Result: no highlight, same as <pre>.
2.2. With tag <source>. Result: no highlight, same as <pre>.
The code fragments used in the tests:
def quickSort(arr):
less = []
pivotList = []
more = []
if len(arr) <= 1:
return arr
else:
pass
<title>PHP "Hello, World!" program</title>
<?php echo '<p>Hello World</p>'; ?>

MediaWiki Syntax highlighter used Pygments library, you should first download and install the extension:
Requirements
This version of the extension has been tested with Pygments 1.6, 2.0.2 and
MediaWiki 1.25 as of 2015-06-19. To get releases of this extension compatible
with earlier versions of MediaWiki, visit:
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi
Download
https://github.com/wikimedia/mediawiki-extensions-SyntaxHighlight_GeSHi/archive/master.tar.gz
Installation
Add this line to your LocalSettings.php:
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
By default, this extension will use a bundled copy of Pygments 2.0.2. If you
would like to use a different copy of the library, you can set
$wgPygmentizePath to point to the path to the 'pygmentize' binary.
Usage
On the wiki page, you can now use "source" elements:
<source lang="php">
<?php
v = "string"; // sample initialization
?>
html text
<?php
echo v; // end of php code
?>
</source>
Parameters
For details information of these parameters, see the documentation of Pygments'
HtmlFormatter at http://pygments.org/docs/formatters/#HtmlFormatter.
lang; Defines the language.
line; Corresponds to linenos="inline" option.
start; Corresponds to linenostart opion.
enclose; If set to "none", corresponds to the nowrap=1 option.
inline; Corresponds to the nowrap=1 option.
highlight; Corresponds to hl_lines option (comma separated).
Note
Pygments is generous about creating HTML elements: highlighting large blocks of
code can easily generate enough of them to crash a browser. As a guard, syntax
highlighting is turned off for code fragments larger than 100 kB.

Related

How can I debug plugins that are being silently ignored?

Newcomer to Jekyll here (previously on Hyde).
Ruby files placed in the _plugins/ directory are apparently silently ignored.
I am using version 0.11.2 of Jekyll, with ruby 1.8.7 on Ubuntu 12.04.
Should an extra config parameter be added to load these plugins? The doc doesn't say so - the sane default should be to look into _plugins, and they should be required automatically. How can one debug the loading of Jekyll plugins?
For my instance of jekyll (also 0.11.2, but with ruby 1.9.2p290 on a Mac), I don't have to add any extra configuration, but you can try adding the following line to your top level "_config.yml" file.
plugins: _plugins
or, possibly,
plugins: ./_plugins
The simplest way to test that your plugins are working is to remove all of them except for one that you know will work. I've put together the following which works as expected on my install.
Create a new file in the root of your jekyll source directory called "plugin_test.md" with the following contents:
---
layout: default
title: Plugin Test
---
the quick brown fox jumps over the lazy dog.
Testing plugin output of '_plugins/testplugin.rb': {% testplugin %}
Note that you may need to change "layout: default" to whatever you are actually using.
Create a new file at "_plugins/testplugin.rb" with the following contents:
module Jekyll
class TestPlugin < Liquid::Tag
def render(context)
"It's Working!"
end
end
end
Liquid::Template.register_tag('testplugin', Jekyll::TestPlugin)
Run jekyll on your source dir.
All that testplugin.rb does is replace instances of the liquid tag {% testplugin %} with the text "It's Working!". If your plugins are triggering, you'll see the output
Testing plugin output of '_plugins/testplugin.rb': It's Working!"
on the page "plugin_test.html" at your output site root. If you see:
Testing plugin output of '_plugins/testplugin.rb':
that means that the plugin didn't trigger. If you run into that, I think it's a sign that something is pretty out of whack and would advise reinstalling jekyll.
I know I'm little bit late but for others who still come across this question I would like to add my resolution:
Restart the server to get the newly added plugin working. So stop jekyll serve (Ctrl C) and restart it again with jekyll serve.

how to install gmagick extension of php on windows vista

gmagick is newer version of imagemagick with more set of features it is less resource intensive and fast but the problem is there is very few discussion about this wonderful tool on web i recently came across this on
http://devzone.zend.com/1559/manipulating-images-with-php-and-graphicsmagick/
but i could not install it on windows machines cos phpize did not work so i tried some other way and some how managed to get on phpinfo page but i could not make it work further i colud not even open a single image with gmagick
this is code i used
<?php
$path="gallery/img1.jpg";
// initialize object
$image = new Gmagick($path);
echo $image;
// read image file
$file = 'gallery/img1.jpg';
$image->readImage($file);
echo '<img src="' . $file . '" width="200" height="150" /> <br/>';
?>
i used this code to instanstiate gmagick class and open image but i am geeting very big error as follows
Fatal error: Uncaught exception 'GmagickException' with message 'Unable to open file (gallery/img1.jpg)' in C:\xampp\htdocs\junk\imgproc\imgproc1.php:4 Stack trace: #0 C:\xampp\htdocs\junk\imgproc\imgproc1.php(4): Gmagick->__construct('gallery/img1.jp...') #1 {main} thrown in C:\xampp\htdocs\junk\imgproc\imgproc1.php on line 4
A) To answer the question in your headline (that might lead other readers here):
Windows builds of the GraphicsMagick extension for PHP can be obtained here:
http://valokuva.org/builds/
Check whether you need the thread-safe version or not by looking at a phpinfo(); output of your webserver. Look for the entry Thread Safety. In the entry PHP Extension Build you should also find the VC version that you need, e.g. API20090626,TS,VC9 for VC9.
Download the latest build that matches your conditions, put it into your PHP/ext directory and add it to your php.ini like this:
extension=php_gmagick_ts.dll
Remember to correct the name of the dll if you use the non-TS version.
Restart Apache and check phpinfo();. There should be a gmagick block now..
B) To correct the problem with your code:
The Gmagick constructor does not expect a path as a parameter, but a full image filename (may include a path). Most often it is better to leave it empty and provide the file in the readImage() call.
Try a full $path (starting at root) and use it in readImage() and writeImage():
Here is an example of a working piece of code:
<?php
// assuming this is the path to your code and to your image files
$path = 'C:\xampp\htdocs\junk\imgproc\';
$image = new Gmagick();
$file = 'img1.jpg';
$image->readImage($path.$file);
// The rest of your code does not make any use of the GM instance,
// so I add something functional here: create a grayscale version and show it
$fileOut= 'img1_GRAY.jpg';
$image->setImageType(Gmagick::IMGTYPE_GRAYSCALE);
$image->writeImage($path.$fileOut);
$image->destroy();
echo "<img src='$fileOut' >";
?>
It should show a grayscale version of your image file.

How do I enable syntax highlighting for my Gemfile in Sublime Text 2?

I recently started using Sublime Text 2. What an awesome editor. It does a great job of highlighting Ruby code, but it does not highlight my Gemfile.
Is there a way to get it to do that?
I found this Gist but it has no instructions on how to use it.
There are at least three options:
Switch syntax manually (not preferred, but easy; no explanation required)
Add "Gemfile" to the list of Ruby-syntax files
Use the plugin you link to and create a package for it
1. No explanation, but handy trick
You can bind a keystroke to set syntax without moving to the mouse.
I bound syntax changing to Ctrl-Opt-Space by adding the following to my user keybindings:
[
{ "keys": ["ctrl+alt+space"],
"command": "show_overlay",
"args": { "overlay": "command_palette", "text": "Set Syntax: " } }
]
2. Add "Gemfile" to list of Ruby-syntax files
Linux: ~/.config/sublime-text-2/Packages/Ruby/Ruby.tmLanguage
OS X: ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.tmLanguage
Windows: %APPDATA%/Sublime Text 2/Packages/Ruby/Ruby.tmLanguage
You can also get there by using the menu option Preferences -> Browse Packages and going into the Ruby package. Once you're in the file it'll be obvious: it's the <array> element with Ruby-looking filenames. Add <string>Gemfile</string> and you're all set.
It's possible the setting could get overwritten on an upgrade; I'm not sure how that works with ST2–it may be cleaner to do it through code as in the snippet.
3. Using the snippet you linked to
More work (and the correction of one syntax error). You can either do it manually, by creating a directory in Packages (see above for location) or create an actual package and allow ST2 to install it.
I created a test package called "Syntax" and copied the snippet into it, restarted ST2, and opening a Gemfile worked as expected. The correction required an additional colon (new gist), nutshell:
elif name[-3] == "erb": # Needed a semi-colon here.
set_sintax(view, "HTML (Rails)", "Rails")
If you are here but are using Sublime Text 3 you might not be able able to find the 'list of Ruby-syntax files' in packages.
Most other solutions found online were confusing to me.
I fixed this by manually changing Gemfile to Ruby in the bottom right hand corner file extension menu item when you have opened the file in Sublime Text 3 (which is what I had been doing each time I opened the file up until now).
Once you have selected ruby then go to Preferences -> Settings-More -> Syntax Specific-User
{
"extensions":
[
"Gemfile",
"Gemfile.lock"
]
}
When you navigate to Syntax Specific User it opens a file specific to the language that the file has syntax highlighting for. You may need to change the file back to whatever it is defaulting too (mine was 'Rd (R Documentation).sublime-settings') and removing Gemfile from that Syntax highlighting file.
In Ubuntu these files are stored at
~/.config/sublime-text-3/Packages/User
The DetectSyntax plugin for ST2 provides a more comprehensive solution to highlighting files - It allows file highlighting based on rules. It's smart enough to understand the difference between a Rails file, other files that use .rb as an extension and standard ruby files.
The standard rules include Gemfile, Rakefile, Guardfile and others matched to Ruby for Syntax formatting.
See DetectSyntax on GitHub.
You can achieve this by copying the HTML.tmLanguage file in the User/ folder, this way it won't be overwritten by an update.

phpDocumentor on legacy code

Can phpDocumentor be used to generate HTML docs for some legacy code that does not necessarily conform to its standard?
I'd like to generate some preliminary documentation for an old code tree and later on start improving my comments and add the appropriate # tags as I get fluent with phpDocumentor. I've never used this piece of software before and the examples I've found focus on how to write new code that conforms to its syntax and generate HTML file by file with the -f parameter.
I've installed latest phpDocumentor through the PEAR command line installer and tried this little *.bat file on Windows XP:
#echo off
phpdoc ^
--directory "\\server\project\trunk" ^
--target "C:\tests\project-doc"
... but this is all I get:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
directory: '' not found
I've also tried mapping the UNC path to a drive letter:
#echo off
phpdoc ^
--directory "I:\" ^
--target "C:\tests\project-doc"
... but:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
a target directory must be specified
try phpdoc -h
This error message is the same if I create "C:\tests\project-doc" before.
What's exactly wrong in my syntax?
phpDocumentor can indeed run against "undocumented" code. It builds its docs based on the code itself, and uses the docblocks as additional info (and additional organization, in the case of #package and #subpackage tags).
I'd suggest starting with phpDocumentor against your existing code, and work towards clearing out the warnings you see in the errors.html file that results -- this file is generated in the top level of your output docs, but there isn't any link to it from the output docs.
Once you have those cleared, you can start running phpDocumentor with the -ue argument (--undocumentedelements), which will add new warnings to errors.html, highlighting (in much greater detail) things that still need to be documented in docblocks.
Now, as for the issue you're having trying to run the program against code on a shared drive, I'm not sure what's wrong there. The script is clearly able to execute PHP and find the phpDocumentor code itself. You might try putting the arguments in the same line, rather than using the ^ as a line-feed escape character, and perhaps remove the quotes around the paths (since no spaces exist in the paths).
I think I've found what the issue is. The parameter parser is very picky and it doesn't like neither UNC paths nor bare root directories. If I replace this:
--directory "I:\"
... with this:
--directory "I:\."
... it finally starts running.
I suppose it's a bug. Their bug tracker doesn't seem to be public so I don't know if it's a known issue.

poedit and xml files

How to configure poedit to extract strings from xml file?
I have Zend Framework navigation items in .xml like this:
<entry-i>
<label>Text to translate</label>
<params>
...
<params>
<entry-i>
And I want poedit to read just messages from <label>s.
I have been searching for a solution as well, and I have just gotten it to work!
In Poedit (I have 1.4.2), add a new parser (Edit > Preferences) with the following properties:
Language: XML
List of extensions separated by semicolons (e.g. .cpp;.h): *.xml
Parser command: xgettext --force-po -o %o %C %K %F -L glade
An item in keywords list: -k%k
An item in input files list: %f
Source code charset: --from-code=%c
In your translation project, add label and title to your keyword list and update the catalog.
The above advice to abuse the Glade extractor to parse non-Glade XML files is misguided. It’s never going to work well (case in point: some comments around here). Of course, it was better than nothing back in 2010.
Starting with gettext 0.19.7 (bundled with Poedit since 1.8.7), there’s a better way: there’s now builtin support in gettext for custom XML files via ITS rules.
The best way to extract strings from a custom XML file is to
Add a custom extractor with your extension, specifying standard gettext invocation, without the -L glade bit.
Write ITS rules for your file format.
Put them in the location of other .its and .loc files in Poedit’s installation.
For anyone running into problems with the configuration for Poedit on windows, specifically if you get an error message saying that glade and expat are not available, replace the supplied xgettext.exe with current one from the gnuwin32 project:
http://gnuwin32.sourceforge.net/packages/gettext.htm
You need to download the binaries and the dependencies. However, only the binary xgettext.exe must be extracted and related files (just run it and it will tell you what is missing)
Looks like PoEdit does not support XML yet.
I have created a little php script, to extract the labels to .php file,
which PoEdit does understand.
$xml = simplexml_load_file("../application/configs/navigation.xml")
or die("Error: Cannot open XML file");
echo '<?';
foreach($xml->xpath('//label') as $label){
echo 'echo _("'.$label.'");'. PHP_EOL;
}
It worked great!! I found the problem about "glade not supported" using Poedit 1.4.6 in Windows 7 but I fixed by downloading last gnuwin32 binaries and dependencies as user496209 said. Don't download the complet package because PoEdit comes with its own gettext library, so just donwload binaries and dependencies and replace the requested files into the poedit folder.

Resources