Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline comments do not hide @Step in tutorials. #180

Open
1 of 2 tasks
mbrandonw opened this issue Jun 5, 2024 · 2 comments
Open
1 of 2 tasks

Multiline comments do not hide @Step in tutorials. #180

mbrandonw opened this issue Jun 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mbrandonw
Copy link

Description

If you use a multiline HTML comment with @Steps inside, those steps will be rendered in docs:

<!--

This text will not be rendered in docs.

@Step {
  This text **will** be rendered in docs.
}

--!>

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

I would expect that everything inside <!-- --> is omitted from rendering.

Actual behavior

Instead, @Steps are rendered.

Steps To Reproduce

Put the following in any tutorial to see that the step will be rendered:

<!--

This text will not be rendered in docs.

@Step {
  This text **will** be rendered in docs.
}

--!>

Swift-DocC Version Information

Xcode 15.4

Swift Compiler Version Information

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
@mbrandonw mbrandonw added the bug Something isn't working label Jun 5, 2024
@d-ronnqvist
Copy link
Contributor

This is an issue with directive parsing in swift-markdown. It can be reproduced with this test

func testDirectiveInMultilineHTMLComment() {
    let content = """
    # Some heading

    <!--

    Some commented out text

    @SomeDirectiveName {
      Some content within the directive
    }

    -->

    A paragraph with some text.
    """
    let document = Document(parsing: content, source: nil, options: .parseBlockDirectives)
    XCTAssertEqual(document.debugDescription(), """
    Document
    ├─ Heading level: 1
    │  └─ Text "Some heading"
    ├─ HTMLBlock
    │  <!--
    │  Some commented out text
    │  @SomeDirectiveName {
    │    Some content within the directive
    │  }
    │  -->
    └─ Paragraph
       └─ Text "A paragraph with some text."
    """)
}

@d-ronnqvist d-ronnqvist transferred this issue from swiftlang/swift-docc Jun 11, 2024
@QuietMisdreavus
Copy link
Contributor

The interaction between block directives and any other Markdown/HTML syntax is awkward, and fixing this properly will require a severe rewrite of the code.

As a workaround, you can use the @Comment directive instead of an HTML comment:

@Comment {
  This text will not be rendered in docs.

  @Step {
    This text will also not be rendered in docs.
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants