packages feed

pencil 0.1.1 → 0.1.2

raw patch · 5 files changed

+53/−78 lines, 5 files

Files

CHANGELOG.md view
@@ -2,11 +2,17 @@  All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).+## [Unreleased] -## [0.1.1](https://github.com/elben/pencil/)+## [0.1.2]  ### Added+- Escape template directives using `$${example}`. This will be rendered+  literally as `${example}`.++## [0.1.1]++### Added - Blog example. - Minor method changes. @@ -27,3 +33,9 @@ ### Removed ### Deprecated ### Security++The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).++[Unreleased]: https://github.com/elben/pencil/compare/v1.0.0...HEAD+[0.1.2]: https://github.com/elben/pencil/compare/v0.1.1...v0.1.2+[0.1.1]: https://github.com/elben/pencil/compare/cb14e3610aa18dd3c71279bd56231c6bb23bae7b...v0.1.1
README.md view
@@ -6,6 +6,10 @@ Pencil comes pre-loaded with goodies such as blogging, tagging, templating, and Markdown Sass/Scss support. Flexible enough to extend for your own needs. +The easiest way to get started is to read the tutorials at+[elbenshira.com/pencil](http://elbenshira.com/pencil) and reference the [Haddock+docs](https://hackage.haskell.org/package/pencil).+ > The blue-backed notebooks, the two pencils and the pencil sharpener... the > marble topped tables, the smell of early morning... and luck were all you > needed. — Ernest Hemingway, A Moveable Feast@@ -32,65 +36,4 @@  # Development -```bash-stack build --pedantic-stack test-stack exec doctest src/-```--## Documentation--```-stack haddock-```--## Ctags--```bash-stack install hasktags-hasktags --ignore-close-implementation --ctags .-```--## Release--Make sure it builds, passes tests, and works:--```-stack build-stack test-stack exec pencil-example-simple-stack exec pencil-example-blog-stack haddock-```--Check that tutorials are updated.--Update the CHANGELOG.md.--Update the version number in `pencil.cabal`.--Commit the changes.--Tag the release:--```-git tag v0.1.0-git push --tags-```--Push to Hackage:--```-stack sdist-stack upload-```--## Travis CI--[travis-ci.org/elben/pencil](https://travis-ci.org/elben/pencil)--Note that `.travis.yml` was generated using [multi-ghc-travis](https://github.com/haskell-hvr/multi-ghc-travis) this:--```-stack exec runghc ~/code/multi-ghc-travis/make_travis_yml_2.hs pencil.cabal > .travis.yml-```+See [DEVELOPMENT.md](DEVELOPMENT.md)
pencil.cabal view
@@ -1,10 +1,10 @@ name:                pencil-version:             0.1.1+version:             0.1.2 synopsis: Static site generator description:   Pencil is a static site generator. Use it to generate your personal website!-  Pencil comes pre-loaded with goodies such as blogging, tagging, templating,-  and Markdown Sass/Scss support. Flexible enough to extend for your own needs.+  Pencil comes pre-loaded blogging, tagging, templating, and Markdown and+  Sass/Scss support. Flexible enough to extend for your own needs. homepage:            https://github.com/elben/pencil license:             BSD3 license-file:        LICENSE
src/Pencil/Internal/Parser.hs view
@@ -43,6 +43,8 @@   | TokEnd   deriving (Show, Eq) +-- | Convert Tokens to PNode AST.+-- -- >>> transform [TokText "hello", TokText "world"] -- [PText "hello",PText "world"] --@@ -91,7 +93,6 @@ -- >>> transform [TokPreamble "foo: bar\ndo:\n  - re\n  -me", TokText "Hello world ", TokVar "foo"] -- [PPreamble "foo: bar\ndo:\n  - re\n  -me",PText "Hello world ",PVar "foo"] ----- | Convert Tokens to PNode AST. transform :: [Token] -> [PNode] transform toks =   let stack = ast [] toks@@ -184,6 +185,7 @@   toks <- parse parseEverything (T.unpack "") (T.unpack text)   return $ transform toks +-- | Parse everything. -- -- >>> parse parseEverything "" "Hello ${man} and ${woman}." -- Right [TokText "Hello ",TokVar "man",TokText " and ",TokVar "woman",TokText "."]@@ -194,8 +196,8 @@ -- >>> parse parseEverything "" "Hi ${for(people)} ${name}, ${end} everyone!" -- Right [TokText "Hi ",TokFor "people",TokText " ",TokVar "name",TokText ", ",TokEnd,TokText " everyone!"] ----- >>> parse parseEverything "" "${realvar} $.get(javascript) $$ $$$ $} $( $45.50 $$escape wonderful life! ${truth}"--- Right [TokVar "realvar",TokText " $.get(javascript) $$ $$$ $} $( $45.50 $$escape wonderful life! ",TokVar "truth"]+-- >>> parse parseEverything "" "${realvar} $.get(javascript) $$ $$$ $} $( $45.50 $$escape $${escape2} wonderful life! ${truth}"+-- Right [TokVar "realvar",TokText " $.get(javascript) $$ $$$ $} $( $45.50 $$escape ",TokText "${",TokText "escape2} wonderful life! ",TokVar "truth"] -- -- >>> parse parseEverything "" "<!--PREAMBLE  \n  foo: bar\ndo:\n  - re\n  -me\n  -->waffle house ${lyfe}" -- Right [TokPreamble "  \n  foo: bar\ndo:\n  - re\n  -me\n  ",TokText "waffle house ",TokVar "lyfe"]@@ -207,13 +209,12 @@ -- >>> parse parseEverything "" "<b>this ${var never closes</b> ${realvar}" -- Right [TokText "<b>this ",TokVar "var never closes</b> ${realvar"] ----- | Parse everything.--- parseEverything :: Parser [Token] parseEverything =   -- Note that order matters here. We want "most general" to be last (variable   -- names).   many1 (try parsePreamble+     <|> try parseEscape      <|> try parseContent      <|> try parseEnd      <|> try parseFor@@ -259,10 +260,11 @@ parsePreambleStart = string "<!--PREAMBLE"  +-- | Parse partial commands.+-- -- >>> parse parsePartial "" "${partial(\"my/file/name.html\")}" -- Right (TokPartial "my/file/name.html") ----- | Parse partial commands. parsePartial :: Parser Token parsePartial = do   _ <- string "${partial(\""@@ -270,6 +272,18 @@   _ <- string "\")}"   return $ TokPartial (T.pack filename) +-- | Parse escape sequence "$${"+--+-- >>> parse parseEscape "" "$${example}"+-- Right (TokText "${")+--+parseEscape :: Parser Token+parseEscape = do+  _ <- try $ string "$${"+  return (TokText "${")++-- | Parse boring, boring text.+-- -- >>> parse parseContent "" "hello ${ffwe} you!" -- Right (TokText "hello ") --@@ -285,7 +299,6 @@ -- >>> isLeft $ parse parseContent "" "${name}!!" -- True ----- | Parse boring, boring text. parseContent :: Parser Token parseContent = do   -- The manyTill big parser below will accept an empty string, which is bad. So@@ -296,10 +309,17 @@   -- both lookAhead (does not consume successful "${" found) and try (does not   -- consume failure to find "${"). Not having both produces bugs, so.   --+  -- Also grab "$${", which should be captured as an escape (parseEscape).+  --   -- https://stackoverflow.com/questions/20020350/parsec-difference-between-try-and-lookahead-  stuff <- manyTill anyChar (try (lookAhead (string "${")) <|> try (lookAhead parsePreambleStart) <|> (eof >> return " "))+  stuff <- manyTill anyChar (try (lookAhead (string "$${")) <|>+                             try (lookAhead (string "${")) <|>+                             try (lookAhead parsePreambleStart) <|>+                             (eof >> return " "))   return $ TokText (T.pack (h : stuff)) +-- | Parse for loop declaration.+-- -- >>> parse parseFor "" "${for(posts)}" -- Right (TokFor "posts") --@@ -312,7 +332,6 @@ -- >>> isLeft $ parse parseFor "" "${for foo}" -- True ----- | Parse for loop declaration. parseFor :: Parser Token parseFor = parseFunction "for" TokFor @@ -331,13 +350,14 @@   _ <- char '}'   return $ ctor (T.pack varName) +-- | Parse end keyword.+-- -- >>> parse parseEnd "" "${end}" -- Right TokEnd -- -- >>> isLeft $ parse parseEnd "" "${enddd}" -- True ----- | Parse end keyword. parseEnd :: Parser Token parseEnd = do   _ <- try $ string "${end}"
src/Pencil/Internal/Pencil.hs view
@@ -838,7 +838,7 @@ -- The first element defines the outer-most container, and subsequent elements -- are /inside/ the previous element. ----- You commonly @Structure@s to insert a @Page@ containing content (e.g. a blog+-- You commonly use @Structure@s to insert a @Page@ containing content (e.g. a blog -- post) into a container (e.g. a layout shared across all your web pages). -- -- Build structures using 'structure', '<||' and '<|'.