1

I'm parsing a css stylesheet with cssutils python module. The parser emits an error when reaching the "[dir=ltr] div.row div.label" selector.

I would like to find a way to modify the CSS to make the parser happy and maintain the same functionality.

What would be the standard way for this:

div.row div.label {
 float: left;
 width: 18%;
 text-align: right;
}
div.row div.formw {
 width: 80%;
}
[dir=ltr] div.row div.label, [dir=rtl] div.row div.formw {
 float: left;
 text-align: right;
}
[dir=rtl] div.row div.label, [dir=ltr] div.row div.formw {
 float: right;
 text-align: left;
}

Note: "dir" is used to control the direction of the text for languages like hebrew or arabic.

http://www.unics.uni-hannover.de/nhtcapri/bidirectional-text.html

Constantin
  • 27,478
  • 10
  • 60
  • 79
vejeta
  • 133
  • 11

1 Answers1

3

it's a bit slower but

*[dir=ltr] div.row div.label, *[dir=rtl] div.row div.formw {
 float: left;
 text-align: right;
}
*[dir=rtl] div.row div.label, *[dir=ltr] div.row div.formw {
 float: right;
 text-align: left;
}

should work. Obviously change * with the element with this attribute if is possible

  • It seems it works for now. It parses it now and doesn't ignore the selector. Thanks! – vejeta Nov 15 '10 at 13:54
  • 1
    `[dir=ltr]` and `*[dir=ltr]` are identical selectors - the only performance downside is the addition of the `*` character, and if you're working with a parser alone there's seriously nothing to worry about. – BoltClock Nov 21 '13 at 14:00