Giter VIP home page Giter VIP logo

csspropertychecker's Introduction

CSSPropertyChecker

CSSプロパティが正しいかを判定する関数.

構成

  • CSSプロパティ一覧はTAG indexよりABC順であることを利用してスクレイプしている.
    • CSSプロパティの最新バージョンが追加されるかは分からないがスクレイピングによって最新バージョンも柔軟に気楽に取得できることを想定している.
      もっと良い・豊富な辞書サイトがあったら教えてください.
  • 関数
    • cssPropCheck($selector,$cssprop)
      この機能を呼び出す際はこの関数にHTMLタグ(セレクタ)とCSSプロパティを渡して呼び出すようにする.
      戻り値はエラーが無ければtrue,エラーがあればerror文が返される(そのため呼び出す側における判定としては is_string() を用いることが望ましい).
    • searchCSSJList($cssprop)
      CSSプロパティ一覧を格納したJSONファイルを取得し,引数に渡されたCSSプロパティの頭文字から探索範囲を限定させその中で一致するプロパティが存在するかを判定する.
      大文字小文字も区別するため,CSSプロパティは小文字で入力する前提で判定を行っている.
    • scrapeCSSListToJson()
      指定リンクよりABC順のグループとCSSプロパティ群をスクレイピングし,連想配列にまとめJSONファイルとして保存する.

使い方

  • 本コードではphpQuery-onefile.phpを使用しているので,これを以下リンクからダウンロードする.
  • test.phpを参考に.
    • 取得したHTMLタグ(セレクタ)とCSSプロパティを関数 cssPropCheck() に渡して実行する.
    • is_string() で戻り値の判定を行い,エラー文を表示させるなど.

出力例

※正常な処理においてはis_string()においてそのようにechoするようにしている.

//「font-color」という存在しないプロパティ
$result=CPC::cssPropCheck("div","font-color");

/*--------------出力--------------*/
//divにおけるCSSプロパティが間違っています。
//Wrong CSS property in div.
//大文字が混じったプロパティ
$result=CPC::cssPropCheck("table","Width");

/*--------------出力--------------*/
//tableにおけるCSSプロパティが間違っています。
//Wrong CSS property in table.
//正常
$result=CPC::cssPropCheck("body","background-attachment");

/*--------------出力--------------*/
//CSSプロパティは正しいです
//Correct CSS property.

csspropertychecker's People

Contributors

kagenomoheji avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.