Skip to content
/ da_css.cr Public

My personal way of generating .css files using Crystal.

License

Notifications You must be signed in to change notification settings

da99/da_css.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

da_css.cr

The idea is to let users use a subset of CSS to upload their own CSS files while preventing CSS security vulnerabilities.

Security links:

Example:

Let's have a String filled with this content:

blocks = DA_CSS.parse(%[ div { border: 1px solid red; } ])

blocks.each { |blok|
  blok.selectors # Deque(DA_CSS::Selectors
  blok.propertys # Deque(Color_Keyword | Color | A_String | A_Number | ...)

  width = blok.propertys.first.values.first
  case width
  when DA_CSS::Number_Unit
    width.a_number.to_number == 1
    width.unit.token.to_s == "px"
  end
}

About

My personal way of generating .css files using Crystal.

Resources

License

Stars

Watchers

Forks

Packages

No packages published