Minification exclusion

This commit is contained in:
Nate Choe
2022-06-06 16:42:15 -05:00
parent 46a95c1330
commit 174e77a637
3 changed files with 25 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ Please not that ncdg minifies HTML so these examples aren't really correct.
## Usage
There are only 3 features in ncdg:
There are only 4 features in ncdg:
### Include statements
@@ -108,3 +108,19 @@ Result:
</code></pre>
Note that text inside of escaped sections are not minified.
### Excluding minification
```
%&
&
%
```
Result:
```
&
```
Used for legacy web pages on my site that I don't want to update

View File

@@ -3,5 +3,6 @@
#define VAR_CHAR '!'
#define SET_CHAR '='
#define AUTOESCAPE_CHAR '\\'
#define NOMINIFY_CHAR '&'
#define MAX_INCLUDE_DEPTH 10

View File

@@ -105,8 +105,7 @@ static int writefile(struct expandfile *file, FILE *out) {
}
case AUTOESCAPE_CHAR:
for (++i; data->data[i] != ESCAPE_CHAR &&
i < data->len;
++i) {
i < data->len; ++i) {
switch (data->data[i]) {
case '&':
fputs("&amp;", out);
@@ -125,6 +124,11 @@ static int writefile(struct expandfile *file, FILE *out) {
}
}
break;
case NOMINIFY_CHAR:
for (++i; data->data[i] != ESCAPE_CHAR &&
i < data->len; ++i)
fputc(data->data[i], out);
break;
}
}
else
@@ -161,7 +165,7 @@ static int expandfile(struct expandfile *ret, char *filename, int level) {
if (appendchar(ret->data, ESCAPE_CHAR))
goto error;
break;
case VAR_CHAR: case AUTOESCAPE_CHAR:
case VAR_CHAR: case AUTOESCAPE_CHAR: case NOMINIFY_CHAR:
if (appendchar(ret->data, ESCAPE_CHAR))
goto error;
for (;;) {