You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pollen/doc/quick-tour.html

5 lines
58 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>2&nbsp;Quick tour</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="mb.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9660;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Pollen:<span class="mywbr"> &nbsp;</span> the book is a program</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="Installation.html" class="tocviewlink" data-pltdoc="x">Installation</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="quick-tour.html" class="tocviewselflink" data-pltdoc="x">Quick tour</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="Backstory.html" class="tocviewlink" data-pltdoc="x">Backstory</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="big-picture.html" class="tocviewlink" data-pltdoc="x">The big picture</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="first-tutorial.html" class="tocviewlink" data-pltdoc="x">First tutorial</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="second-tutorial.html" class="tocviewlink" data-pltdoc="x">Second tutorial</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="third-tutorial.html" class="tocviewlink" data-pltdoc="x">Third tutorial</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="raco-pollen.html" class="tocviewlink" data-pltdoc="x">Using <span class="stt">raco pollen</span></a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="File_formats.html" class="tocviewlink" data-pltdoc="x">File formats</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="reader.html" class="tocviewlink" data-pltdoc="x">&#9674; command overview</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="Module_reference.html" class="tocviewlink" data-pltdoc="x">Module reference</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Acknowledgments.html" class="tocviewlink" data-pltdoc="x">Acknowledgments</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="License___source_code.html" class="tocviewlink" data-pltdoc="x">License &amp; source code</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>2&nbsp;</td><td><a href="quick-tour.html" class="tocviewselflink" data-pltdoc="x">Quick tour</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1&nbsp;</td><td><a href="quick-tour.html#%28part._.Creating_a_source_file%29" class="tocviewlink" data-pltdoc="x">Creating a source file</a></td></tr><tr><td align="right">2.2&nbsp;</td><td><a href="quick-tour.html#%28part._.Running_a_source_file%29" class="tocviewlink" data-pltdoc="x">Running a source file</a></td></tr><tr><td align="right">2.3&nbsp;</td><td><a href="quick-t
<br/><span style="font-weight: bold">Mac</span>: option + shift + V
<br/><span style="font-weight: bold">Windows</span>: holding down alt, type 9674 on the num pad
10 years ago
<br/><span style="font-weight: bold">Ubuntu</span>: ctrl + shift + U, then 25CA</p><p>The whole command <span class="stt">&#9674;define[my-inset]{30%}</span> means &ldquo;create a variable called <span class="stt">my-inset</span> and give it the value <span class="stt">30%</span>.&rdquo;</p><p>Then put the variable into the HTML like so, this time using the &#9674; character with the variable name in the two places the value appears:</p><div class="fileblock"><div class="SIntrapara"><div class="fileblock_filetitle"><span class="fileblock_filename"><span class="stt">"margin.html.pp"</span></span></div></div><div class="SIntrapara"><div class="fileblock_filecontent"><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace">&nbsp;</span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">&#9674;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktPn">[</span><span class="RktSym">my-inset</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">30%</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">&lt;body</span><span class="hspace">&nbsp;</span><span class="RktMeta">style=</span><span class="RktVal">"margin:</span><span class="hspace">&nbsp;</span><span class="RktVal">&#9674;my-inset;</span><span class="hspace">&nbsp;</span><span class="RktVal">border:1px</span><span class="hspace">&nbsp;</span><span class="RktVal">solid</span><span class="hspace">&nbsp;</span><span class="RktVal">black"</span><span class="RktMeta">&gt;</span></td></tr><tr><td><span class="RktMeta">&#9674;</span><span class="RktSym">my-inset</span><span class="RktMeta"></span><span class="hspace">&nbsp;</span><span class="RktMeta">is</span><span class="hspace">&nbsp;</span><span class="RktMeta">the</span><span class="hspace">&nbsp;</span><span class="RktMeta">inset.</span></td></tr><tr><td><span class="RktMeta">&lt;/body&gt;</span></td></tr></table></blockquote></div></div></div></div><p>Now reload <a href="http://localhost:8080/margin.html"><span class="stt">margin.html</span></a>. You&rsquo;ll see that the size of the margin has changed (because of the change to the <span class="stt">style</span> attribute) and so has the text of the HTML. If you like, try editing <span class="stt">my-inset</span> with different values and reloading the page. You can also try using <span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span> to create another variable (for instance, to change the color of the box border).</p><p>Still, this is the tiniest tip of the iceberg. The Pollen preprocessor gives you access to everything in the Racket programming language &#8212;&#160;including math functions, text manipulation, and so on.</p><h4>2.7<tt>&nbsp;</tt><a name="(part._.Markdown_mode)"></a>Markdown mode</h4><p>When used as a preprocessor, Pollen&rsquo;s rule is that what you write is what you get. But if you&rsquo;re targeting HTML, who wants to type out all those <span class="stt">&lt;tedious&gt;tags&lt;/tedious&gt;</span>? You can make Pollen do the heavy lifting by using it as a source decoder.</p><p>For instance, Markdown mode. Markdown is a simplified <a href="https://daringfireball.net/projects/markdown/">notation system</a> for HTML. You can use Pollen&rsquo;s Markdown decoder by inserting <span class="stt">#lang pollen</span> as the first line, and adding the <span class="stt">.pmd</span> file extension.</p><p>Try it. In DrRacket, create a file with the following lines and save it as <span class="stt">downtown.html.pmd</span>:</p><di