How can I validate CSS within a script?(如何在脚本中验证 CSS?)
问题描述
是否有可以验证 CSS 的库?
Is there a library out there which will validate CSS?
我能找到的唯一工具是网站.如果其中一个网站有 API,那也符合要求.
The only tools I can find to do so are web sites. If one of these sites has an API, that would fit the bill, too.
我有一个用作 CSS 编译器的脚本.它根据主题的设置设置各种变量,并生成和写入 CSS 文件.在着手编写 CSS 文件之前,我想对其进行验证以确保没有任何无效条目.
I have a script that serves as a CSS compiler. It sets various variables according to settings for a theme, and generates and writes a CSS file. Before committing to writing the CSS file, I'd like to validate it to make sure there aren't any invalid entries.
PHP 会很方便,但 Python、Perl、Ruby、Java 或任何可从 shell 执行的东西都可以.
PHP would be convenient, but Python, Perl, Ruby, Java, or anything executable from a shell would be fine.
理想情况下,我可以将某些东西用作序列的一部分,例如:
Ideally, there's something out there that I can use as part of a sequence like:
$css_file=theme_compile('theme-name');
if(!validate_css($css_file)){
echo "css file contained invalid entry 'width:px'";//just an example, of course
}
else{
file_put_contents('/path/css_file',$css_file);
}
推荐答案
W3C有一个API:
http://jigsaw.w3.org/css-validator/api.html
您还可以下载验证器并在本地运行它:http://jigsaw.w3.org/css-validator/DOWNLOAD.html
You can also download the validator and run it locally: http://jigsaw.w3.org/css-validator/DOWNLOAD.html
您需要能够从脚本运行 java.
You need to be able to run java from your script.
这篇关于如何在脚本中验证 CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在脚本中验证 CSS?
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
