-
-
Save Mouq/82ebe2b9633c487d3795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/syngen.p6 b/syngen.p6 | |
index 73eb9e4..5eac406 100644 | |
--- a/syngen.p6 | |
+++ b/syngen.p6 | |
@@ -77,16 +77,20 @@ sub MAIN(:$backlinks = "", :$synopses!, :$outdir!, Bool :$debug = False, Bool :$ | |
for %blinks{~$/}.flat -> $blink { | |
DEBUG($blink.perl); | |
DEBUG($blink.section); | |
- # the use of 0x10FFFB .. 0x10FFFD is just to make sure we don't | |
- # accidentaly HTML-ify things that weren't meant to be | |
- # backlinks. If it turns out enough of an audience uses these, we | |
- # can use other PUA chars. | |
+ my $smartlink-pod = qq:to/POD/; | |
+ \n=begin pod :class<smartlink> | |
+ =begin pod :class<smartlink-file> | |
+ L<C<{$blink.linkfrom}>, line C<{$blink.atline}> | |
+ | https://github.com/perl6/roast/blob/master/{$blink.linkfrom}#L{$blink.atline}> | |
+ =end pod | |
+ =end pod | |
+ POD | |
if $curfile ~~ /^^ \h* \= head <digit> \h+ "$blink.section()"/ { | |
- $curfile.=subst(/\n\n/, "\n\n\x10FFFB{$blink.linkfrom}\x10FFFC{$blink.atline}\x10FFFD\n\n", :p($/.to)); | |
+ $curfile.=subst(/\n\n/, $smartlink-pod, :p($/.to)); | |
} elsif $curfile ~~ /^^ \h* \= begin \h+ pod/ { | |
- $curfile.=subst(/\n\n/, "\n\n\x10FFFB{$blink.linkfrom}\x10FFFC{$blink.atline}\x10FFFD\n\n", :p($/.to)); | |
+ $curfile.=subst(/\n\n/, $smartlink-pod, :p($/.to)); | |
} else { | |
- $curfile = "=for para\n\x10FFFB{$blink.linkfrom}\x10FFFC{$blink.atline}\x10FFFD\n\n" ~ $curfile; | |
+ $curfile = $smartlink-pod ~ $curfile; | |
} | |
$curout = open($_, :w); | |
@@ -123,45 +127,6 @@ sub MAIN(:$backlinks = "", :$synopses!, :$outdir!, Bool :$debug = False, Bool :$ | |
say DONE("HTML files generated."); | |
- #### FINAL MODIFICATIONS | |
- print DOING("Performing post-gen modifications..."); DEBUG(""); | |
- print "\e[s"; | |
- | |
- if $backlinks { | |
- my $didReplace; # save time by not rewriting unchanged files | |
- my $curfile; | |
- my $curout; | |
- | |
- $progress = 0; | |
- | |
- for @htmlfiles { | |
- $curfile = $_.IO.slurp; | |
- | |
- # there's no way to specify U+10FFFD in a negation of any kind, except as a literal char | |
- | |
- $didReplace = True if $curfile ~~ /"<p>"\x10FFFB(<-[]>+)\x10FFFC(<-[]>+)\x10FFFD"</p>"/; | |
- $curfile.=subst(/"<p>"\x10FFFB(<-[]>+)\x10FFFC(<-[]>+)\x10FFFD"</p>"/, {q:c:to/EOBL/}, :g); | |
- <div class="smartlink"> | |
- <p class="smartlink-file"> | |
- <a href="https://github.com/perl6/roast/blob/master/{$0}#L{$1}"><code>{$0}</code>, line <code>{$1}</code></a> | |
- </p> | |
- </div> | |
- EOBL | |
- | |
- if $didReplace { | |
- $curout = open($_, :w); | |
- $curout.say($curfile); | |
- $curout.close; | |
- $didReplace = False; | |
- } | |
- | |
- $progress++; | |
- print "\e[u\e[K", FRAC($progress, +@htmlfiles); | |
- } | |
- } | |
- | |
- say DONE("Post-gen modifications applied."); | |
- | |
#### CLEANUP | |
print DOING("Cleaning Up..."); DEBUG(""); | |
for @workfiles { | |
@@ -190,4 +155,4 @@ Options: | |
--debug Messy debug output. | |
EOHELP | |
exit; | |
-} | |
\ No newline at end of file | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment