aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/OpenDocument.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-06-25 15:36:30 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-06-25 15:36:30 +0200
commite7cd3cb4668b119b61eb69eed857b0254a614ad9 (patch)
tree79b8564cf255852055009c0f0b56dde6af8b33dc /src/Text/Pandoc/Writers/OpenDocument.hs
parent3ae4105d143dbec44afa713f6c3fa28f7a8c1d1f (diff)
downloadpandoc-e7cd3cb4668b119b61eb69eed857b0254a614ad9.tar.gz
Writers.Shared: refactored getLang, splitLang...
into `Lang(..)`, `getLang`, `parceBCP47`.
Diffstat (limited to 'src/Text/Pandoc/Writers/OpenDocument.hs')
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 3a720acdc..57f3c1194 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -36,7 +36,6 @@ import Control.Arrow ((***), (>>>))
import Control.Monad.State.Strict hiding (when)
import Data.Char (chr)
import Data.List (sortBy)
-import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Map as Map
import Data.Ord (comparing)
@@ -608,8 +607,14 @@ paraTableStyles t s (a:xs)
[ ("fo:text-align", x)
, ("style:justify-single-word", "false")]
-data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC | Pre
- | Lang String String
+data TextStyle = Italic
+ | Bold
+ | Strike
+ | Sub
+ | Sup
+ | SmallC
+ | Pre
+ | Language String String
deriving ( Eq,Ord )
textStyleAttr :: TextStyle -> [(String,String)]
@@ -627,7 +632,7 @@ textStyleAttr s
| Pre <- s = [("style:font-name" ,"Courier New")
,("style:font-name-asian" ,"Courier New")
,("style:font-name-complex" ,"Courier New")]
- | Lang lang country <- s
+ | Language lang country <- s
= [("fo:language" ,lang)
,("fo:country" ,country)]
| otherwise = []
@@ -637,9 +642,8 @@ withLangFromAttr (_,_,kvs) action =
case lookup "lang" kvs of
Nothing -> action
Just l -> do
- (mblang, mbcountry) <- splitLang l
- case (mblang, mbcountry) of
- (Just lang, _) -> withTextStyle
- (Lang lang (fromMaybe "" mbcountry))
- action
+ mblang <- parseBCP47 l
+ case mblang of
+ Just (Lang lang country) -> withTextStyle
+ (Language lang country) action
_ -> action