seonbi-0.4.0: SmartyPants for Korean language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Seonbi.Html.Lang

Synopsis

Documentation

data LangHtmlEntity Source #

Annotates HtmlEntity with the lang tag extracted from it or its ancestors.

Constructors

LangHtmlEntity 

Fields

Instances

Instances details
Show LangHtmlEntity Source # 
Instance details

Defined in Text.Seonbi.Html.Lang

Eq LangHtmlEntity Source # 
Instance details

Defined in Text.Seonbi.Html.Lang

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.

extractLang Source #

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 lang attribute or its value is invalid, Nothing is returned.

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 Nothing
False
>>> isNeverKorean $ Just "en"
True