Although Text will render two lines if you pass it a 2 line String, it will render the text of both lines concatenated if you pass it as a markdown string.
Same if you create an AttributeText before. Examining the AT highlights the markdown structure (NSPresentationIntent
, NSInlinePresentationIntent
, NSLink
, Header
, Paragraph
, CodeBlock
, etc) but this is "flattened" if you will (NSLink works, multiline CodeBlock work).
The problem isn't only present in Text. My use case was CoreText 2: I expected that each AttributeText run would be turned into a text layout fragment but NSTextLayoutManager
also flattens my example.
As an example, a screenshot of a markdown file in Xcode and the rendering in the simulator. 2 "paragraphs" aka 2 text layout fragments.
The same test with the EGG recipes rtf file of the CoreText2 WWDC21 session gives predictable results, one text layout fragment per paragraph.
I'm wondering if this is a bug or a "feature" of this markdown first iteration? I tried to access the NSPresentationIntent
without much luck to populate CoreText2 myself.
Any hint would be REALLY welcomed.
thank.
I made a sample project to show how I solved this:
https://github.com/frankrausch/AttributedStringStyledMarkdown