Skip to content

Commit 9b87a74

Browse files
committed
Add stolen wrapping script
1 parent 6e50ed8 commit 9b87a74

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ jobs:
3636
out='generation/gh-pages/std-2023'
3737
mkdir -- "$out"
3838
39-
gcc -E cpp23/flowchart.dot.cpp | dot -Tsvg -start=1000 > "$out"/initialization.svg
40-
gcc -E cpp23/flowchart.dot.cpp | dot -Tpng -start=1000 > "$out"/initialization.png
39+
cpp23/build.sh "$out"/initialization.svg "$out"/initialization.png
4140
4241
- name: Deploy generated flowcharts to Github Pages
4342
if: github.ref == 'refs/heads/main'

cpp23/wrap.perl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env perl
2+
3+
# Based on https://biowize.wordpress.com/2011/03/11/text-wrapping-with-dot-graphviz/
4+
5+
use strict;
6+
7+
my $usage = "setdotlabelwidth [char-width] < [dotfile]";
8+
my $width = shift() or die("Usage: $usage $!");
9+
10+
while(<STDIN>)
11+
{
12+
if(m/label="((?:\\.|[^\\"])*)"/)
13+
{
14+
my $labeltext = $1;
15+
my @words = split(/ /, $labeltext);
16+
my @newtext = ();
17+
my $newline = "";
18+
foreach my $word(@words)
19+
{
20+
if( length($newline) > 0 and
21+
length($newline) + length($word) > $width )
22+
{
23+
push(@newtext, $newline);
24+
$newline = "";
25+
}
26+
$newline .= " " if( length($newline) > 0 );
27+
$newline .= $word;
28+
}
29+
push(@newtext, $newline) if( length($newline) > 0 );
30+
my $newlabel = join("\\n", @newtext);
31+
s/label="((?:\\.|[^\\"])*)"/label="$newlabel"/;
32+
}
33+
print;
34+
}

0 commit comments

Comments
 (0)