Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 1dcdd2a692cd77866af045e314526ed4 > files > 16

ghc-pandoc-types-devel-1.8-2.fc14.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Text.Pandoc.Generic</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_Text-Pandoc-Generic.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>pandoc-types-1.8: Types for representing a structured document</TD
><TD CLASS="topbut"
><A HREF="src/Text-Pandoc-Generic.html"
>Source code</A
></TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Text.Pandoc.Generic</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>portable</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>alpha</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>John MacFarlane &lt;jgm@berkeley.edu&gt;</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><P
>Generic functions for manipulating Pandoc documents.
</P
><P
>Here's a simple example, defining a function that replaces all the level 3+
headers in a document with regular paragraphs in ALL CAPS:
</P
><PRE
> import Text.Pandoc.Definition
 import Text.Pandoc.Generic
 import Data.Char (toUpper)

 modHeader :: Block -&gt; Block
 modHeader (Header n xs) | n &gt;= 3 = Para $ bottomUp allCaps xs
 modHeader x = x

 allCaps :: Inline -&gt; Inline
 allCaps (Str xs) = Str $ map toUpper xs
 allCaps x = x

 changeHeaders :: Pandoc -&gt; Pandoc
 changeHeaders = bottomUp modHeader
</PRE
><P
><TT
><A HREF="Text-Pandoc-Generic.html#v%3AbottomUp"
>bottomUp</A
></TT
> is so called because it traverses the <TT
>Pandoc</TT
> structure from
bottom up. <TT
><A HREF="Text-Pandoc-Generic.html#v%3AtopDown"
>topDown</A
></TT
> goes the other way. The difference between them can be
seen from this example:
</P
><PRE
> normal :: [Inline] -&gt; [Inline]
 normal (Space : Space : xs) = Space : xs
 normal (Emph xs : Emph ys : zs) = Emph (xs ++ ys) : zs
 normal xs = xs

 myDoc :: Pandoc
 myDoc =  Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
  [Para [Str &quot;Hi&quot;,Space,Emph [Str &quot;world&quot;,Space],Emph [Space,Str &quot;emphasized&quot;]]]
</PRE
><P
>Here we want to use <TT
><A HREF="Text-Pandoc-Generic.html#v%3AtopDown"
>topDown</A
></TT
> to lift <TT
>normal</TT
> to <TT
>Pandoc -&gt; Pandoc</TT
>.
The top down strategy will collapse the two adjacent <TT
>Emph</TT
>s first, then
collapse the resulting adjacent <TT
>Space</TT
>s, as desired. If we used <TT
><A HREF="Text-Pandoc-Generic.html#v%3AbottomUp"
>bottomUp</A
></TT
>,
we would end up with two adjacent <TT
>Space</TT
>s, since the contents of the
two <TT
>Emph</TT
> inlines would be processed before the <TT
>Emph</TT
>s were collapsed
into one.
</P
><PRE
> topDown normal myDoc ==
   Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
    [Para [Str &quot;Hi&quot;,Space,Emph [Str &quot;world&quot;,Space,Str &quot;emphasized&quot;]]]

 bottomUp normal myDoc ==
   Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
    [Para [Str &quot;Hi&quot;,Space,Emph [Str &quot;world&quot;,Space,Space,Str &quot;emphasized&quot;]]]
</PRE
><P
><TT
><A HREF="Text-Pandoc-Generic.html#v%3AbottomUpM"
>bottomUpM</A
></TT
> is a monadic version of <TT
><A HREF="Text-Pandoc-Generic.html#v%3AbottomUp"
>bottomUp</A
></TT
>.  It could be used,
for example, to replace the contents of delimited code blocks with
attribute <TT
>include=FILENAME</TT
> with the contents of <TT
>FILENAME</TT
>:
</P
><PRE
> doInclude :: Block -&gt; IO Block
 doInclude cb@(CodeBlock (id, classes, namevals) contents) =
   case lookup &quot;include&quot; namevals of
        Just f  -&gt; return . (CodeBlock (id, classes, namevals)) =&lt;&lt; readFile f
        Nothing -&gt; return cb
 doInclude x = return x

 processIncludes :: Pandoc -&gt; IO Pandoc
 processIncludes = bottomUpM doInclude
</PRE
><P
><TT
><A HREF="Text-Pandoc-Generic.html#v%3AqueryWith"
>queryWith</A
></TT
> can be used, for example, to compile a list of URLs
linked to in a document:
</P
><PRE
> extractURL :: Inline -&gt; [String]
 extractURL (Link _ (u,_)) = [u]
 extractURL (Image _ (u,_)) = [u]
 extractURL _ = []

 extractURLs :: Pandoc -&gt; [String]
 extractURLs = queryWith extractURL
</PRE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="#v%3AbottomUp"
>bottomUp</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AtopDown"
>topDown</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AbottomUpM"
>bottomUpM</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Monad.html#t%3AMonad"
>Monad</A
> m, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; m a) -&gt; b -&gt; m b</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AqueryWith"
>queryWith</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> b, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> c) =&gt; (a -&gt; b) -&gt; c -&gt; b</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AprocessWith"
>processWith</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AprocessWithM"
>processWithM</A
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Monad.html#t%3AMonad"
>Monad</A
> m, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; m a) -&gt; b -&gt; m b</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Documentation</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:bottomUp"
><A NAME="v%3AbottomUp"
></A
></A
><B
>bottomUp</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#bottomUp"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Applies a transformation on <TT
>a</TT
>s to matching elements in a <TT
>b</TT
>,
 moving from the bottom of the structure up.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:topDown"
><A NAME="v%3AtopDown"
></A
></A
><B
>topDown</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#topDown"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Applies a transformation on <TT
>a</TT
>s to matching elements in a <TT
>b</TT
>,
 moving from the top of the structure down.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:bottomUpM"
><A NAME="v%3AbottomUpM"
></A
></A
><B
>bottomUpM</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Monad.html#t%3AMonad"
>Monad</A
> m, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; m a) -&gt; b -&gt; m b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#bottomUpM"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Like <TT
><A HREF="Text-Pandoc-Generic.html#v%3AbottomUp"
>bottomUp</A
></TT
>, but with monadic transformations.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:queryWith"
><A NAME="v%3AqueryWith"
></A
></A
><B
>queryWith</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Monoid.html#t%3AMonoid"
>Monoid</A
> b, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> c) =&gt; (a -&gt; b) -&gt; c -&gt; b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#queryWith"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Runs a query on matching <TT
>a</TT
> elements in a <TT
>c</TT
>.  The results
 of the queries are combined using <TT
><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Monoid.html#v%3Amappend"
>mappend</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:processWith"
><A NAME="v%3AprocessWith"
></A
></A
><B
>processWith</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; a) -&gt; b -&gt; b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#processWith"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Deprecated synonym for <TT
>bottomUp</TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:processWithM"
><A NAME="v%3AprocessWithM"
></A
></A
><B
>processWithM</B
> :: (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Control-Monad.html#t%3AMonad"
>Monad</A
> m, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> a, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.2/Data-Data.html#t%3AData"
>Data</A
> b) =&gt; (a -&gt; m a) -&gt; b -&gt; m b</TD
><TD CLASS="declbut"
><A HREF="src/Text-Pandoc-Generic.html#processWithM"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Deprecated synonym for <TT
>bottomUpM</TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.6.1</TD
></TR
></TABLE
></BODY
></HTML
>