From 7a205bc6bd2380e0834d4156884055621e526fdc Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Thu, 29 Apr 2021 19:01:42 +0200 Subject: [PATCH] fix handling of punctuation --- laantas-script/Glyphs.hs | 8 ++++---- laantas-script/Split.hs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/laantas-script/Glyphs.hs b/laantas-script/Glyphs.hs index a3fa866..c6b202d 100644 --- a/laantas-script/Glyphs.hs +++ b/laantas-script/Glyphs.hs @@ -655,11 +655,11 @@ punctuation :: Map Text Glyph punctuation = Map.fromList [(".", eos), ("?", eos), ("!", eos), (",", eop), (":", eop), (";", eop)] -eos = G {path = eosPath, width = 2} -eosPath = P $ circA 1 (1,1) <> circA 1 (1,4) +eos = G {path = eosPath, width = 4} +eosPath = P $ circA 1 (4,1) <> circA 1 (4,4) -eop = G {path = eopPath, width = -2} -eopPath = P $ circA 1 (-1,2.5) +eop = G {path = eopPath, width = 2} +eopPath = P $ circA 1 (3,2.5) num = G {path = P [mA (0,0), lR (0,5), mA (1,0), lR (0,5)], width = 1} diff --git a/laantas-script/Split.hs b/laantas-script/Split.hs index 3429758..8a05280 100644 --- a/laantas-script/Split.hs +++ b/laantas-script/Split.hs @@ -1,13 +1,13 @@ module Split (split) where import Glyphs +import Text.Megaparsec +import Text.Megaparsec.Char import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Char as Char import Data.Map (Map, (!)) import qualified Data.Map.Strict as Map -import Text.Megaparsec -import Text.Megaparsec.Char import Data.Void @@ -39,7 +39,8 @@ ivowel :: P Glyph ivowel = maxFrom "vowel" vowels word :: P [Piece] -word = (<>) <$> some initMed <*> fin where +word = [is <> f <> concat p | is <- some initMed, f <- fin, p <- many punct] + where initMed = try $ [(i, [m]) | i <- initial, m <- medial] <|> [(v, []) | v <- ivowel] <|> @@ -52,7 +53,7 @@ number = some (digit <|> hash) where digit = [(numbers ! Char.digitToInt i, []) | i <- digitChar] punct :: P [Piece] -punct = [[(p, [])] | p <- maxFrom "punctuation" punctuation] +punct = [[(p, [])] | p <- maxFrom "punctuation" punctuation] <* space dash :: P Piece dash = (wave, []) <$ chunk "–"