如何使用正确的lang参数? [英] How to use correct lang parameter?
问题描述
我在新的UBUNTU 18 LTS中安装了新的Mediawiki ... "SyntaxHighlight" 'extension 不适用于 Unix shell ,lang="sh"
,lang="shell"
, lang="bash"
,...没有人在工作.它不在 #Supported_language 上,也没有关于如何安装的线索其他标记".
在 mediawiki.org/list 上,没有任何线索.
那么,如何解决该问题?是配置,环境或语法问题?
注释和测试
注意.
-
这是一个法人的Wiki,无法提供公共URL ...但这是一个全新的,标准的和受控制的安装,所有都是生殖的和标准的.
-
该Wiki配置了皮肤矢量"和语言巴西葡萄牙语".
测试.
-
mediawiki.org/Extension:SyntaxHighlight的用法测试 ,即Python示例.
1.1.带有标签
<syntaxhighlight>
.结果:没有突出显示,与<pre>
相同.1.2.带有标签
<source>
.结果:没有突出显示,与<pre>
相同. -
PHP示例,来自 wikipedia.org/PHP语法的片段.
2.1.带有标签
<syntaxhighlight>
.结果:没有突出显示,与<pre>
相同.2.2.带有标签
<source>
.结果:没有突出显示,与<pre>
相同.
测试中使用的代码片段:
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语法突出显示器使用了Pygments库,您应该首先下载并安装扩展名:
要求
此扩展版本已通过Pygments 1.6、2.0.2和 截至2015年6月19日,MediaWiki 1.25.获得与此扩展程序兼容的版本 使用MediaWiki的早期版本,请访问:
https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi
下载
https://github.com/wikimedia/mediawiki -extensions-SyntaxHighlight_GeSHi/archive/master.tar.gz
安装
将此行添加到您的LocalSettings.php:
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
默认情况下,此扩展将使用Pygments 2.0.2的捆绑副本.如果你 想要使用库的其他副本,您可以设置 $ wgPygmentizePath指向"pygmentize"二进制文件的路径.
用法
现在在Wiki页面上,您可以使用源"元素:
<source lang="php">
<?php
v = "string"; // sample initialization
?>
html text
<?php
echo v; // end of php code
?>
</source>
参数
有关这些参数的详细信息,请参见Pygments的文档. HtmlFormatter,网址为 http://pygments.org/docs/formatters/#HtmlFormatter .>
- lang;定义语言.
- 行;对应于linenos ="inline"选项.
- 开始;对应于linenostart opion.
- 附上;如果设置为"none",则对应于nowrap = 1选项.
- 内联;对应于nowrap = 1选项.
- 要点;对应于hl_lines选项(以逗号分隔).
注意
Pygments慷慨地创建HTML元素:突出显示大块的 代码可以轻松生成足够多的代码以使浏览器崩溃.警惕,语法 对于大于100 kB的代码片段,高亮显示处于关闭状态.
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.
这篇关于如何使用正确的lang参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!