diff options
| -rw-r--r-- | main.c | 22 | 
1 files changed, 14 insertions, 8 deletions
@@ -283,7 +283,8 @@ void usage(const char *cmd) {  			" -s --standalone   prefix with html metadata\n"  			" -h --hvar         define a css variable (--name) with a random value,\n"  			"                   selected by a hash of the document's title\n" -			" -c --css          embed the given file within a <style> element\n", +			" -c --css          embed the given file within a <style> element\n" +			" -t --title        set the document title (does nothing without --standalone)\n",  			cmd, cmd);  } @@ -355,9 +356,10 @@ int main(int argc, const char **argv) {  	Str param = { 0 };  	opts.from_stdin = 1; -	while ((r = arg_get(&a, "?sc:h:", ¶m, +	while ((r = arg_get(&a, "?sc:h:t:", ¶m,  					"help", '?',  					"standalone", 's', +					":title", 't',  					":css", 'c',  					":hvar", 'h')) >= ARG_OK) {  		Arena reset = scratch; @@ -372,6 +374,9 @@ int main(int argc, const char **argv) {  		case 'c':  			opts.stylesheet = param;  			break; +		case 't': +			opts.title = param; +			break;  		case 'h':  			if (opts.hvarc == countof(opts.hvarv)) {  				fprintf(stderr, "too many hash variables!\n"); @@ -424,12 +429,13 @@ int main(int argc, const char **argv) {  		}  	} -	if (doc && opts.standalone) { -		opts.title = doc->title; -		while (doc->prev) { -			doc = doc->prev; -			if (doc->title.s) opts.title = doc->title; -		} +	if (doc && !opts.title.s) opts.title = doc->title; +	while (doc && doc->prev) { +		doc = doc->prev; +		if (doc->title.s && !opts.title.s) opts.title = doc->title; +	} + +	if (opts.standalone) {  		str_put(html_head(&opts, &perm, &scratch));  	}  | 
