data WikiElement
- = Block !BlockElement
+ = Block !BlockElement
| Inline !InlineElement
deriving (Eq, Show)
import Control.Arrow
import Control.Arrow.ArrowList
+import Data.Char
import Data.List
import Data.Maybe
import Network.URI
formatPageLink
= proc (baseURI, PageLink page fragment text)
-> let uri = case (page, fragment) of
- (Just x, Just y) -> mkPageFragmentURI baseURI x y
- (Just x, Nothing) -> mkPageURI baseURI x
+ (Just x, Just y) -> mkPageFragmentURI baseURI (fix x) y
+ (Just x, Nothing) -> mkPageURI baseURI (fix x)
(Nothing, Just y) -> nullURI { uriFragment = ('#':y) }
+ fix = (\ (x:xs) -> toUpper x : xs) . map (\ c -> if c == ' ' then '_' else c)
href = uriToString id uri ""
dLabel = fromMaybe "" page ++ fromMaybe "" (fmap ('#':) fragment)
label = fromMaybe dLabel text
)
where
-import Data.Char
import Rakka.Wiki
import Text.ParserCombinators.Parsec
pageLink :: Parser InlineElement
pageLink = do string "[["
- page <- option Nothing $
- do x <- satisfy (\ c -> not (elem c "#|]" || isLower c))
- xs <- many (noneOf "#|]")
- return $ Just (x:xs)
+ page <- option Nothing
+ (many1 (noneOf "#|]") >>= return . Just)
fragment <- option Nothing
(char '#' >> many1 (noneOf "|]") >>= return . Just)
text <- option Nothing
===== Heading 5 =====
-== Verbatim ==
+== &lt;nowiki&gt; tags ==
+<nowiki>
+[[Wiki]] markup is ignored here
+but the text is reformatted.
+</nowiki>
+
+== &lt;pre&gt; tags ==
+<pre>
+[[Wiki]] markup is ignored here
+ and reformatting is also disabled.
+</pre>
+
+== Leading spaces ==
This
is a
- verbatim
+ preformatted
text.
+ [[Foo|Wiki markup is interpretted in here.]]
== Horizontal Line ==
----
== Link ==
* [[Page]]
+* [[page]]
+* [[space in a page name]]
* [[Page|Link to "Page"]]
* [[Page#Heading]]
* [[#Heading]]
== Link ==
[[Page]]
+[[page]]
+[[space in a page name]]
[[Page|Link to "Page"]]
[[Page#Heading]]
[[#Heading]]