Skip to content

Run of tildes in HTML comments confuses/reverses the at-directive parser #88

@amartini51

Description

@amartini51

The at-directive parser looks for runs of ~ or ` to delimit the start and end of code blocks. It knows that an at-directive can't start by @foo inside a code block. However, if one of those lines appears in an HTML comment, the at-directive parser doesn't ignore the line. This results in the "not in a code block" logic being inverted. For example, we ran into this issue in "The Swift Programming Language" (reduced example):

<!--
  Adding Child Tasks to a Task Group
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  - Creating a group with ``withTaskGroup`` and ``withThrowingTaskGroup``
  
  - awaiting ``withGroup`` means waiting for all child tasks to complete
-->

```
struct NonsendableTemperatureReading {
    var measurement: Int
}

@available(*, unavailable)
extension NonsendableTemperatureReading: Sendable { }
```

In this case, @available is treated as the start of an at-directive and the code listing is mis-parsed and displays as follows:

199356359-535a8a12-6acd-4033-b709-82c45c38c6f1

rdar://101828693

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions