lib: Write.Ods.escape: escape cell contents

This commit is contained in:
Henning Thielemann 2024-07-27 23:51:02 +02:00
parent ba0db5feec
commit 2a1f3920c6

View File

@ -213,6 +213,18 @@ formatCell cell =
in
printf "<table:table-cell%s %s>" style valueType :
printf "<text:p>%s</text:p>" (cellContent cell) :
printf "<text:p>%s</text:p>" (escape $ T.unpack $ cellContent cell) :
"</table:table-cell>" :
[]
escape :: String -> String
escape =
concatMap $ \c ->
case c of
'\n' -> "&#10;"
'&' -> "&amp;"
'<' -> "&lt;"
'>' -> "&gt;"
'"' -> "&quot;"
'\'' -> "&apos;"
_ -> [c]