diff --git a/parser-typechecker/src/Unison/Codebase/TranscriptParser.hs b/parser-typechecker/src/Unison/Codebase/TranscriptParser.hs index fe6f3e79e..85372c485 100644 --- a/parser-typechecker/src/Unison/Codebase/TranscriptParser.hs +++ b/parser-typechecker/src/Unison/Codebase/TranscriptParser.hs @@ -302,7 +302,7 @@ ucmCommand = do fenced :: P Stanza fenced = do fence - fenceType <- lineToken (word "ucm" <|> word "unison" <|> lineUntilSpace) + fenceType <- lineToken(word "ucm" <|> word "unison" <|> language) stanza <- if fenceType == "ucm" then do hide <- hidden @@ -381,8 +381,8 @@ expectingError = isJust <$> optional (word ":error") untilSpace1 :: P Text untilSpace1 = P.takeWhile1P Nothing (not . Char.isSpace) -lineUntilSpace :: P Text -lineUntilSpace = P.takeWhileP Nothing (\ch -> ch `elem` (" \t" :: String)) +language :: P Text +language = P.takeWhileP Nothing (\ch -> Char.isDigit ch || Char.isLower ch || ch == '_' ) spaces :: P () spaces = void $ P.takeWhileP (Just "spaces") Char.isSpace diff --git a/unison-src/transcripts/transcript-parser-commands.md b/unison-src/transcripts/transcript-parser-commands.md new file mode 100644 index 000000000..fa07bdc67 --- /dev/null +++ b/unison-src/transcripts/transcript-parser-commands.md @@ -0,0 +1,37 @@ +### Transcript parser operations + +The transcript parser is meant to parse `ucm` and `unison` blocks. + +```unison +x = 1 +``` + +```ucm +.> add +``` + +```unison:hide:error:scratch.u +z +``` + +```ucm:error +.> delete foo +``` + +```ucm :error +.> delete lineToken.call +``` + +However handling of blocks of other languages should be supported. + +```python +some python code +``` + +```c_cpp +some C++ code +``` + +```c9search +some cloud9 code +``` \ No newline at end of file diff --git a/unison-src/transcripts/transcript-parser-commands.output.md b/unison-src/transcripts/transcript-parser-commands.output.md new file mode 100644 index 000000000..1e480efc5 --- /dev/null +++ b/unison-src/transcripts/transcript-parser-commands.output.md @@ -0,0 +1,75 @@ +### Transcript parser operations + +The transcript parser is meant to parse `ucm` and `unison` blocks. + +```unison +x = 1 +``` + +```ucm + + I found and typechecked these definitions in scratch.u. If you + do an `add` or `update`, here's how your codebase would + change: + + ⍟ These new definitions are ok to `add`: + + x : Nat + + Now evaluating any watch expressions (lines starting with + `>`)... Ctrl+C cancels. + +``` +```ucm +.> add + + ⍟ I've added these definitions: + + x : Nat + +``` +```unison +--- +title: :scratch.u +--- +z + +``` + + +```ucm +.> delete foo + + ⚠️ + + I don't know about that name. + +``` +```ucm +.> delete lineToken.call + + ⚠️ + + I don't know about that name. + +``` +However handling of blocks of other languages should be supported. + +```python + +some python code + +``` + +```c_cpp + +some C++ code + +``` + +```c9search + +some cloud9 code + +``` +