aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Translations.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Translations.hs')
-rw-r--r--src/Text/Pandoc/Translations.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Translations.hs b/src/Text/Pandoc/Translations.hs
index af504a5e4..6d091bf92 100644
--- a/src/Text/Pandoc/Translations.hs
+++ b/src/Text/Pandoc/Translations.hs
@@ -76,7 +76,7 @@ instance FromJSON Term where
parseJSON invalid = Aeson.typeMismatch "Term" invalid
instance YAML.FromYAML Term where
- parseYAML (YAML.Scalar (YAML.SStr t)) =
+ parseYAML (YAML.Scalar _ (YAML.SStr t)) =
case safeRead (T.unpack t) of
Just t' -> pure t'
Nothing -> fail $ "Invalid Term name " ++
@@ -99,12 +99,12 @@ instance FromJSON Translations where
instance YAML.FromYAML Translations where
parseYAML = YAML.withMap "Translations" $
\tr -> Translations .M.fromList <$> mapM addItem (M.toList tr)
- where addItem (n@(YAML.Scalar (YAML.SStr k)), v) =
+ where addItem (n@(YAML.Scalar _ (YAML.SStr k)), v) =
case safeRead (T.unpack k) of
Nothing -> YAML.typeMismatch "Term" n
Just t ->
case v of
- (YAML.Scalar (YAML.SStr s)) ->
+ (YAML.Scalar _ (YAML.SStr s)) ->
return (t, T.unpack (T.strip s))
n' -> YAML.typeMismatch "String" n'
addItem (n, _) = YAML.typeMismatch "String" n
@@ -115,6 +115,8 @@ lookupTerm t (Translations tm) = M.lookup t tm
readTranslations :: String -> Either String Translations
readTranslations s =
case YAML.decodeStrict $ UTF8.fromString s of
- Left err' -> Left err'
- Right (t:_) -> Right t
- Right [] -> Left "empty YAML document"
+ Left (pos,err') -> Left $ err' ++
+ " (line " ++ show (YAML.posLine pos) ++ " column " ++
+ show (YAML.posColumn pos) ++ ")"
+ Right (t:_) -> Right t
+ Right [] -> Left "empty YAML document"