Minification exclusion
This commit is contained in:
18
README.md
18
README.md
@@ -7,7 +7,7 @@ Please not that ncdg minifies HTML so these examples aren't really correct.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
There are only 3 features in ncdg:
|
There are only 4 features in ncdg:
|
||||||
|
|
||||||
### Include statements
|
### Include statements
|
||||||
|
|
||||||
@@ -108,3 +108,19 @@ Result:
|
|||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
Note that text inside of escaped sections are not minified.
|
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
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
#define VAR_CHAR '!'
|
#define VAR_CHAR '!'
|
||||||
#define SET_CHAR '='
|
#define SET_CHAR '='
|
||||||
#define AUTOESCAPE_CHAR '\\'
|
#define AUTOESCAPE_CHAR '\\'
|
||||||
|
#define NOMINIFY_CHAR '&'
|
||||||
|
|
||||||
#define MAX_INCLUDE_DEPTH 10
|
#define MAX_INCLUDE_DEPTH 10
|
||||||
|
|||||||
10
src/parse.c
10
src/parse.c
@@ -105,8 +105,7 @@ static int writefile(struct expandfile *file, FILE *out) {
|
|||||||
}
|
}
|
||||||
case AUTOESCAPE_CHAR:
|
case AUTOESCAPE_CHAR:
|
||||||
for (++i; data->data[i] != ESCAPE_CHAR &&
|
for (++i; data->data[i] != ESCAPE_CHAR &&
|
||||||
i < data->len;
|
i < data->len; ++i) {
|
||||||
++i) {
|
|
||||||
switch (data->data[i]) {
|
switch (data->data[i]) {
|
||||||
case '&':
|
case '&':
|
||||||
fputs("&", out);
|
fputs("&", out);
|
||||||
@@ -125,6 +124,11 @@ static int writefile(struct expandfile *file, FILE *out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NOMINIFY_CHAR:
|
||||||
|
for (++i; data->data[i] != ESCAPE_CHAR &&
|
||||||
|
i < data->len; ++i)
|
||||||
|
fputc(data->data[i], out);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -161,7 +165,7 @@ static int expandfile(struct expandfile *ret, char *filename, int level) {
|
|||||||
if (appendchar(ret->data, ESCAPE_CHAR))
|
if (appendchar(ret->data, ESCAPE_CHAR))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VAR_CHAR: case AUTOESCAPE_CHAR:
|
case VAR_CHAR: case AUTOESCAPE_CHAR: case NOMINIFY_CHAR:
|
||||||
if (appendchar(ret->data, ESCAPE_CHAR))
|
if (appendchar(ret->data, ESCAPE_CHAR))
|
||||||
goto error;
|
goto error;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|||||||
Reference in New Issue
Block a user