Aníbal Monsalve Salazar wrote: > To possibly avoid printing problems, convert the .txt files to utf-8 by > running the commands below. > > iconv -f iso-8859-1 -t utf-8 < ksp-dc14.txt > ksp-dc14.utf8.txt > iconv -f iso-8859-1 -t utf-8 < ksp-dc14.condensed.txt > ksp-dc14.condensed.utf8.txt > > I used libreoffice with ksp-dc14.condensed.txt as input to create a four > pages landscape document with two columns. Maybe you could do something > similar with other tools. > > If you have other ideas, post them to the list. Here's a program that will generate a html file with a form containing a bunch of checkboxes, formatted so they fit all on one screen on my tablet. runhaskell convert.hs < ksp-dc14.utf8.txt > ksp-dc14.html (html improvements appreciated) (saving consists of generating a url, which I have not bothered to write a consumer for yet) -- see shy jo
import Text.Parsec
import Text.Parsec.String
import Data.Either
import Data.List
import Control.Applicative hiding (many, (<|>))
numcols :: Int
numcols = 12
main :: IO ()
main = interact $ either (error . show) format . parse keys "input"
data Key = Key
	{ knum :: Int
	, kname :: String
	, kdetails :: [String]
	}
keys :: Parser [Key]
keys = do
	ls <- instructionlines
	many $ Key <$> getnum <*> getname <*> getdetails
instructionlines :: Parser [String]
instructionlines = restOfLine `manyTill` try (string "\n\n\n")
restOfLine :: Parser String
restOfLine = anyChar `manyTill` try newline
getnum :: Parser Int
getnum = read <$> between (char '#') (many1 space) (many1 digit)
getname :: Parser String
getname = manyTill anyChar
	(try (void (string "(rank:" >> restOfLine) <|> void newline))
getdetails :: Parser [String]
getdetails = restOfLine `manyTill` try (void (string "\n\n") <|> eof)
void :: Parser a -> Parser ()
void p = p >> return ()
format :: [Key] -> String
format l = unlines $ concat
	[ header
	, intercalate chunksep (map (map formatkey) (segment l))
	, footer
	]
  where
	header= [ "<html>"
		, "SHA256 Checksum: _"
		, "<form method=get action=http://localhost/saveme>"
		, "<table>"
		, "<tr>"
		]
	footer = 
		[ "</tr>"
		, "</table>"
		, "<input type=submit value=Save>"
		, "</form>"
		, "</html>"
		]
	chunksep = ["</tr>", "<tr>"]
	formatkey k = concat
		[ "<td>"
		, '#' : show (knum k)
		, "<label><input type=checkbox name=" ++ show (knum k) ++ ">"
		, kname k
		-- TODO: allow expanding to see kdetails k
		, "</input></label></td>"
		]
	
	segment [] = []
	segment l = 
		let (chunk, rest) = splitAt numcols l
		in chunk : segment rest
Attachment:
signature.asc
Description: Digital signature