Skip to content

Commit

Permalink
Remove language.dtd from DOCTYPE in parseSyntaxDefinitionFromString.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Feb 27, 2019
1 parent a7d4fe8 commit e51dcea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion skylighting-core/src/Skylighting/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,21 @@ parseSyntaxDefinitionFromString fp xml = do
_:':':'\\':_ -> "file:///" ++ map
(\c -> if c == '\\' then '/' else c) fp
_ -> fp
res <- runX (readString [withValidate no, withInputEncoding utf8] xml
res <- runX ( readString [withValidate no, withInputEncoding utf8]
(removeLanguageDTD xml)
>>>
application fp')
case res of
[s] -> return $ Right s
_ -> return $ Left $ "Could not parse syntax definition " ++ fp

removeLanguageDTD :: String -> String
removeLanguageDTD ('S':'Y':'S':'T':'E':'M':' ':xs) =
removeLanguageDTD $ dropWhile (\c -> c /= '[' && c /= '>') xs
removeLanguageDTD xs@('<':'l':'a':'n':'g':_) = xs
removeLanguageDTD (x:xs) = x : removeLanguageDTD xs
removeLanguageDTD [] = []

application :: FilePath -> IOSArrow XmlTree Syntax
application fp
= multi (hasName "language")
Expand Down

0 comments on commit e51dcea

Please sign in to comment.