You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+118-1Lines changed: 118 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,18 +24,135 @@ Add the library to your composer.json
24
24
### Flipping
25
25
26
26
```php
27
-
$tree = new Sabberworm\CSS\Parser($css);
27
+
$parser = new Sabberworm\CSS\Parser($css);
28
+
$tree = $parser->parse()
28
29
$rtlcss = new MoodleHQ\RTLCSS\RTLCSS($tree);
29
30
$rtlcss->flip();
30
31
echo $tree->render();
31
32
```
32
33
33
34
For parsing options and rendering, refer to [Sabeerword/PHP-CSS-Parser](https://github.com/sabberworm/PHP-CSS-Parser).
34
35
36
+
## Output sample
37
+
38
+
```css
39
+
.div {
40
+
direction: ltr;
41
+
left: 10px;
42
+
border: 10px5px0px2px;
43
+
float: left;
44
+
}
45
+
```
46
+
47
+
Becomes:
48
+
49
+
```css
50
+
.div {
51
+
direction: rtl;
52
+
right: 10px;
53
+
border: 10px2px0px5px;
54
+
float: right;
55
+
}
56
+
```
57
+
58
+
## Options
59
+
60
+
You can prefix your CSS with comments starting with `/*rtl:*/` for special handling.
61
+
62
+
### Do not flip values
63
+
64
+
Prepend with `/*rtl:ignore*/`, or wrap within `/*rtl:begin:ignore*/` and `/*rtl:end:ignore*/`.
65
+
66
+
```css
67
+
.div {
68
+
/*rtl:ignore*/
69
+
float: left;
70
+
left: 10px;
71
+
}
72
+
.div {
73
+
direction: ltr;
74
+
/*rtl:begin:ignore*/
75
+
float: left;
76
+
left: 10px;
77
+
/*rtl:end:ignore*/
78
+
}
79
+
```
80
+
81
+
Becomes:
82
+
83
+
```css
84
+
.div {
85
+
float: left;
86
+
right: 10px;
87
+
}
88
+
.div {
89
+
direction: rtl;
90
+
float: left;
91
+
left: 10px;
92
+
}
93
+
```
94
+
95
+
### Remove CSS
96
+
97
+
Prepend with `/*rtl:remove*/`, wrap within `/*rtl:begin:remove*/` and `/*rtl:end:remove*/`.
98
+
99
+
```css
100
+
.div {
101
+
/*rtl:remove*/
102
+
float: left;
103
+
left: 10px;
104
+
}
105
+
.div {
106
+
direction: ltr;
107
+
/*rtl:begin:remove*/
108
+
float: left;
109
+
left: 10px;
110
+
/*rtl:end:remove*/
111
+
}
112
+
```
113
+
114
+
Becomes:
115
+
116
+
```css
117
+
.div {
118
+
right: 10px;
119
+
}
120
+
.div {
121
+
direction: rtl;
122
+
}
123
+
```
124
+
125
+
### Additional CSS
126
+
127
+
Write the CSS in a content starting with `/*rtl:raw:`.
128
+
129
+
```css
130
+
.div {
131
+
/*rtl:raw:
132
+
text-align: left;
133
+
*/
134
+
float: left;
135
+
}
136
+
```
137
+
138
+
Becomes:
139
+
140
+
```css
141
+
.div {
142
+
text-align: left;
143
+
float: right;
144
+
}
145
+
```
146
+
35
147
## About this tool
36
148
37
149
This tool is very heavily inspired by [MohammaYounes/rtlcss](https://github.com/MohammadYounes/rtlcss), even though at this stage it does not include all of its features. See this library as a partial port of the latter.
38
150
151
+
## Credits
152
+
153
+
*[MohammaYounes/rtlcss](https://github.com/MohammadYounes/rtlcss) for being the example we followed.
154
+
*[Sabeerword/PHP-CSS-Parser](https://github.com/sabberworm/PHP-CSS-Parser) for parsing CSS in PHP.
155
+
39
156
## License
40
157
41
158
Licensed under the [GNU GPL License](http://www.gnu.org/copyleft/gpl.html).
0 commit comments