Skip to content

Commit 6f67452

Browse files
authored
Merge pull request #4670 from unisonweb/cp/doc-italics
Allow multi-line bold, italics, and strikethrough
2 parents 4eb0147 + be330a8 commit 6f67452

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

unison-src/transcripts/formatter.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ structural type Optional a = More Text
4848
4949
{{ A doc before a type with no type-vars }}
5050
type Two = One Nat | Two Text
51+
52+
-- Regression for https://github.com/unisonweb/unison/issues/4669
53+
54+
multilineBold = {{
55+
56+
**This paragraph is really really really really really long and spans multiple lines
57+
with a strike-through block**
58+
59+
_This paragraph is really really really really really long and spans multiple lines
60+
with a strike-through block_
61+
62+
~This paragraph is really really really really really long and spans multiple lines
63+
with a strike-through block~
64+
65+
}}
5166
```
5267

5368
```ucm

unison-src/transcripts/formatter.output.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ structural type Optional a = More Text
4444
4545
{{ A doc before a type with no type-vars }}
4646
type Two = One Nat | Two Text
47+
48+
-- Regression for https://github.com/unisonweb/unison/issues/4669
49+
50+
multilineBold = {{
51+
52+
**This paragraph is really really really really really long and spans multiple lines
53+
with a strike-through block**
54+
55+
_This paragraph is really really really really really long and spans multiple lines
56+
with a strike-through block_
57+
58+
~This paragraph is really really really really really long and spans multiple lines
59+
with a strike-through block~
60+
61+
}}
4762
```
4863

4964
```ucm
@@ -91,6 +106,20 @@ structural type Optional a = More Text | Some | Other a | None Nat
91106
92107
Two.doc = {{ A doc before a type with no type-vars }}
93108
type Two = One Nat | Two Text
109+
110+
-- Regression for https://github.com/unisonweb/unison/issues/4669
111+
112+
multilineBold =
113+
{{
114+
**This paragraph is really really really really really long and spans
115+
multiple lines with a strike-through block**
116+
117+
__This paragraph is really really really really really long and spans
118+
multiple lines with a strike-through block__
119+
120+
~~This paragraph is really really really really really long and spans
121+
multiple lines with a strike-through block~~
122+
}}
94123
```
95124

96125
Formatter should leave things alone if the file doesn't typecheck.

unison-syntax/src/Unison/Syntax/Lexer.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ lexemes' eof =
587587
nonNewlineSpace ch = isSpace ch && ch /= '\n' && ch /= '\r'
588588
nonNewlineSpaces = P.takeWhileP Nothing nonNewlineSpace
589589

590+
-- Allows whitespace or a newline, but not more than two newlines in a row.
591+
whitespaceWithoutParagraphBreak :: P ()
592+
whitespaceWithoutParagraphBreak = void do
593+
void nonNewlineSpaces
594+
optional newline >>= \case
595+
Just _ -> void nonNewlineSpaces
596+
Nothing -> pure ()
597+
590598
fencedBlock =
591599
P.label "block eval (syntax: a fenced code block)" $
592600
evalUnison <|> exampleBlock <|> other
@@ -651,7 +659,7 @@ lexemes' eof =
651659
wrap (name end) . wrap "syntax.docParagraph" $
652660
join
653661
<$> P.someTill
654-
(leafy (closing <|> (void $ lit end)) <* nonNewlineSpaces)
662+
(leafy (closing <|> (void $ lit end)) <* whitespaceWithoutParagraphBreak)
655663
(lit end)
656664

657665
externalLink =

0 commit comments

Comments
 (0)