fix handling of punctuation

This commit is contained in:
Rhiannon Morris 2021-04-29 19:01:42 +02:00
parent 5583865e27
commit 7a205bc6bd
2 changed files with 9 additions and 8 deletions

View file

@ -655,11 +655,11 @@ punctuation :: Map Text Glyph
punctuation = Map.fromList punctuation = Map.fromList
[(".", eos), ("?", eos), ("!", eos), (",", eop), (":", eop), (";", eop)] [(".", eos), ("?", eos), ("!", eos), (",", eop), (":", eop), (";", eop)]
eos = G {path = eosPath, width = 2} eos = G {path = eosPath, width = 4}
eosPath = P $ circA 1 (1,1) <> circA 1 (1,4) eosPath = P $ circA 1 (4,1) <> circA 1 (4,4)
eop = G {path = eopPath, width = -2} eop = G {path = eopPath, width = 2}
eopPath = P $ circA 1 (-1,2.5) 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} num = G {path = P [mA (0,0), lR (0,5), mA (1,0), lR (0,5)], width = 1}

View file

@ -1,13 +1,13 @@
module Split (split) where module Split (split) where
import Glyphs import Glyphs
import Text.Megaparsec
import Text.Megaparsec.Char
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text import qualified Data.Text as Text
import qualified Data.Char as Char import qualified Data.Char as Char
import Data.Map (Map, (!)) import Data.Map (Map, (!))
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Text.Megaparsec
import Text.Megaparsec.Char
import Data.Void import Data.Void
@ -39,7 +39,8 @@ ivowel :: P Glyph
ivowel = maxFrom "vowel" vowels ivowel = maxFrom "vowel" vowels
word :: P [Piece] word :: P [Piece]
word = (<>) <$> some initMed <*> fin where word = [is <> f <> concat p | is <- some initMed, f <- fin, p <- many punct]
where
initMed = try $ initMed = try $
[(i, [m]) | i <- initial, m <- medial] <|> [(i, [m]) | i <- initial, m <- medial] <|>
[(v, []) | v <- ivowel] <|> [(v, []) | v <- ivowel] <|>
@ -52,7 +53,7 @@ number = some (digit <|> hash) where
digit = [(numbers ! Char.digitToInt i, []) | i <- digitChar] digit = [(numbers ! Char.digitToInt i, []) | i <- digitChar]
punct :: P [Piece] punct :: P [Piece]
punct = [[(p, [])] | p <- maxFrom "punctuation" punctuation] punct = [[(p, [])] | p <- maxFrom "punctuation" punctuation] <* space
dash :: P Piece dash :: P Piece
dash = (wave, []) <$ chunk "" dash = (wave, []) <$ chunk ""