Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't report an error on unclosed, skipped code fence #1728

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Cryptol/REPL/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,10 +2009,10 @@ moduleInfoCmd isFile name
-- * ```
-- */
-- @
extractCodeBlocks :: T.Text -> Either String [[T.Text]]
extractCodeBlocks :: T.Text -> [[T.Text]]
extractCodeBlocks raw = go [] (T.lines raw)
where
go finished [] = Right (reverse finished)
go finished [] = reverse finished
go finished (x:xs)
| (spaces, x1) <- T.span (' ' ==) x
, (ticks, x2) <- T.span ('`' ==) x1
Expand Down Expand Up @@ -2042,7 +2042,7 @@ extractCodeBlocks raw = go [] (T.lines raw)
in keep finished indentLen ticksLen (x' : acc) xs

-- process a code block that we're skipping
skip _ _ [] = Left "Unclosed code block"
skip finished _ [] = go finished []
skip finished close (x:xs)
| close == x = go finished xs
| otherwise = skip finished close xs
Expand Down Expand Up @@ -2131,14 +2131,8 @@ data DocstringResult = DocstringResult
checkDocItem :: T.DocItem -> REPL DocstringResult
checkDocItem item =
do xs <- case traverse extractCodeBlocks (T.docText item) of
Left e -> do
pure [[SubcommandResult
{ srInput = T.empty
, srResult = emptyCommandResult { crSuccess = False }
, srLog = e
}]]
Right [] -> pure [] -- optimization
Right bs ->
[] -> pure [] -- optimization
bs ->
Ex.bracket
(liftModuleCmd (`M.runModuleM` (M.getFocusedModule <* M.setFocusedModule (T.docModContext item))))
(\mb -> liftModuleCmd (`M.runModuleM` M.setMaybeFocusedModule mb))
Expand Down
Loading