diff --git a/bin/remove-eol.pl b/bin/remove-eol.pl new file mode 100755 index 0000000..f98c2f3 --- /dev/null +++ b/bin/remove-eol.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +use v5.10; + +my @list_multiline_cmd = ( + qr/^\.SUBSECTION$/ + , qr/^\.SECTION_NO_NUMBER$/ + , qr/^\.SUBSUBSECTION$/ + , qr/^\.SUBSUBSUBSECTION$/ + , qr/^\.SECTION$/ + , qr/^\.BULLET$/ + ); + +my $STACK = ""; +my $found_pattern = 0; + +while (<>) { + chomp; + my $line = $_; + + $found_pattern = 0; + + for (@list_multiline_cmd) { + if ($line =~ $_) { + #say "line '$line' matched " . $_; + $found_pattern = 1; + $STACK = $line . ' '; + } + } + + if ($found_pattern == 1) { + next; + } + + say $STACK . $line; + $STACK = ""; +} diff --git a/bin/roff2custom.sh b/bin/roff2custom.sh new file mode 100755 index 0000000..65a02b2 --- /dev/null +++ b/bin/roff2custom.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# HOW TO USE + +# . ./$0 +# cat file | modernize_roff | remove-eol.pl > file.new + +modernize_roff() { + sed \ + -e "s/^\.PP/.PARAGRAPH_INDENTED/" \ + -e "s/^\.NH 1/.SECTION/" \ + -e "s/^\.NH 2/.SUBSECTION/" \ + -e "s/^\.NH 3/.SUBSUBSECTION/" \ + -e "s/^\.NH 4/.SUBSUBSUBSECTION/" \ + -e "s/^\.SH [1-4]/.SECTION_NO_NUMBER/" \ + -e "s/^\.SH$/.SECTION_NO_NUMBER/" \ + -e "s/^\.LP/.PARAGRAPH_UNINDENTED/" +}