Skip to content

Commit

Permalink
man2html knows how to generate Markdown.
Browse files Browse the repository at this point in the history
Not completely, but enough for our manual pages.
  • Loading branch information
kohler committed Oct 18, 2017
1 parent 50d8cd7 commit 5c7d0c1
Show file tree
Hide file tree
Showing 2 changed files with 398 additions and 249 deletions.
29 changes: 26 additions & 3 deletions doc/click-elem2man
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ my(%markdown_podentities) =
'verbar' => '|', 'eq' => '=', 'star' => '*', 'lparen' => '(',
'rparen' => ')', 'lbrack' => '[', 'rbrack' => ']', 'lbrace' => '{',
'rbrace' => '}' );
my($markdown_sensitive_char) = "[&\\[\\]#*_~&`]";
my($markdown_sensitive_char) = "[&\\[\\]#*_~`]";
my($markdown_was_short_item) = 0;

sub markdown_unentity ($) {
Expand Down Expand Up @@ -750,6 +750,9 @@ sub markdownize_text ($$) {
# remove self references
$t =~ s{\[$PrimaryElement\]\($PrimaryElement\)}{$PrimaryElement}g;

# quote colons that look like emoji escapes
$t =~ s{:(?=[-+_a-z0-9]+:)}{\\:}ig;

$t;
}

Expand Down Expand Up @@ -1157,8 +1160,7 @@ sub process_comment ($$$) {
print STDERR "Uninstalled $main_outname\n" if $verbose;
unlink($main_outname);
open(OUT, ">/dev/null");
} elsif ($gzip ? open(OUT, "|gzip -9 >$main_outname")
: open(OUT, ">$main_outname")) {
} elsif ($gzip ? open(OUT, "|-", "gzip -9 >'$main_outname~'") : open(OUT, ">", $main_outname . "~")) {
print STDERR "Writing to $main_outname\n" if $verbose;
} else {
print STDERR "$main_outname: $!\n";
Expand Down Expand Up @@ -1309,6 +1311,27 @@ sub process_comment ($$$) {
# close output file & make links if appropriate
if ($filename_func) {
close OUT;

if ($gzip ? open(INX, "-|", "gzcat", $main_outname) : open(INX, "<", $main_outname)) {
$gzip ? open(OUTX, "-|", "gzcat", $main_outname . "~") : open(OUTX, "<", $main_outname . "~");
local($/) = undef;
my($in) = <INX>;
my($out) = <OUTX>;
close INX;
close OUTX;
if (defined($in) && defined($out) && $in ne "" && $out ne "") {
$in =~ s{\nGenerated by click-elem2man[^\n]*\n+\z}{};
$out =~ s{\nGenerated by click-elem2man[^\n]*\n+\z}{};
if ($in eq $out) {
unlink($main_outname . "~");
print STDERR "No changes to $main_outname\n" if $verbose;
return;
}
}
}

rename("$main_outname~", $main_outname);

for ($i = 1; $i < @outfiles; $i++) {
my($outname) = &$filename_func($outfiles[$i], $outsections[$i], 0);
print STDERR "Unlinking $outname\n" if $verbose;
Expand Down
Loading

0 comments on commit 5c7d0c1

Please sign in to comment.