swiftlang / swift-markdown

A Swift package for parsing, building, editing, and analyzing Markdown documents.
https://swiftpackageindex.com/swiftlang/swift-markdown/documentation/markdown
Apache License 2.0
2.79k stars 191 forks source link

add optional Aside intiailizer that bails if it can't find a tag #196

Closed QuietMisdreavus closed 2 months ago

QuietMisdreavus commented 3 months ago

Bug/issue #, if applicable: Resolves #139

Summary

This PR adds a new initializer to Aside that only returns a new instance if it successfully finds an aside tag at the beginning of the block-quote. To make the API fully flexible, this API introduces three separate modes to this initializer:

  1. tagNotRequired, which defers to the currently-available initializer that creates a .note aside if it can't find a tag,
  2. requireSingleWordTag, which requires that the block starts with a single-word tag (and is used by the new HTML formatter), and
  3. requireAnyLengthTag, which requires that the block starts with a tag (defined as any text prefixed by a colon), even tags with multiple words like See Also:.

Dependencies

None

Testing

As this is an API-only change, the testing strategy is limited to automated testing.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

QuietMisdreavus commented 3 months ago

@swift-ci Please test

QuietMisdreavus commented 2 months ago

@swift-ci Please test

QuietMisdreavus commented 2 months ago

@swift-ci Please test