Repository: JuliaLang/julia
File: stdlib/Markdown/test/runtests.jl (Julia)

Code before:
    # see issue #42139
    @test md"<一轮红日初升>" |> html == """<p>&lt;一轮红日初升&gt;</p>\n"""
end

@testset "Docstrings" begin
    @test isempty(Docs.undocumented_names(Markdown))
end

@testset "Non-Markdown" begin
    # https://github.com/JuliaLang/julia/issues/37765
    @test isa(insert_hlines(Text("foo")), Text)
    # https://github.com/JuliaLang/julia/issues/37757
    @test insert_hlines(nothing) === nothing
end

@testset "#59967: indented code blocks with more than one blank line" begin
    # Test the broken case in issue: indented code block with multiple blank lines
    md = Markdown.parse("""
- code block with more than one blank line with indention does not work
  ```julia
  domaths(x::Number) = x + 5


  domath(x::Int) = x + 10
  ```
""")

    expected =
        """
        <ul>
        <li><p>code block with more than one blank line with indention does not work</p>
        <pre><code class="language-julia">domaths&#40;x::Number&#41; &#61; x &#43; 5


        domath&#40;x::Int&#41; &#61; x &#43; 10</code></pre>
        </li>
        </ul>
        """
    @test expected == Markdown.html(md)
end

@testset "Lazy Strings" begin
    @test Markdown.parse(lazy"foo") == Markdown.parse("foo")
end


Review comment (suggestion):
Your test currently only tests the "positive" case: that the list is not ended prematurely. But I think we should also verify that it still ends when it should end. How about adding something like this:
```suggestion
- another entry, now testing code blocks without fences

      # this is a code block
      x = 1 + 1
      
      
      # Two empty lines don't interrupt the code
      y = x * 3

- a final list entry

And now to something completely different!
""")
```
which GitHub markdown renders as a list with three entries, followed by a paragraph:


- code block inside a list with more than one blank line with indentation work
  ```julia
  domaths(x::Number) = x + 5


  domath(x::Int) = x + 10
  ```
- another entry, now testing code blocks without fences

      # this is a code block
      x = 1 + 1
      
      
      # Two empty lines don't interrupt the code
      y = x * 3

- a final list entry

And now to something completely different!


Code after:
    # see issue #42139
    @test md"<一轮红日初升>" |> html == """<p>&lt;一轮红日初升&gt;</p>\n"""
end

@testset "Docstrings" begin
    @test isempty(Docs.undocumented_names(Markdown))
end

@testset "Non-Markdown" begin
    # https://github.com/JuliaLang/julia/issues/37765
    @test isa(insert_hlines(Text("foo")), Text)
    # https://github.com/JuliaLang/julia/issues/37757
    @test insert_hlines(nothing) === nothing
end

@testset "#59967: indented code blocks with more than one blank line" begin
    # Test the broken case in issue: indented code block with multiple blank lines
    md = Markdown.parse("""
    - code block inside a list with more than one blank line with indentation works
      ```julia
      domaths(x::Number) = x + 5


      domath(x::Int) = x + 10
      ```
    - another entry, now testing code blocks without fences

          # this is a code block
          x = 1 + 1


          # Two empty lines don't interrupt the code
          y = x * 3

    - a final list entry

    And now to something completely different!
    """)
    expected =
    """
    <ul>
    <li><p>code block inside a list with more than one blank line with indentation works</p>
    <pre><code class="language-julia">domaths&#40;x::Number&#41; &#61; x &#43; 5


    domath&#40;x::Int&#41; &#61; x &#43; 10</code></pre>
    </li>
    <li><p>another entry, now testing code blocks without fences</p>
    <pre><code># this is a code block
    x &#61; 1 &#43; 1