Skip to content

Commit

Permalink
Support single quotes for strings as in CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Zlobin authored and DaveDavenport committed Aug 21, 2023
1 parent 664f1b9 commit c6f3cfb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
15 changes: 8 additions & 7 deletions doc/rofi-theme.5
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,13 @@ Some of these types are a combination of other types.
.SS String
.RS
.IP \(bu 2
Format: \fB\fC"[:print:]+"\fR
Format: \fB\fC(["'])[:print:]+\\1\fR

.RE

.PP
A string is always surrounded by double quotes (\fB\fC"\fR). Between the quotes there
can be any printable character.
Strings are always surrounded by double (\fB\fC"\fR) or single (\fB\fC\&'\fR, apostrophe) quotes. Between
the quotes there can be any printable character.

.PP
For example:
Expand All @@ -592,15 +592,16 @@ The string must be valid UTF-8, special characters can be escaped:
.RS

.nf
text {
content: "Line one\\n\\tIndented line two";
}
text { content: "Line one\\n\\tIndented line two 'Quoted text'"; }
text { content: 'Line one\\n\\tIndented line two "Quoted text"'; }
text { content: "Line one\\n\\tIndented line two \\"Quoted text\\""; }

.fi
.RE

.PP
The following special characters can be escaped: \fB\fC\\b\fR, \fB\fC\\f\fR, \fB\fC\\n\fR, \fB\fC\\r\fR, \fB\fC\\t\fR, \fB\fC\\v\fR, \fB\fC\\\fR and \fB\fC"\fR\&.
The following special characters can be escaped: \fB\fC\\b\fR, \fB\fC\\f\fR, \fB\fC\\n\fR, \fB\fC\\r\fR, \fB\fC\\t\fR, \fB\fC\\v\fR, \fB\fC\\\fR,
\fB\fC"\fR and \fB\fC\&'\fR (double quotes inside single-quotes or in reverse don't need escape).

.SS Integer
.RS
Expand Down
15 changes: 8 additions & 7 deletions doc/rofi-theme.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ Some of these types are a combination of other types.

### String

- Format: `"[:print:]+"`
- Format: `(["'])[:print:]+\1`

A string is always surrounded by double quotes (`"`). Between the quotes there
can be any printable character.
Strings are always surrounded by double (`"`) or single (`'`, apostrophe) quotes. Between
the quotes there can be any printable character.

For example:

Expand All @@ -393,12 +393,13 @@ font: "Awasome 12";
The string must be valid UTF-8, special characters can be escaped:

```css
text {
content: "Line one\n\tIndented line two";
}
text { content: "Line one\n\tIndented line two 'Quoted text'"; }
text { content: 'Line one\n\tIndented line two "Quoted text"'; }
text { content: "Line one\n\tIndented line two \"Quoted text\""; }
```

The following special characters can be escaped: `\b`, `\f`, `\n`, `\r`, `\t`, `\v`, `\` and `"`.
The following special characters can be escaped: `\b`, `\f`, `\n`, `\r`, `\t`, `\v`, `\`,
`"` and `'` (double quotes inside single-quotes or in reverse don't need escape).

### Integer

Expand Down
16 changes: 9 additions & 7 deletions lexer/theme-lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,28 @@ static double rofi_theme_parse_convert_hex ( char high, char low)

ASC [\x00-\x7f]
ASCN [\x00-\t\v-\x7f]
ASCNP [\x00-\t\v-\x21\x23-\x7f]
ASCNP1 [\x00-\t\v-\x21\x23-\x7f]
ASCNP2 [\x00-\t\v-\x26\x28-\x7f]
U [\x80-\xbf]
U2 [\xc2-\xdf]
U3 [\xe0-\xef]
U4 [\xf0-\xf4]

// UANY {ASC}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
// UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
// UANY {ASC}|{UONLY}
UANYN {ASCN}|{UONLY}

UANYNP {ASCNP}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
UANYNP1 {ASCNP1}|{UONLY}
UANYNP2 {ASCNP2}|{UONLY}

WHITESPACE [[:blank:]]
WSO [[:blank:]]*
WORD [[:alnum:]-]+
WORD_ELEMENT [[:alpha:]][[:alnum:]-]*
WORD_ENV [[:alpha:]_][[:alnum:]_]*
COLOR_NAME [[:alpha:]]+
STRING \"{UANYN}*\"
STRING_LIST \"{UANYNP}*\"
STRING \"{UANYN}*\"|\'{UANYN}*\'
STRING_LIST \"{UANYNP1}*\"|\'{UANYNP2}*\'
CHAR \'({ASCN}|\\\\|\\\'|\\0)\'
HEX [[:xdigit:]]
NUMBER [[:digit:]]+
Expand Down

0 comments on commit c6f3cfb

Please sign in to comment.