| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Ltml.HTML.Common
Synopsis
- type HtmlReaderState = ReaderStateMonad (Delayed (Html ()))
- type ReaderStateMonad a = ReaderT ReaderState (State GlobalState) a
- runReaderState :: ReaderStateMonad a -> ReaderState -> GlobalState -> (a, GlobalState)
- data GlobalState = GlobalState {
- hasFlagged :: Bool
- currentSuperSectionID :: Int
- currentSectionID :: Int
- currentInsertedSectionID :: Int
- currentParagraphID :: Int
- currentSentenceID :: Int
- currentEnumItemID :: Int
- currentFootnoteID :: Int
- usedFootnoteMap :: FootnoteMap
- locallyUsedFootnotes :: FootnoteSet
- labels :: [(Label, Html ())]
- tableOfContents :: ToC
- mangledLabelName :: Text
- mangledLabelID :: Int
- enumStyles :: EnumStyleMap
- mangledEnumCounterName :: Text
- mangledEnumCounterID :: Int
- exportSections :: [(Text, Delayed Text, Delayed (Html ()))]
- documentFallbackTitle :: Fallback NavTocHeading
- mainDocumentTitleHtml :: Delayed (Html ())
- mainDocumentTitle :: Delayed Text
- hasErrors :: Bool
- data ReaderState = ReaderState {
- shouldRender :: Bool
- hasGlobalToC :: Bool
- appendixHasGlobalToC :: Bool
- currentAppendixElementID :: Int
- appendixElementIdFormat :: IdentifierFormat
- appendixElementTocKeyFormat :: TocKeyFormat
- appendixElementMLabel :: Maybe Label
- documentHeadingFormat :: Either (HeadingFormat 'False) (HeadingFormat 'True)
- localSectionFormat :: SectionFormat
- isSingleParagraph :: Bool
- currentEnumIDFormatString :: IdentifierFormat
- footnoteMap :: Map Label Footnote
- labelWrapperFunc :: LabelWrapper
- footnoteWrapperFunc :: LabelWrapper
- tocEntryWrapperFunc :: TocEntryWrapper
- tocButtonWrapperFunc :: TocEntryWrapper
- exportLinkWrapper :: LabelWrapper
- initGlobalState :: GlobalState
- initReaderState :: ReaderState
- incSectionID :: ReaderT r (State GlobalState) ()
- incInsertedSectionID :: ReaderT r (State GlobalState) ()
- resetInsertedSectionID :: ReaderT r (State GlobalState) ()
- incSuperSectionID :: ReaderT r (State GlobalState) ()
- type FootnoteMap = [(Label, (Int, Html (), Delayed (Html ())))]
- convertLabelMap :: FootnoteMap -> [(Label, Html ())]
- addUsedFootnotes :: GlobalState -> GlobalState -> GlobalState
- type FootnoteSet = Set NumLabel
- newtype NumLabel = NumLabel {
- unNumLabel :: (Int, Label)
- type ToC = DList (Either PhantomTocEntry TocEntry)
- type TocEntry = (Maybe (Html ()), Result (Delayed (Html ())), Text, TocCategory)
- data TocCategory
- = SomeSection
- | Other
- addTocEntry :: Maybe (Html ()) -> Result (Delayed (Html ())) -> Maybe Label -> TocCategory -> ReaderStateMonad Text
- addPhantomTocEntry :: Result (Html ()) -> ReaderStateMonad ()
- type PhantomTocEntry = (Maybe (Html ()), Result (Html ()))
- type RenderedTocEntry = (Maybe ByteString, Result ByteString)
- data Result a
- result :: (a -> b) -> (a -> b) -> Result a -> b
- type EnumStyleMap = [(EnumFormat, Text)]
- type LabelWrapper = Label -> Html () -> Html ()
- type TocEntryWrapper = TocCategory -> LabelWrapper
- anchorLink :: LabelWrapper
- pageLink :: FilePath -> TocEntryWrapper
- mainPageAnchorLink :: FilePath -> LabelWrapper
- collectExportSection :: Text -> Delayed Text -> Delayed (Html ()) -> ReaderStateMonad ()
- exportLink :: FilePath -> LabelWrapper
- setHasErrors :: ReaderStateMonad ()
- data Delayed a
- = Now a
- | Later (GlobalState -> a)
- evalDelayed :: GlobalState -> Delayed a -> a
- returnNow :: a -> ReaderStateMonad (Delayed a)
Custom State Monad
type HtmlReaderState = ReaderStateMonad (Delayed (Html ())) Source #
The Reader Monad is used for local tracking (e.g. enumNestingLevel). The State Monad is used for global tracking (e.g. sectionIDs). The Delayed type is used for delaying the actual lookup of references in the GlobalState. This allows forward references, because at first a delayed object is build, which is then evaluated aterwards with the final GlobalState.
type ReaderStateMonad a = ReaderT ReaderState (State GlobalState) a Source #
runReaderState :: ReaderStateMonad a -> ReaderState -> GlobalState -> (a, GlobalState) Source #
data GlobalState Source #
Constructors
| GlobalState | |
Fields
| |
data ReaderState Source #
Constructors
| ReaderState | |
Fields
| |
SectionID Functions
incSectionID :: ReaderT r (State GlobalState) () Source #
Increments currentSectionID in GlobalState
incInsertedSectionID :: ReaderT r (State GlobalState) () Source #
Increments currentInsertedSectionID in GlobalState
resetInsertedSectionID :: ReaderT r (State GlobalState) () Source #
Reset currentInsertedSectionID to initial value
incSuperSectionID :: ReaderT r (State GlobalState) () Source #
Increments currentSuperSectionID in GlobalState
Footnotes
type FootnoteMap = [(Label, (Int, Html (), Delayed (Html ())))] Source #
Maps Label to (ID, Text) as int and (delayed) html
convertLabelMap :: FootnoteMap -> [(Label, Html ())] Source #
Converts FootnoteMap to Label Map used for "normal" references
Arguments
| :: GlobalState | Base State |
| -> GlobalState | Add State |
| -> GlobalState |
Adds used footnotes of base state to add state (appends at the front)
type FootnoteSet = Set NumLabel Source #
Set of footnote labels with their respective footnote id
Used for sorted insertion into the set of footnotes; The Labels must be sorted by their footnote id
Constructors
| NumLabel | |
Fields
| |
Table of Contents
type ToC = DList (Either PhantomTocEntry TocEntry) Source #
The ToC uses a difference list to get constant time appending at the end, which has no speed draw backs, since the list is evaluated only ones when building the ToC Html at the end of rendering.
data TocCategory Source #
Constructors
| SomeSection | |
| Other |
addTocEntry :: Maybe (Html ()) -> Result (Delayed (Html ())) -> Maybe Label -> TocCategory -> ReaderStateMonad Text Source #
Add entry to table of contents with: key Html (e.g. § 1), title Html and html anchor link id; If Label is present uses it as the anchor link id, otherwise it creates a new mangled label name; the used label name is returned;
addPhantomTocEntry :: Result (Html ()) -> ReaderStateMonad () Source #
Adds a phantom entry into the table of contents, which is ignored when rendering.
Its only purpose is to tell the frontend if a parse error occured in this segment.
This is only meant to be used for segments that do not have a normal Toc entry,
like SimpleSections.
type PhantomTocEntry = (Maybe (Html ()), Result (Html ())) Source #
Toc Entry that only exists to send info to the Frontend; It is ignored when rendering a ToC
type RenderedTocEntry = (Maybe ByteString, Result ByteString) Source #
Type of exported ToC Entries (especially for Frontend);
Result signals if the generated title was parsed successfully or not
Instances
result :: (a -> b) -> (a -> b) -> Result a -> b Source #
Takes a Result a, a success function and an error function.
Applies one of the two functions depending on the Result constructor.
Enum Styles
type EnumStyleMap = [(EnumFormat, Text)] Source #
Maps EnumFormat to css class name which implements the counter: Is used for reusing already existing classes, if the same EnumFormat occurs again
Labels
type LabelWrapper = Label -> Html () -> Html () Source #
Type of function thats used to wrap Label information around Html; e.g. for adding anchor links
type TocEntryWrapper = TocCategory -> LabelWrapper Source #
anchorLink :: LabelWrapper Source #
Converts Label into href = "#<label"> for jumping to a HTML id
Arguments
| :: FilePath | Path prefix |
| -> TocEntryWrapper |
Converts Label into href = "<path/label.html"> for jumping
to another page
mainPageAnchorLink :: FilePath -> LabelWrapper Source #
Converts Label into href = "<path#label"> for jumping
to another pages anchor
collectExportSection :: Text -> Delayed Text -> Delayed (Html ()) -> ReaderStateMonad () Source #
Adds a Section with htmlId and HTML title to GlobalState
exportLink :: FilePath -> LabelWrapper Source #
Builds a link with labelPath, prefix "Zur Einzelansicht"
and adds some vertical spacing
setHasErrors :: ReaderStateMonad () Source #
Sets the hasErrors flag to True
Delayed data type
Constructors
| Now a | |
| Later (GlobalState -> a) |
evalDelayed :: GlobalState -> Delayed a -> a Source #
returnNow :: a -> ReaderStateMonad (Delayed a) Source #