@@ -21,40 +21,40 @@ import Web.DOM.Node (textContent)
2121
2222foreign import data DOMParser ∷ Type
2323
24- -- | Create a new `DOMParser`
24+ -- | Create a new `DOMParser`
2525foreign import makeDOMParser ∷ Effect DOMParser
2626
27- -- | Parse a string with the first argumet being a string for a doctype.
28- -- | Does not capture errors; consider using other wrapper functions,
29- -- | e.g. `parseXMLFromString`.
27+ -- | Parse a string with the first argumet being a string for a doctype.
28+ -- | Does not capture errors; consider using other wrapper functions,
29+ -- | e.g. `parseXMLFromString`.
3030foreign import parseFromString ∷ String -> String -> DOMParser -> Effect Document
3131
32- -- | Convience function to parse HTML from a string, partially applying
33- -- | `parseFromString` with "text/html"
32+ -- | Convience function to parse HTML from a string, partially applying
33+ -- | `parseFromString` with "text/html"
3434parseHTMLFromString ∷ String -> DOMParser -> Effect (Either String Document )
3535parseHTMLFromString s d = do
3636 doc <- parseFromString " text/html" s d
3737 errMay <- _getParserError doc
3838 pure $ returnIfNothing errMay doc
3939
40- -- | Convience function to parse SVG from a string, partially applying
41- -- | `parseFromString` with "image/svg+xml"
40+ -- | Convience function to parse SVG from a string, partially applying
41+ -- | `parseFromString` with "image/svg+xml"
4242parseSVGFromString ∷ String -> DOMParser -> Effect (Either String Document )
4343parseSVGFromString s d = do
4444 doc <- parseFromString " image/svg+xml" s d
4545 errMay <- _getParserError doc
4646 pure $ returnIfNothing errMay doc
4747
48- -- | Convience function to parse XML from a string, partially applying
49- -- | `parseFromString` with "application/xml"
48+ -- | Convience function to parse XML from a string, partially applying
49+ -- | `parseFromString` with "application/xml"
5050parseXMLFromString ∷ String -> DOMParser -> Effect (Either String Document )
5151parseXMLFromString s d = do
5252 doc <- parseFromString " application/xml" s d
5353 errMay <- _getParserError doc
5454 pure $ returnIfNothing errMay doc
5555
56- -- | Utility method for extracting Dom Parser errors from document;
57- -- | should only need to be used if calling `parseFromString` directly.
56+ -- | Utility method for extracting Dom Parser errors from document;
57+ -- | should only need to be used if calling `parseFromString` directly.
5858_getParserError :: Document -> Effect (Maybe String )
5959_getParserError doc = do
6060 peElems :: Array Element <- join $ map toArray $ getElementsByTagName " parsererror" doc
@@ -66,9 +66,9 @@ _getParserError doc = do
6666 Nothing -> pure $ Nothing
6767 Just nd -> map Just $ textContent nd
6868
69- -- | Like [Data.Either.note](https://pursuit.purescript.org/packages/purescript-either/docs/Data.Either#v:note),
70- -- | but with the logic reversed. Used internally for converting the
71- -- | result of `_getParserError` to an `Either`.
69+ -- | Like [Data.Either.note](https://pursuit.purescript.org/packages/purescript-either/docs/Data.Either#v:note),
70+ -- | but with the logic reversed. Used internally for converting the
71+ -- | result of `_getParserError` to an `Either`.
7272returnIfNothing :: forall a b . Maybe a -> b -> Either a b
7373returnIfNothing errMay val = case errMay of
7474 Nothing -> Right val
0 commit comments