| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Text.Seonbi.Html.Lang
Synopsis
- data LangHtmlEntity = LangHtmlEntity {
- lang :: Maybe LanguageTag
- entity :: HtmlEntity
- type LanguageTag = Text
- annotateWithLang :: [HtmlEntity] -> [LangHtmlEntity]
- extractLang :: HtmlRawAttrs -> Maybe LanguageTag
- isKorean :: LanguageTag -> Bool
- isNeverKorean :: Maybe LanguageTag -> Bool
Documentation
data LangHtmlEntity Source #
Annotates HtmlEntity with the lang tag extracted from it or its
ancestors.
Constructors
| LangHtmlEntity | |
Fields
| |
Instances
| Show LangHtmlEntity Source # | |
Defined in Text.Seonbi.Html.Lang Methods showsPrec :: Int -> LangHtmlEntity -> ShowS # show :: LangHtmlEntity -> String # showList :: [LangHtmlEntity] -> ShowS # | |
| Eq LangHtmlEntity Source # | |
Defined in Text.Seonbi.Html.Lang Methods (==) :: LangHtmlEntity -> LangHtmlEntity -> Bool # (/=) :: LangHtmlEntity -> LangHtmlEntity -> Bool # | |
type LanguageTag = Text Source #
Represents a language tag. Although it is defined as an alias for Text,
it can be structured in the future. Do not use its contents directly.
annotateWithLang :: [HtmlEntity] -> [LangHtmlEntity] Source #
Annotates the given HTML entities with the language tag extracted from
their lang attributes. If a parent entity has lang attribute, its
all descendants are annotated with the same language tag.
Arguments
| :: HtmlRawAttrs | A raw HTML attributes to extract the language tag from. |
| -> Maybe LanguageTag | A language tag extracted from the given raw HTML attributes.
If the given raw HTML attributes does not have |
Extracts the language tag from the given raw HTML attributes if it has
lang attribute.
>>>extractLang ""Nothing>>>extractLang "lang=en"Just "en">>>extractLang "lang=\"ko-KR\""Just "ko-kr">>>extractLang " lang='ko-Hang'"Just "ko-hang"
isKorean :: LanguageTag -> Bool Source #
Determines whether the given language tag refers to any kind of Korean.
>>>isKorean "ko"True>>>isKorean "ko-KR"True>>>isKorean "kor-Hang"True>>>isKorean "en"False>>>isKorean "en-KR"False
isNeverKorean :: Maybe LanguageTag -> Bool Source #
Determines whether the given language tag undoubtedly does not refer to any kind of Korean.
>>>isNeverKorean $ Just "ko"False>>>isNeverKorean $ Just "ko-KR"False>>>isNeverKorean NothingFalse>>>isNeverKorean $ Just "en"True