Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

- Updated colors for code fragments (@EmileTrotignon, #1023)
- Fixed complexity of looking up `.odoc` files (@panglesd, #1075)
- Normalize whitespaces in codespans (@gpetiot, #1085)
A newline followed by any whitespaces is normalized as one space character.

### Changed

Expand Down
7 changes: 5 additions & 2 deletions src/parser/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,16 @@ and code_span buffer nesting_level start_offset input = parse
{ Buffer.add_char buffer c;
code_span buffer nesting_level start_offset input lexbuf }

| newline newline
| newline horizontal_space* (newline horizontal_space*)+
{ warning
input
(Parse_error.not_allowed
~what:(Token.describe (`Blank_line "\n\n"))
~in_what:(Token.describe (`Code_span "")));
Buffer.add_char buffer '\n';
Buffer.add_char buffer ' ';
code_span buffer nesting_level start_offset input lexbuf }
| newline horizontal_space+
{ Buffer.add_char buffer ' ';
code_span buffer nesting_level start_offset input lexbuf }

| eof
Expand Down
6 changes: 2 additions & 4 deletions src/parser/test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,7 @@ let%expect_test _ =
{|
((output
(((f.ml (1 0) (3 4))
(paragraph (((f.ml (1 0) (3 4)) (code_span "foo\
\nbar")))))))
(paragraph (((f.ml (1 0) (3 4)) (code_span "foo bar")))))))
(warnings
( "File \"f.ml\", line 1, character 4 to line 3, character 0:\
\nBlank line is not allowed in '[...]' (code)."))) |}]
Expand All @@ -829,8 +828,7 @@ let%expect_test _ =
{|
((output
(((f.ml (1 0) (3 4))
(paragraph (((f.ml (1 0) (3 4)) (code_span "foo\
\nbar")))))))
(paragraph (((f.ml (1 0) (3 4)) (code_span "foo bar")))))))
(warnings
( "File \"f.ml\", line 1, character 4 to line 3, character 0:\
\nBlank line is not allowed in '[...]' (code)."))) |}]
Expand Down
4 changes: 4 additions & 0 deletions test/generators/cases/markup.mli
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
Code can appear {b inside [other] markup}. Its display shouldn't be
affected.

There is no differences between [a b] and [a
b].

Consecutive whitespaces not after a newline are conserved as they are: [a b].

{1 Links and references}

Expand Down
5 changes: 5 additions & 0 deletions test/generators/html/Markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ <h6 id="subparagraph"><a href="#subparagraph" class="anchor"></a>
<p>Code can appear <b>inside <code>other</code> markup</b>. Its display
shouldn't be affected.
</p>
<p>There is no differences between <code>a b</code> and <code>a b</code>.
</p>
<p>Consecutive whitespaces not after a newline are conserved as they
are: <code>a b</code>.
</p>
<h2 id="links-and-references">
<a href="#links-and-references" class="anchor"></a>Links and references
</h2>
Expand Down
4 changes: 4 additions & 0 deletions test/generators/latex/Markup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ \subsection{Styling\label{styling}}%

Code can appear \bold{inside \ocamlinlinecode{other} markup}. Its display shouldn't be affected.

There is no differences between \ocamlinlinecode{a b} and \ocamlinlinecode{a b}.

Consecutive whitespaces not after a newline are conserved as they are: \ocamlinlinecode{a b}.

\subsection{Links and references\label{links-and-references}}%
This is a \href{\#}{link}\footnote{\url{\#}}. It sends you to the top of this page. Links can have markup inside them: \href{\#}{\bold{bold}}\footnote{\url{\#}}, \href{\#}{\emph{italics}}\footnote{\url{\#}}, \href{\#}{\emph{emphasis}}\footnote{\url{\#}}, \href{\#}{super\textsuperscript{script}}\footnote{\url{\#}}, \href{\#}{sub\textsubscript{script}}\footnote{\url{\#}}, and \href{\#}{\ocamlinlinecode{code}}\footnote{\url{\#}}. Links can also be nested \emph{\href{\#}{inside}\footnote{\url{\#}}} markup. Links cannot be nested inside each other. This link has no replacement text: \href{\#}{\#}\footnote{\url{\#}}. The text is filled in by odoc. This is a shorthand link: \href{\#}{\#}\footnote{\url{\#}}. The text is also filled in by odoc in this case.

Expand Down
4 changes: 4 additions & 0 deletions test/generators/man/Markup.3o
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ It's possible for two markup elements to appear \fBnext\fR \fIto\fR each other a
This is also true between non-code markup and code\.
.sp
Code can appear \fBinside other markup\fR\. Its display shouldn't be affected\.
.sp
There is no differences between a b and a b\.
.sp
Consecutive whitespaces not after a newline are conserved as they are: a b\.
.nf
.sp
.in 3
Expand Down