📄 hstrip.cpp
字号:
// Created:11-14-98
// By Jeff Connelly
// HStrip - Reduces the size of HTML documents
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include <ctype.h>
bool iswhitespace(char c)
{
switch (c)
{
case 0x0A: // fall though
case 0x0D: // fall though
case ' ': // fall though
case 0x09: return true;
default: return false;
};
}
// Reduces the size of HTML page 'in' to 'out'
void ReduceHTML(FILE* in, FILE* out)
{
bool whitespace = false;
register char c;
while (!feof(in))
{
c = getc(in);
if (iswhitespace(c))
whitespace = true;
else
{
if (whitespace) // Whitespace was present
fputc(' ', out);
fputc(c, out);
whitespace = false;
}
}
}
const char* help = "Reduces the size of an HTML page\n"
"\tHSTRIP source dest\n"
"\n";
int main(int argc, char* argv[])
{
FILE* in;
FILE* out;
if (argc != 3)
{
printf(help);
exit (0);
}
in = fopen(argv[1], "rt");
out = fopen(argv[2], "wt");
if (!in || !out)
{
printf ("Cannot open files(s)\n");
exit (1);
}
printf ("Reducing size of %s...\n", argv[1]);
ReduceHTML(in, out);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -