aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-04-01 21:17:01 +0200
committerbptato <nincsnevem662@gmail.com>2025-04-01 21:24:04 +0200
commit84c3902e94c6f0e01fb122511ebdc762464ece93 (patch)
tree319aca9f15ed731fad96a73465825c5305cdc4d9
parent9e1098a649c80fa7a3ac8d492594bd76460ea46c (diff)
downloadchawan-84c3902e94c6f0e01fb122511ebdc762464ece93.tar.gz
config: fix semicolon handling in user-style import
ok so apparently you can leave out the semicolon, but *only* if the at rule is at EOF
-rw-r--r--doc/cha-config.54
-rw-r--r--doc/config.md4
-rw-r--r--src/config/config.nim8
3 files changed, 12 insertions, 4 deletions
diff --git a/doc/cha-config.5 b/doc/cha-config.5
index 202c51d9..101eaab8 100644
--- a/doc/cha-config.5
+++ b/doc/cha-config.5
@@ -268,7 +268,7 @@ T}@T{
T}@T{
A user stylesheet applied to all buffers.
External stylesheets can be imported using the
-\f[CR]\[at]import \[aq]file.css\[aq]\f[R] syntax.
+\f[CR]\[at]import \[aq]file.css\[aq];\f[R] syntax.
Paths are relative to the configuration directory.
Nested \[at]import is not supported yet.
T}@T{
@@ -1308,7 +1308,7 @@ Please use \f[CR]buffer.user\-style\f[R] instead.
.PP
(\f[CR]user\-style\f[R] accepts inline styles by default, but can also
include external stylesheets using
-\f[CR]\[at]import \[aq]file.css\[aq]\f[R].)
+\f[CR]\[at]import \[aq]file.css\[aq];\f[R].)
.SS Keybindings
Keybindings are to be placed in these sections:
.IP \[bu] 2
diff --git a/doc/config.md b/doc/config.md
index f7cb3d18..46d3a9ef 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -237,7 +237,7 @@ prints a list of URLs after the page.</td>
<td>string</td>
<td>""</td>
<td>A user stylesheet applied to all buffers.<br>
-External stylesheets can be imported using the `@import 'file.css'`
+External stylesheets can be imported using the `@import 'file.css';`
syntax. Paths are relative to the configuration directory.<br>
Nested @import is not supported yet.
</td>
@@ -1043,7 +1043,7 @@ The `[css]` section is deprecated, and will be removed in the future.
Please use `buffer.user-style` instead.
(`user-style` accepts inline styles by default, but can also include
-external stylesheets using `@import 'file.css'`.)
+external stylesheets using `@import 'file.css';`.)
## Keybindings
diff --git a/src/config/config.nim b/src/config/config.nim
index 6d07238e..073aea1a 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -805,6 +805,14 @@ proc parseConfigValue(ctx: var ConfigParser; x: var StyleString; v: TomlValue;
let tok = s.parseCSSString(ending, i)
if tok.t != cttString:
break
+ while s.nextCSSToken(i):
+ if s[i] in AsciiWhitespace or
+ i + 1 < s.len and s[i] == '\\' and s[i + 1] == '\n':
+ inc i
+ continue
+ break
+ if i < s.len and s[i] != ';':
+ break
let path = ChaPath(tok.value).unquote(ctx.config.dir)
if path.isNone:
return err(k & ": wrong CSS import (" & $tok.value &