Pregunta

For one of my projects, which validates JSON using JSON Schema, I miss accurate code for two format specifications: color and style.

The first specification, color, denotes whatever color is valid in CSS 2.1. The second, style, is whatever CSS 2.1 considers as a style.

I have two problems:

  • I don't know CSS that much;
  • I have the devil's time using cssparser to do the job.

The current code (here for color and here for style) will definitely allow invalid inputs, and disallow potentially valid inputs... Also, I wish I could use jStyleParser (part of the cssbox project), unfortunately it is not available on Maven, which is a requirement for me.

How can you use cssparser to accurately identify both format specifications above, if at all possible?

¿Fue útil?

Solución

First off, there is no such color as "fuschia" (CSSColorValidator.java:42), so your bets are off. It should read "fuchsia" instead. Also, "#[\da-f]{1,6}" is not a good way to parse hash-colors, they can have ONLY 3 or 6 hex digits. Either contribute to the cssparser project or find a better parser :(

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top