Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data WikiLink
- data WikiLinkType
- mkWikiLinkFromSlugs :: NonEmpty Slug -> WikiLink
- mkWikiLinkFromInline :: Inline -> Maybe (WikiLink, [Inline])
- delineateLink :: [(Text, Text)] -> Text -> Maybe (Either (WikiLinkType, WikiLink) FilePath, Maybe Anchor)
- allowedWikiLinks :: HasCallStack => NonEmpty Slug -> NonEmpty (WikiLinkType, WikiLink)
- wikilinkInline :: WikiLinkType -> WikiLink -> Inlines -> Inlines
- wikiLinkInlineRendered :: Inline -> Maybe Text
- wikilinkSpec :: (Monad m, IsInline il, HasWikiLink il) => SyntaxSpec m il bl
- data Anchor
- anchorSuffix :: Maybe Anchor -> Text
- plainify :: [Inline] -> Text
Types
Represents the Foo in [[Foo]]
As wiki links may contain multiple path components, it can represent [[Foo/Bar]], hence we use nonempty slug list.
Instances
ToJSON WikiLink Source # | |
Defined in Commonmark.Extensions.WikiLink | |
Data WikiLink Source # | |
Defined in Commonmark.Extensions.WikiLink gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WikiLink -> c WikiLink # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WikiLink # toConstr :: WikiLink -> Constr # dataTypeOf :: WikiLink -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WikiLink) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WikiLink) # gmapT :: (forall b. Data b => b -> b) -> WikiLink -> WikiLink # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WikiLink -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WikiLink -> r # gmapQ :: (forall d. Data d => d -> u) -> WikiLink -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> WikiLink -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> WikiLink -> m WikiLink # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WikiLink -> m WikiLink # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WikiLink -> m WikiLink # | |
Show WikiLink Source # | |
Eq WikiLink Source # | |
Ord WikiLink Source # | |
Defined in Commonmark.Extensions.WikiLink |
data WikiLinkType Source #
A # prefix or suffix allows semantically distinct wikilinks
Typically called branching link or a tag link, when used with #.
WikiLinkNormal |
|
WikiLinkBranch |
|
WikiLinkTag | #[[Foo]] |
WikiLinkEmbed | ![[Foo]] |
Instances
Parsing wikilinks
delineateLink :: [(Text, Text)] -> Text -> Maybe (Either (WikiLinkType, WikiLink) FilePath, Maybe Anchor) Source #
Given a Pandoc Link node, apparaise what kind of link it is.
- Nothing, if the link is an absolute URL
- Just (Left wl), if a wiki-link
- Just (Right fp), if a relative path (not a wiki-link)
Wikilink candidates
allowedWikiLinks :: HasCallStack => NonEmpty Slug -> NonEmpty (WikiLinkType, WikiLink) Source #
Return the various ways to link to a route (ignoring ext)
FooBarQux.md -> [[Qux]], [[BarQux]], [[FooBar/Qux]]
All possible combinations of Wikilink type use is automatically included.
Converting wikilinks
wikilinkInline :: WikiLinkType -> WikiLink -> Inlines -> Inlines Source #
Commonmark parser spec
wikilinkSpec :: (Monad m, IsInline il, HasWikiLink il) => SyntaxSpec m il bl Source #
Like wikilinkSpec
but Zettelkasten-friendly.
Compared with the official extension, this has two differences:
- Supports flipped inner text, eg: `[[Foo | some inner text]]`
- Supports neuron folgezettel, i.e.: #[[Foo]] or [[Foo]]#