Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htmlfmt: add -I flag to suppress printing of image anchors. #594

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions man/man1/fmt.1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ fmt, htmlfmt \- simple text formatters
.B -c
.I charset
] [
.B -I
] [
.B -u
.I url
] [
Expand Down Expand Up @@ -75,6 +77,10 @@ change the default character set from iso-8859-1 to
This is the character set assumed if there isn't one
specified by the html itself in a <meta> directive.
.TP
.B -I
When displaying anchors, suppress the printing of
image anchors.
.TP
.BI -u " url
Use
.I url
Expand Down
1 change: 1 addition & 0 deletions src/cmd/htmlfmt/dat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct URLwin

extern char* url;
extern int aflag;
extern int Iflag;
extern int width;
extern int defcharset;

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/htmlfmt/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ render(URLwin *u, Bytes *t, Item *items, int curanchor)
renderbytes(t, "=======\n");
break;
case Iimagetag:
if(!aflag)
if(!aflag || Iflag)
break;
im = (Iimage*)il;
if(im->imsrc){
Expand Down
6 changes: 5 additions & 1 deletion src/cmd/htmlfmt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

char *url = "";
int aflag;
int Iflag;
int width = 70;
int defcharset;

void
usage(void)
{
fprint(2, "usage: htmlfmt [-c charset] [-u URL] [-a] [-l length] [file ...]\n");
fprint(2, "usage: htmlfmt [-c charset] [-u URL] [-aI] [-l length] [file ...]\n");
exits("usage");
}

Expand All @@ -33,6 +34,9 @@ main(int argc, char *argv[])
defcharset = charset(p);
free(p);
break;
case 'I':
Iflag++;
break;
case 'l': case 'w':
err = EARGF(usage());
width = atoi(err);
Expand Down