Parsing CSS background-image

后端 未结 2 839
有刺的猬
有刺的猬 2021-01-05 15:06

How do I parse CSS background-image, which supports multiple values, which may be none and functions (e.g. url() and linear-grad

2条回答
  •  离开以前
    2021-01-05 15:28

    Looking at the current W3C Candidate Recommendation for CSS3 (in particular, see background-image and uri), it is structured as follows:

     =  [ ,  ]* 
     =  | none
     =  |  |  |  | 
    

    ... (you can find the rest of syntax for images here)

    EDIT:

    You will need to parse for matching parenthese or none then, and the former is not possible with regex. This post has a pseudo code for the algorithm: Python parsing bracketed blocks.

提交回复
热议问题