/usr/share/doc/libghc-blaze-markup-doc/html/src/Text-Blaze-Renderer-Pretty.html is in libghc-blaze-markup-doc 0.8.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/Text/Blaze/Renderer/Pretty.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-- | A renderer that produces pretty HTML, mostly meant for debugging purposes.</span>
<a name="line-2"></a><span class='hs-comment'>--</span>
<a name="line-3"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>Blaze</span><span class='hs-varop'>.</span><span class='hs-conid'>Renderer</span><span class='hs-varop'>.</span><span class='hs-conid'>Pretty</span>
<a name="line-4"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>renderMarkup</span>
<a name="line-5"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>renderHtml</span>
<a name="line-6"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-7"></a>
<a name="line-8"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>Blaze</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
<a name="line-9"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>Blaze</span><span class='hs-varop'>.</span><span class='hs-conid'>Renderer</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromChoiceString</span><span class='hs-layout'>)</span>
<a name="line-10"></a>
<a name="line-11"></a><a name="renderString"></a><span class='hs-comment'>-- | Render some 'Markup' to an appending 'String'.</span>
<a name="line-12"></a><span class='hs-comment'>--</span>
<a name="line-13"></a><span class='hs-definition'>renderString</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Markup</span> <span class='hs-comment'>-- ^ Markup to render</span>
<a name="line-14"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-comment'>-- ^ String to append</span>
<a name="line-15"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-comment'>-- ^ Resulting String</span>
<a name="line-16"></a><span class='hs-definition'>renderString</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>go</span> <span class='hs-num'>0</span> <span class='hs-varid'>id</span>
<a name="line-17"></a> <span class='hs-keyword'>where</span>
<a name="line-18"></a> <span class='hs-varid'>go</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>MarkupM</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span>
<a name="line-19"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>Parent</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>open</span> <span class='hs-varid'>close</span> <span class='hs-varid'>content</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-20"></a> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-varid'>getString</span> <span class='hs-varid'>open</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>">\n"</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>go</span> <span class='hs-layout'>(</span><span class='hs-varid'>inc</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-varid'>id</span> <span class='hs-varid'>content</span>
<a name="line-21"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-varid'>getString</span> <span class='hs-varid'>close</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'\n'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span>
<a name="line-22"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>CustomParent</span> <span class='hs-varid'>tag</span> <span class='hs-varid'>content</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-23"></a> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'<'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>tag</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>">\n"</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span>
<a name="line-24"></a> <span class='hs-varid'>go</span> <span class='hs-layout'>(</span><span class='hs-varid'>inc</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-varid'>id</span> <span class='hs-varid'>content</span> <span class='hs-varop'>.</span> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>"</"</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>tag</span> <span class='hs-varop'>.</span>
<a name="line-25"></a> <span class='hs-layout'>(</span><span class='hs-str'>">\n"</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span>
<a name="line-26"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>Leaf</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>begin</span> <span class='hs-varid'>end</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-27"></a> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-varid'>getString</span> <span class='hs-varid'>begin</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span> <span class='hs-varop'>.</span> <span class='hs-varid'>getString</span> <span class='hs-varid'>end</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'\n'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span>
<a name="line-28"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>CustomLeaf</span> <span class='hs-varid'>tag</span> <span class='hs-varid'>close</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
<a name="line-29"></a> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'<'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>tag</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span> <span class='hs-varop'>.</span>
<a name="line-30"></a> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-keyword'>if</span> <span class='hs-varid'>close</span> <span class='hs-keyword'>then</span> <span class='hs-str'>" />\n"</span> <span class='hs-keyword'>else</span> <span class='hs-str'>">\n"</span><span class='hs-layout'>)</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span>
<a name="line-31"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>AddAttribute</span> <span class='hs-keyword'>_</span> <span class='hs-varid'>key</span> <span class='hs-varid'>value</span> <span class='hs-varid'>h</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>flip</span> <span class='hs-layout'>(</span><span class='hs-varid'>go</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-varid'>h</span> <span class='hs-varop'>$</span>
<a name="line-32"></a> <span class='hs-varid'>getString</span> <span class='hs-varid'>key</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>value</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'"'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span>
<a name="line-33"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>AddCustomAttribute</span> <span class='hs-varid'>key</span> <span class='hs-varid'>value</span> <span class='hs-varid'>h</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>flip</span> <span class='hs-layout'>(</span><span class='hs-varid'>go</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-varid'>h</span> <span class='hs-varop'>$</span>
<a name="line-34"></a> <span class='hs-layout'>(</span><span class='hs-chr'>' '</span> <span class='hs-conop'>:</span> <span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>key</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>"=\""</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>value</span> <span class='hs-varop'>.</span>
<a name="line-35"></a> <span class='hs-layout'>(</span><span class='hs-chr'>'"'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>attrs</span>
<a name="line-36"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Content</span> <span class='hs-varid'>content</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>content</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-chr'>'\n'</span> <span class='hs-conop'>:</span><span class='hs-layout'>)</span>
<a name="line-37"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Comment</span> <span class='hs-varid'>comment</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-varop'>.</span>
<a name="line-38"></a> <span class='hs-layout'>(</span><span class='hs-str'>"<!-- "</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromChoiceString</span> <span class='hs-varid'>comment</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-str'>" -->\n"</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span>
<a name="line-39"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-layout'>(</span><span class='hs-conid'>Append</span> <span class='hs-varid'>h1</span> <span class='hs-varid'>h2</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-varid'>h1</span> <span class='hs-varop'>.</span> <span class='hs-varid'>go</span> <span class='hs-varid'>i</span> <span class='hs-varid'>attrs</span> <span class='hs-varid'>h2</span>
<a name="line-40"></a> <span class='hs-varid'>go</span> <span class='hs-keyword'>_</span> <span class='hs-keyword'>_</span> <span class='hs-layout'>(</span><span class='hs-conid'>Empty</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>id</span>
<a name="line-41"></a> <span class='hs-comment'>{-# NOINLINE go #-}</span>
<a name="line-42"></a>
<a name="line-43"></a> <span class='hs-comment'>-- Increase the indentation</span>
<a name="line-44"></a> <span class='hs-varid'>inc</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>+</span><span class='hs-layout'>)</span> <span class='hs-num'>4</span>
<a name="line-45"></a>
<a name="line-46"></a> <span class='hs-comment'>-- Produce appending indentation</span>
<a name="line-47"></a> <span class='hs-varid'>ind</span> <span class='hs-varid'>i</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varid'>replicate</span> <span class='hs-varid'>i</span> <span class='hs-chr'>' '</span> <span class='hs-varop'>++</span><span class='hs-layout'>)</span>
<a name="line-48"></a><span class='hs-comment'>{-# INLINE renderString #-}</span>
<a name="line-49"></a>
<a name="line-50"></a><a name="renderMarkup"></a><span class='hs-comment'>-- | Render markup to a lazy 'String'. The result is prettified.</span>
<a name="line-51"></a><span class='hs-comment'>--</span>
<a name="line-52"></a><span class='hs-definition'>renderMarkup</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Markup</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span>
<a name="line-53"></a><span class='hs-definition'>renderMarkup</span> <span class='hs-varid'>html</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>renderString</span> <span class='hs-varid'>html</span> <span class='hs-str'>""</span>
<a name="line-54"></a><span class='hs-comment'>{-# INLINE renderMarkup #-}</span>
<a name="line-55"></a>
<a name="line-56"></a><a name="renderHtml"></a><span class='hs-definition'>renderHtml</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Markup</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span>
<a name="line-57"></a><span class='hs-definition'>renderHtml</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>renderMarkup</span>
<a name="line-58"></a><span class='hs-comment'>{-# INLINE renderHtml #-}</span>
<a name="line-59"></a><span class='hs-comment'>{-# DEPRECATED renderHtml
<a name="line-60"></a> "Use renderHtml from Text.Blaze.Html.Renderer.Pretty instead" #-}</span>
</pre></body>
</html>
|