From ae36e5cd430a1f84d677fc51373e6af6e8e8e423 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Wed, 5 Jan 2022 07:41:37 +0100 Subject: [PATCH] new scripts --- bin/remove-eol.pl | 37 +++++++++++++++++++++++++++++++++++++ bin/roff2custom.sh | 18 ++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 bin/remove-eol.pl create mode 100755 bin/roff2custom.sh 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/" +}