热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

是否有一个朗-vb或朗-基本选项美化。js从谷歌吗?-Istherealang-vborlang-basicoptionforprettify.jsfromGoogle?

VisualBasiccodedoesnotrendercorrectlywithprettify.jsfromGoogle.可视的基本代码不能正确地渲染美化。js从谷歌。o

Visual Basic code does not render correctly with prettify.js from Google.

可视的基本代码不能正确地渲染美化。js从谷歌。

on Stack Overflow:

堆栈溢出:

Partial Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'set page title
        Page.Title = "Something"
    End Sub

End Class

in Visual Studio...

在Visual Studio……

Visual Basic in Visual Studio

I found this in the README document:

我在自述文件中发现:

How do I specify which language my code is in?

如何指定代码所在的语言?

You don't need to specify the language since prettyprint() will guess. You can specify a language by specifying the language extension along with the prettyprint class like so:

您不需要指定语言,因为prettyprint()会猜测。可以通过指定语言扩展名和prettyprint类来指定语言,如下所示:

  The lang-* class specifies the language file extensions.
  Supported file extensions include
    "c", "cc", "cpp", "cs", "cyc", "java", "bsh", "csh", "sh",
    "cv", "py", "perl", "pl", "pm", "rb", "js",
    "html", "html", "xhtml", "xml", "xsl".

I see no lang-vb or lang-basic option. Does anyone know if one exists as an add-in?

我没有看到lang-vb或lang-basic选项。有谁知道是否有一个作为外接程序存在吗?


Note: This is related to the VB.NET code blocks suggestion for Stack Overflow.

注意:这与VB有关。NET代码块对堆栈溢出的建议。

3 个解决方案

#1


8  

/EDIT: I've rewritten the whole posting.

/编辑:我重写了整个帖子。

Below is a pretty complete solution to the VB highlighting problem. If SO has got nothing better, please use it. VB syntax highlighting is definitely wanted.

下面是对VB突出问题的一个非常完整的解决方案。如果没有更好的,请使用它。绝对需要VB语法高亮显示。

I've also added a code example with some complex code literals that gets highlighted correctly. However, I haven't even tried to get XLinq right. Might still work, though. The keywords list is taken from the MSDN. Contextual keywords are not included. Did you know the GetXmlNamespace operator?

我还添加了一个代码示例,其中包含一些正确突出显示的复杂代码文本。但是,我还没试过让XLinq正确。不过,可能仍然工作。关键词列表取自MSDN。不包含上下文关键字。您知道GetXmlNamespace操作符吗?

The algorithm knows literal type characters. It should also be able to handle identifier type characters but I haven't tested these. Note that the code works on HTML. As a consequence, &, are required to be read as named (!) entities, not single characters.

算法知道文字类型字符。它还应该能够处理标识符类型的字符,但我还没有对它们进行测试。注意,代码在HTML上工作。因此,&、 <和> 必须被读取为命名(!)实体,而不是单个字符。

Sorry for the long regex.

对不起,我的长正则表达式。

var highlightVB = function(code) {
    var regex = /("(?:""|[^"])+"c?)|('.*$)|#.+?#|(&[HO])?\d+(\.\d*)?(e[+-]?\d+)?U?([SILDFR%@!#]|&)?|\.\d+[FR!#]?|\s+|\w+|&|<|>|([-+*/\\^$@!#%&<>()\[\]{}.,:=]+)/gi;

    var lines = code.split("\n");
    for (var i = 0; i  1 && c1 == '.' && isDigit(tok.charAt(1)) ||
                        tok.length > 5 && (tok.indexOf("&") == 0 &&
                        tok.charAt(5) == 'H' || tok.charAt(5) == 'O')
                    )
                        result += span("number", tok);
                    else if (isKeyword(tok))
                        result += span("keyword", tok);
                    else
                        result += tok;
                    break;
            }
        }

        lines[i] = result;
    }

    return lines.join("\n");
}

var keywords = [
    "addhandler", "addressof", "alias", "and", "andalso", "as", "boolean", "byref",
    "byte", "byval", "call", "case", "catch", "cbool", "cbyte", "cchar", "cdate",
    "cdec", "cdbl", "char", "cint", "class", "clng", "cobj", "const", "continue",
    "csbyte", "cshort", "csng", "cstr", "ctype", "cuint", "culng", "cushort", "date",
    "decimal", "declare", "default", "delegate", "dim", "directcast", "do", "double",
    "each", "else", "elseif", "end", "endif", "enum", "erase", "error", "event",
    "exit", "false", "finally", "for", "friend", "function", "get", "gettype",
    "getxmlnamespace", "global", "gosub", "goto", "handles", "if", "if",
    "implements", "imports", "in", "inherits", "integer", "interface", "is", "isnot",
    "let", "lib", "like", "long", "loop", "me", "mod", "module", "mustinherit",
    "mustoverride", "mybase", "myclass", "namespace", "narrowing", "new", "next",
    "not", "nothing", "notinheritable", "notoverridable", "object", "of", "on",
    "operator", "option", "optional", "or", "orelse", "overloads", "overridable",
    "overrides", "paramarray", "partial", "private", "property", "protected",
    "public", "raiseevent", "readonly", "redim", "rem", "removehandler", "resume",
    "return", "sbyte", "select", "set", "shadows", "shared", "short", "single",
    "static", "step", "stop", "string", "structure", "sub", "synclock", "then",
    "throw", "to", "true", "try", "trycast", "typeof", "variant", "wend", "uinteger",
    "ulong", "ushort", "using", "when", "while", "widening", "with", "withevents",
    "writeonly", "xor", "#const", "#else", "#elseif", "#end", "#if"
]

var isKeyword = function(token) {
    return keywords.indexOf(token.toLowerCase()) != -1;
}

var isDigit = function(c) {
    return c >= '0' && c <= '9';
}

var getToken = function(tokens) {
    for (var i = 0; i " + text + "";
}

Code for testing:

代码测试:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    'set page title
    Page.Title = "Something"
    Dim r As String = "Say ""Hello"""
    Dim i As Integer = 1234
    Dim d As Double = 1.23
    Dim s As Single = .123F
    Dim l As LOng= 123L
    Dim ul As ULOng= 123UL
    Dim c As Char = "x"c
    Dim h As Integer = &H0
    Dim t As Date = #5/31/1993 1:15:30 PM#
    Dim f As Single = 1.32e-5F
End Sub

#2


2  

Prettify does support VB comments as of the 8th of January 2009.

在2009年1月8日,“美化”确实支持VB的评论。

To get vb syntax highlighting working correctly you need three things;

要使vb语法高亮显示正确工作,您需要三件事;



and a PRE block around your code eg:

在你的代码周围加上一个预块。

 Function SomeVB() as string
   ' do stuff
   i = i + 1
 End Function

Stackoverflow is missing the lang-vb.js inclusion, and the ability to specify which language via Markdown, ie: class="prettyprint lang-vb" which is why it doesn't work here.

Stackoverflow缺少了lang-vb。js包含,以及通过Markdown指定哪一种语言的能力,即class="prettyprint lang-vb",这就是为什么它在这里不起作用的原因。

for details on the issue: see the Prettify issues log

有关此问题的详细信息:请参阅“美化问题”日志

#3


0  

In the meantime, you can put an extra comment character at the end of your comments to get it to look okay. For example:

与此同时,您可以在注释的末尾添加一个额外的注释字符,以使其看起来良好。例如:

Sub TestMethod()
    'Method body goes here'
End Sub

You also need to escape internal comment characters in the normal vb-fashion:

您还需要以正常的vb方式转义内部注释字符:

Sub TestMethod2()
    'Here''s another comment'
End Sub

Prettify still treats it as a string literal rather than a comment, but at least it looks okay.

beautitify仍然将它视为字符串文字,而不是注释,但至少看起来还不错。

Another method I've seen is to start comments with an extra '//, like this:

我看到的另一种方法是以一个额外的“//”开始评论,就像这样:

Sub TestMethod3()
    ''// one final comment
End Sub

Then it's handled like a comment, but you have to deal with C-style comment markers

然后像注释一样处理它,但是你必须处理c风格的注释标记


推荐阅读
  • Java EE 平台集成了多种服务、API 和协议,旨在支持基于 Web 的多层应用程序开发。本文将详细介绍 Java EE 中的 13 种关键技术规范,帮助开发者更好地理解和应用这些技术。 ... [详细]
  • vue引入echarts地图的四种方式
    一、vue中引入echart1、安装echarts:npminstallecharts--save2、在main.js文件中引入echarts实例:  Vue.prototype.$echartsecharts3、在需要用到echart图形的vue文件中引入:   importechartsfrom&amp;quot;echarts&amp;quot;;4、如果用到map(地图),还 ... [详细]
  • 包含phppdoerrorcode的词条 ... [详细]
  • WCF类型共享的最佳实践
    在使用WCF服务时,经常会遇到同一个实体类型在不同服务中被生成为不同版本的问题。本文将介绍几种有效的类型共享方法,以解决这一常见问题。 ... [详细]
  • 微服务优雅上下线的最佳实践
    本文介绍了微服务上下线的正确姿势,避免使用 kill -9 等粗暴手段,确保服务的稳定性和可靠性。 ... [详细]
  • 2020年9月15日,Oracle正式发布了最新的JDK 15版本。本次更新带来了许多新特性,包括隐藏类、EdDSA签名算法、模式匹配、记录类、封闭类和文本块等。 ... [详细]
  • 本文详细介绍了Java代码分层的基本概念和常见分层模式,特别是MVC模式。同时探讨了不同项目需求下的分层策略,帮助读者更好地理解和应用Java分层思想。 ... [详细]
  • 装饰者模式(Decorator):一种灵活的对象结构设计模式
    装饰者模式(Decorator)是一种灵活的对象结构设计模式,旨在为单个对象动态地添加功能,而无需修改原有类的结构。通过封装对象并提供额外的行为,装饰者模式比传统的继承方式更加灵活和可扩展。例如,可以在运行时为特定对象添加边框或滚动条等特性,而不会影响其他对象。这种模式特别适用于需要在不同情况下动态组合功能的场景。 ... [详细]
  • 在处理大规模数据数组时,优化分页组件对于提高页面加载速度和用户体验至关重要。本文探讨了如何通过高效的分页策略,减少数据渲染的负担,提升应用性能。具体方法包括懒加载、虚拟滚动和数据预取等技术,这些技术能够显著降低内存占用和提升响应速度。通过实际案例分析,展示了这些优化措施的有效性和可行性。 ... [详细]
  • 在C#编程中,数值结果的格式化展示是提高代码可读性和用户体验的重要手段。本文探讨了多种格式化方法和技巧,如使用格式说明符、自定义格式字符串等,以实现对数值结果的精确控制。通过实例演示,展示了如何灵活运用这些技术来满足不同的展示需求。 ... [详细]
  • 全面升级的中文PubMed——Medreading
    Medreading 是一款由科研者之家(HOME for Researchers)推出的中文版PubMed,提供强大的文献检索和分析功能,支持AI辅助全文下载。 ... [详细]
  • VS2019 在创建 Windows 恢复点时出现卡顿问题及解决方法
    在使用 Visual Studio 2019 时,有时会在创建 Windows 恢复点时遇到卡顿问题。这可能是由于频繁的自动更新导致的,每次更新文件大小可能达到 1-2GB。尽管现代网络速度较快,但这些更新仍可能对系统性能产生影响。本文将探讨该问题的原因,并提供有效的解决方法,帮助用户提升开发效率。 ... [详细]
  • PTArchiver工作原理详解与应用分析
    PTArchiver工作原理及其应用分析本文详细解析了PTArchiver的工作机制,探讨了其在数据归档和管理中的应用。PTArchiver通过高效的压缩算法和灵活的存储策略,实现了对大规模数据的高效管理和长期保存。文章还介绍了其在企业级数据备份、历史数据迁移等场景中的实际应用案例,为用户提供了实用的操作建议和技术支持。 ... [详细]
  • 基于Net Core 3.0与Web API的前后端分离开发:Vue.js在前端的应用
    本文介绍了如何使用Net Core 3.0和Web API进行前后端分离开发,并重点探讨了Vue.js在前端的应用。后端采用MySQL数据库和EF Core框架进行数据操作,开发环境为Windows 10和Visual Studio 2019,MySQL服务器版本为8.0.16。文章详细描述了API项目的创建过程、启动步骤以及必要的插件安装,为开发者提供了一套完整的开发指南。 ... [详细]
  • 如何使用 `org.apache.tomcat.websocket.server.WsServerContainer.findMapping()` 方法及其代码示例解析 ... [详细]
author-avatar
卡布基诺2502934121
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有