@@ -46,6 +46,7 @@ import Data.Aeson (eitherDecode', encode)
4646import qualified Data.ByteString as BS
4747import qualified Data.ByteString.Lazy as B
4848import Data.Char (toLower, toUpper)
49+import qualified Data.Set as Set
4950import Data.Foldable (foldrM)
5051import Data.List (intercalate, isPrefixOf, isSuffixOf, sort)
5152import qualified Data.Map as M
@@ -279,6 +280,11 @@ convertWithOpts opts = do
279280 uriFragment = "" }
280281 _ -> Nothing
281282
283+ abbrevs <- case optAbbreviations opts of
284+ Nothing -> return $ readerAbbreviations def
285+ Just f -> (Set.fromList . filter (not . null) . lines)
286+ <$> UTF8.readFile f
287+
282288 let readerOpts = def{ readerStandalone = standalone
283289 , readerColumns = optColumns opts
284290 , readerTabStop = optTabStop opts
@@ -287,6 +293,7 @@ convertWithOpts opts = do
287293 , readerDefaultImageExtension =
288294 optDefaultImageExtension opts
289295 , readerTrackChanges = optTrackChanges opts
296+ , readerAbbreviations = abbrevs
290297 }
291298
292299 highlightStyle <- lookupHighlightStyle $ optHighlightStyle opts
@@ -489,6 +496,7 @@ data Opt = Opt
489496 , optHighlightStyle :: Maybe String -- ^ Style to use for highlighted code
490497 , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
491498 , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
499+ , optAbbreviations :: Maybe FilePath -- ^ Path to abbrevs file
492500 , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
493501 , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata
494502 , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed
@@ -554,6 +562,7 @@ defaultOpts = Opt
554562 , optHighlightStyle = Just "pygments"
555563 , optTopLevelDivision = TopLevelDefault
556564 , optHTMLMathMethod = PlainMath
565+ , optAbbreviations = Nothing
557566 , optReferenceDoc = Nothing
558567 , optEpubMetadata = Nothing
559568 , optEpubFonts = []
@@ -772,7 +781,7 @@ options =
772781 , Option "o" ["output"]
773782 (ReqArg
774783 (\arg opt -> return opt { optOutputFile = arg })
775− "FILENAME")
784+ "FILE")
776785 "" -- "Name of output file"
777786
778787 , Option "" ["data-dir"]
@@ -855,7 +864,7 @@ options =
855864 (\arg opt ->
856865 return opt{ optTemplate = Just arg,
857866 optStandalone = True })
858− "FILENAME")
867+ "FILE")
859868 "" -- "Use custom template"
860869
861870 , Option "M" ["metadata"]
@@ -954,7 +963,7 @@ options =
954963 (\arg opt -> return opt{ optIncludeInHeader =
955964 arg : optIncludeInHeader opt,
956965 optStandalone = True })
957− "FILENAME")
966+ "FILE")
958967 "" -- "File to include at end of header (implies -s)"
959968
960969 , Option "B" ["include-before-body"]
@@ -962,7 +971,7 @@ options =
962971 (\arg opt -> return opt{ optIncludeBeforeBody =
963972 arg : optIncludeBeforeBody opt,
964973 optStandalone = True })
965− "FILENAME")
974+ "FILE")
966975 "" -- "File to include before document body"
967976
968977 , Option "A" ["include-after-body"]
@@ -970,7 +979,7 @@ options =
970979 (\arg opt -> return opt{ optIncludeAfterBody =
971980 arg : optIncludeAfterBody opt,
972981 optStandalone = True })
973− "FILENAME")
982+ "FILE")
974983 "" -- "File to include after document body"
975984
976985 , Option "" ["self-contained"]
@@ -1110,7 +1119,7 @@ options =
11101119 (ReqArg
11111120 (\arg opt ->
11121121 return opt { optReferenceDoc = Just arg })
1113− "FILENAME")
1122+ "FILE")
11141123 "" -- "Path of custom reference doc"
11151124
11161125 , Option "" ["epub-cover-image"]
@@ -1118,13 +1127,13 @@ options =
11181127 (\arg opt ->
11191128 return opt { optVariables =
11201129 ("epub-cover-image", arg) : optVariables opt })
1121− "FILENAME")
1130+ "FILE")
11221131 "" -- "Path of epub cover image"
11231132
11241133 , Option "" ["epub-metadata"]
11251134 (ReqArg
11261135 (\arg opt -> return opt { optEpubMetadata = Just arg })
1127− "FILENAME")
1136+ "FILE")
11281137 "" -- "Path of epub metadata file"
11291138
11301139 , Option "" ["epub-embed-font"]
@@ -1261,6 +1270,12 @@ options =
12611270 (\opt -> return opt { optHTMLMathMethod = GladTeX }))
12621271 "" -- "Use gladtex for HTML math"
12631272
1273+ , Option "" ["abbreviations"]
1274+ (ReqArg
1275+ (\arg opt -> return opt { optAbbreviations = Just arg })
1276+ "FILE")
1277+ "" -- "Specify file for custom abbreviations"
1278+
12641279 , Option "" ["trace"]
12651280 (NoArg
12661281 (\opt -> return opt { optVerbosity = DEBUG }))