HTML5< code> element有一个
optional class=”language-” attribute来定义代码片段的语言.规范中的一个例子:
<pre><code class="language-pascal">var i: Integer; begin i := 1; end.</code></pre>
是否有要使用的语言列表?只是认为否则可能存在多种不同的拼写或对语言的解释,例如VB6 vs visual basic 6等
解决方法
在WHATWG的
HTML Living Standard版规范中,它实际上建议在< code>上添加类属性的值. “language- *”元素:
从HTML Living Standard: Text-Level Semantics – the code element开始
There is no formal way to indicate the language of computer code being marked up. Authors who wish to mark code elements with the language used,e.g. so that syntax highlighting scripts can use the right rules,can use the class attribute,e.g. by adding a class prefixed with “language-” to the element.
(但是,我认为这个前缀没有实际价值 – 这将取决于现实世界的网站是否采用惯例以及第三方工具是否检测并实际实现此前缀.)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。