Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit ec7e21df authored by Marc Coiffier's avatar Marc Coiffier
Browse files

Make CaPriCon preserve whitespace at the end of documents

parent 137faa42
......@@ -2,7 +2,7 @@
-- see http://haskell.org/cabal/users-guide/
name: capricon
version: 0.12.2
version: 0.12.2.1
-- synopsis:
-- description:
license: GPL-3
......
......@@ -154,7 +154,7 @@ runWordsState ws st = ($st) $ from (stateT.concatT) $^ do
runWithFS :: JS.JSString -> FSIO a -> JS.CIO a
runWithFS fsname (FSIO r) = newFS fsname >>= r^..readerT
hasteDict = cocDict ("0.12.2-js" :: String) getString getBytes setString setBytes
hasteDict = cocDict ("0.12.2.1-js" :: String) getString getBytes setString setBytes
main :: IO ()
main = do
......
......@@ -134,17 +134,22 @@ stringWordsAndSpaces unquoteStrings = map (second fromString) . fromBlank id . t
fromWChar k "" = [(True,k "")]
literate :: forall str. IsCapriconString str => Parser String [str]
literate = intercalate [":s\n"] <$> sepBy' (cmdline "> " ">? " <+? cmdline "$> " "$>? " <+? commentline) (single '\n')
literate = liftA2 (\pref r -> pref + [":s"+fromString r])
(intercalate [":s\n"] <$> sepBy' (cmdline "> " ">? " <+? cmdline "$> " "$>? " <+? commentline) (single '\n'))
remaining
where
wrapResult :: Bool -> [str] -> [str]
wrapResult isParagraph l = case isParagraph of
True -> ":p[":l+[":p]"]
False -> ":s[":l+[":s]"]
cmdline :: Parser String () -> Parser String () -> Parser String [str]
cmdline pre pre_ex = map (\(x,exs) -> [":cp["+fromString (show (length x,if nonempty exs then True else False)),":cp="+intercalate "\n" (map fst x)]
+ (if nonempty exs then ":x[":[":x="+ex | ex <- exs]+[":x]"] else [])
+ (":cp]":wrapResult True (foldMap snd x)))
((,) <$> sepBy1' go (single '\n') <*> option' [] ("\n" >> sepBy1' go_ex (single '\n')))
cmdline pre pre_ex = do
indent <- many' (oneOf [' ','\t'])
map (\(x,exs) -> [":s"+fromString indent
,":cp["+fromString (show (length x,if nonempty exs then True else False)),":cp="+intercalate "\n" (map fst x)]
+ (if nonempty exs then ":x[":[":x="+ex | ex <- exs]+[":x]"] else [])
+ (":cp]":wrapResult True (foldMap snd x)))
((,) <$> sepBy1' go (single '\n') <*> option' [] ("\n" >> sepBy1' go_ex (single '\n')))
where go = do pre; many' (noneOf ['\n']) <&> \x -> (fromString x,map fromString (stringWords x+["steps."]))
go_ex = do pre_ex; many' (noneOf ['\n']) <&> fromString
commentline = map (foldMap (pure . (":s"+) <|> \(x,t) -> ":s[":t+[":cs"+x,":s]" :: str])) $ (<* lookingAt eol)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment