Merge pull request #4670 from unisonweb/cp/doc-italics

Allow multi-line bold, italics, and strikethrough
This commit is contained in:
Arya Irani 2024-02-05 22:13:27 -05:00 committed by GitHub
commit 6f6745240e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 1 deletions

View File

@ -48,6 +48,21 @@ structural type Optional a = More Text
{{ A doc before a type with no type-vars }}
type Two = One Nat | Two Text
-- Regression for https://github.com/unisonweb/unison/issues/4669
multilineBold = {{
**This paragraph is really really really really really long and spans multiple lines
with a strike-through block**
_This paragraph is really really really really really long and spans multiple lines
with a strike-through block_
~This paragraph is really really really really really long and spans multiple lines
with a strike-through block~
}}
```
```ucm

View File

@ -44,6 +44,21 @@ structural type Optional a = More Text
{{ A doc before a type with no type-vars }}
type Two = One Nat | Two Text
-- Regression for https://github.com/unisonweb/unison/issues/4669
multilineBold = {{
**This paragraph is really really really really really long and spans multiple lines
with a strike-through block**
_This paragraph is really really really really really long and spans multiple lines
with a strike-through block_
~This paragraph is really really really really really long and spans multiple lines
with a strike-through block~
}}
```
```ucm
@ -91,6 +106,20 @@ structural type Optional a = More Text | Some | Other a | None Nat
Two.doc = {{ A doc before a type with no type-vars }}
type Two = One Nat | Two Text
-- Regression for https://github.com/unisonweb/unison/issues/4669
multilineBold =
{{
**This paragraph is really really really really really long and spans
multiple lines with a strike-through block**
__This paragraph is really really really really really long and spans
multiple lines with a strike-through block__
~~This paragraph is really really really really really long and spans
multiple lines with a strike-through block~~
}}
```
Formatter should leave things alone if the file doesn't typecheck.

View File

@ -587,6 +587,14 @@ lexemes' eof =
nonNewlineSpace ch = isSpace ch && ch /= '\n' && ch /= '\r'
nonNewlineSpaces = P.takeWhileP Nothing nonNewlineSpace
-- Allows whitespace or a newline, but not more than two newlines in a row.
whitespaceWithoutParagraphBreak :: P ()
whitespaceWithoutParagraphBreak = void do
void nonNewlineSpaces
optional newline >>= \case
Just _ -> void nonNewlineSpaces
Nothing -> pure ()
fencedBlock =
P.label "block eval (syntax: a fenced code block)" $
evalUnison <|> exampleBlock <|> other
@ -651,7 +659,7 @@ lexemes' eof =
wrap (name end) . wrap "syntax.docParagraph" $
join
<$> P.someTill
(leafy (closing <|> (void $ lit end)) <* nonNewlineSpaces)
(leafy (closing <|> (void $ lit end)) <* whitespaceWithoutParagraphBreak)
(lit end)
externalLink =