Replies: 1 comment
-
Hi @drekka, The theming API in MarkdownUI works at two levels. On the one hand, you have the styles for the inline text; these styles define the attributes (font, size, foreground color, background color, etc.) for each Markdown inline: text, strong text, emphasized text, inline code, links, and strikethrough text. The
These styles can be combined together. For instance, a strongly emphasized text (i.e., On the other hand, you have block styles. These are conceptually similar to SwiftUI styles ( You can get the idea by looking at the In summary, if you want to use a different font for your Markdown, you need to override the base Markdown {
// Contents
}
.markdownTextStyle(\.text) {
FontFamily(.custom("Avenir"))
} If you want to use a different font just for the headings, you will need to override all the heading styles: Markdown {
// Contents
}
.markdownBlockStyle(\.heading1) { configuration in
configuration.label
.markdownMargin(top: .rem(1.5), bottom: .rem(1))
.markdownTextStyle {
FontFamily(.custom("Avenir"))
FontWeight(.semibold)
FontSize(.em(2))
}
} If you need to customize the Markdown appearance fully, it is better to create your own theme. My suggestion is to start by copying the code of the |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using your excellent API to provide documents embedded in my app. The issue I'm trying to figure out is how to theme the markdown so it looks like the headings, lists, paragraphs etc in the SwiftUI code.
I've been looking at the doco you've provided but I'm still not sure how to approach this. I currently have a range of custom fonts in my app, some of which I was to apply to the markdown. But it appears I can't just set a font and have to effectively define each font style again.
Or am I missing something? ie. is there a way to do something like heading1.font = myFont?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions