使用 geshi 语法高亮显示 Lua 长字符串无法正确显示

发布于 2024-09-18 06:01:11 字数 412 浏览 2 评论 0原文

我将新的 Lua 代码存储到使用 geshi 荧光笔(用 php 编写)的 Dokuwiki 系统中。例如,我在 lua 中遇到长字符串定义问题,

strLong = [[If this is a long string then I don't want it 
highlighted as code else it looks very silly]]

可以使用 geshi lua.php 文件来纠正这个问题,我已经快速浏览了 http://qbnz.com/highlighter/geshi-doc.html 和多行注释工作正常,它只是多行字符串,而不是。

I am storing my new Lua code in to a Dokuwiki system which uses the geshi highlighter (written in php). How ever I am having a problem with long string definitions in lua for example

strLong = [[If this is a long string then I don't want it 
highlighted as code else it looks very silly]]

It is possible to correct this using the geshi lua.php file, I have already taken a quick look at the documentation at http://qbnz.com/highlighter/geshi-doc.html and multiline comments are working fine it's just multiline strings which are not.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘和柠 2024-09-25 06:01:11

感谢 geshi 用户列表中的 Benny Baumann

GeSHi 1.0.X 中的字符串有开始和结束标记的限制
需要相同。如果不满足此约束,您必须
使用 COMMENT_REGEXP 来突出显示字符串。

正确地对长字符串进行颜色编码
在lua.php中
在 $language_data = 数组 (
add

    'COMMENT_REGEXP' => array(2 => '/\[\[(?s:.*?)\]\]/'),

在样式表中

.lua  .co2  { color: #ff0000; font-style: normal;} 

添加,当在 Lua 源上使用时,仅更改第二个注释类型,使其看起来像字符串。

With Thanks to Benny Baumann on the geshi-users list

Strings in GeSHi 1.0.X have the limitation that start and end marker
need to be the same. If this constraint is not fulfilled you have to
resort to highlighting the strings using COMMENT_REGEXP.

To correctly colour code the long strings
In lua.php
In the $language_data = array (
add

    'COMMENT_REGEXP' => array(2 => '/\[\[(?s:.*?)\]\]/'),

In the style sheet add

.lua  .co2  { color: #ff0000; font-style: normal;} 

to change only second comment type to look like a string, when used on a Lua source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文