Skip to content
Permalink
Browse files

Make formatting blogposts easier

  • Loading branch information...
frioux committed Jun 15, 2019
1 parent ebe1902 commit a197dbc92fab03ea7a7d466a761e746156db16a9
Showing with 41 additions and 0 deletions.
  1. +5 −0 bin/README.mdwn
  2. +34 −0 bin/markdownfmt
  3. +2 −0 vimrc
@@ -301,6 +301,11 @@ Downloads a few packages that import a given package.
Formats input with `fmt -w80` until it sees `-- `, and thus leaves signature
alone.

### `markdownfmt`

Formats input with `fmt -w80`, excluding lines wrapped with `---`, and thus
leaving yaml header alone.

### `mc`

Filter to make output monochrome.
@@ -0,0 +1,34 @@
#!/usr/bin/perl

use strict;
use warnings;

no warnings 'uninitialized';

my @lines = <STDIN>;

my $end = @lines-1;
my $body = 0;

my $nth = 0;
for my $i (0 .. $end) {
if ($lines[$i] eq "---\n") {
$nth++;
if ($nth == 2) {
$body = $i+1;
last;
}
}
}

for my $l (@lines[0..$body-1]) {
print $l
}

open my $fh, '|-', 'fmt', '-w80'
or die "Couldn't run fmt -w80: $!\n";

for my $l (@lines[$body..$end]) {
print $fh $l
}
close $fh;
2 vimrc
@@ -36,6 +36,8 @@ augroup vimrc
au FileType go setlocal formatprg=gofmt
au FileType mail setlocal formatprg=mailfmt

au FileType markdown setlocal formatprg=markdownfmt

au FileType sql setlocal commentstring=--\ %s
au FileType sml setlocal commentstring=(*\ %s\ *)
au FileType racket setlocal commentstring=;\ %s

0 comments on commit a197dbc

Please sign in to comment.
You can’t perform that action at this time.