Skip to content

Commit 292ea8b

Browse files
committed
tolerate additional useless path components in Snippet block directive
1 parent 2123075 commit 292ea8b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Sources/MarkdownSemantics/Markdown.BlockInterpreter.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ extension Markdown.BlockInterpreter
6868
// legitimized anywhere else.
6969
guard
7070
let i:String.Index = value.firstIndex(of: "/"),
71-
let j:String.Index = value.lastIndex(of: "/"),
72-
case "/Snippets" = value[i ..< j]
71+
let j:String.Index = value.lastIndex(of: "/")
72+
else
73+
{
74+
// TODO: emit diagnostic.
75+
continue
76+
}
77+
78+
// OK for the path to contain additional intermediate path components, which
79+
// are just as irrelevant as the package name, because snippet names are
80+
// unique within a package.
81+
guard
82+
case "Snippets" = value[value.index(after: i)...].prefix(while: { $0 != "/" })
7383
else
7484
{
7585
// TODO: emit diagnostic.

0 commit comments

Comments
 (0)