apple/swift-markdown

DocC drops content have single-line directive

Closed this issue · 5 comments

Description

When compiling this documentation comment:

/// Hello
///
/// Some content
///
/// @Comment { This is a comment }
///
/// Hello World

The text after the comment directive incorrectly gets dropped. This doesn't reproduce when writing the directive over multiple lines.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

DocC should not drop content after single-line directives.

Actual behavior

No response

Steps To Reproduce

No response

Swift-DocC Version Information

Swift 5.7

Swift Compiler Version Information

No response

This looks like a swift-markdown bug for me. cc @franklinsch

I'll dig more info and try to fix it.

let source = """
Hello World2

@Comment { This is a comment }

Hello World

asdf

@Comment {
    This is another comment
}
"""
let document = Document(parsing: source, options: [.parseBlockDirectives])
document.debugDescription(options: [.printEverything])

Expect Result

Document @1:1-11:2 Root #1 #0
├─ Paragraph @1:1-1:13 #1
│  └─ Text @1:1-1:13 #2 "Hello World2"
├─ BlockDirective @3:1-3:32 #3 name: "Comment"
│  └─ Paragraph @3:12-3:29 #4
│     └─ Text @3:12-3:29 #5 "This is a comment"
├─ Paragraph @5:1-5:12 #5
│  └─ Text @5:1-5:12 #6 "Hello World"
├─ Paragraph @7:1-7:5 #7
│  └─ Text @7:1-7:5 #8 "asdf"
└─ BlockDirective @9:1-11:2 #9 name: "Comment"
   └─ Paragraph @10:5-10:28 #10
      └─ Text @10:5-10:28 #11 "This is another comment"

Actual Result

Document @1:1-11:2 Root apple/swift-docc#1 #0
├─ Paragraph @1:1-1:13 apple/swift-docc#1
│  └─ Text @1:1-1:13 apple/swift-docc#2 "Hello World2"
└─ BlockDirective @3:1-3:11 apple/swift-docc#3 name: "Comment"
   ├─ Paragraph @5:1-5:12 apple/swift-docc#4
   │  └─ Text @5:1-5:12 apple/swift-docc#5 "Hello World"
   ├─ Paragraph @7:1-7:5 apple/swift-docc#6
   │  └─ Text @7:1-7:5 apple/swift-docc#7 "asdf"
   └─ BlockDirective @9:1-11:2 apple/swift-docc#8 name: "Comment"
      └─ Paragraph @10:5-10:28 apple/swift-docc#9
         └─ Text @10:5-10:28 apple/swift-docc#10 "This is another comment"

I see yes, the content after it gets parsed as the comment's children.

I transferred @ktoso's original reporting of this problem to swift-markdown in #64.

May be fixed by #66
image

Closing this as a duplicate of #64.