Change markdown headline typography
This commit is contained in:
parent
db79a19ebc
commit
624a6a6d2e
@ -104,12 +104,12 @@ fun ChildNodes(node: ASTNode, text: String, onTextChange: (String) -> Unit) {
|
||||
fun AtxNode(node: ASTNode, text: String, level: Int, onTextChange: (String) -> Unit) {
|
||||
ProvideTextStyle(
|
||||
when (level) {
|
||||
1 -> MaterialTheme.typography.headlineLarge
|
||||
2 -> MaterialTheme.typography.headlineMedium
|
||||
3 -> MaterialTheme.typography.headlineSmall
|
||||
4 -> MaterialTheme.typography.titleLarge
|
||||
5 -> MaterialTheme.typography.titleMedium
|
||||
else -> MaterialTheme.typography.titleSmall
|
||||
1 -> MaterialTheme.typography.titleLarge
|
||||
2 -> MaterialTheme.typography.titleMedium
|
||||
3 -> MaterialTheme.typography.titleSmall
|
||||
4 -> MaterialTheme.typography.labelLarge
|
||||
5 -> MaterialTheme.typography.labelMedium
|
||||
else -> MaterialTheme.typography.labelSmall
|
||||
}
|
||||
) {
|
||||
ChildNodes(node, text, onTextChange)
|
||||
|
||||
@ -45,45 +45,6 @@ fun AnnotatedString.Builder.applyStyles(
|
||||
)
|
||||
}
|
||||
MarkdownElementTypes.ATX_1 -> {
|
||||
addStyle(
|
||||
typography.headlineLarge.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.headlineLarge.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_2 -> {
|
||||
addStyle(
|
||||
typography.headlineMedium.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.headlineMedium.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_3 -> {
|
||||
addStyle(
|
||||
typography.headlineSmall.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.headlineSmall.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_4 -> {
|
||||
addStyle(
|
||||
typography.titleLarge.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
@ -96,7 +57,7 @@ fun AnnotatedString.Builder.applyStyles(
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_5 -> {
|
||||
MarkdownElementTypes.ATX_2 -> {
|
||||
addStyle(
|
||||
typography.titleMedium.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
@ -109,7 +70,7 @@ fun AnnotatedString.Builder.applyStyles(
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_6 -> {
|
||||
MarkdownElementTypes.ATX_3 -> {
|
||||
addStyle(
|
||||
typography.titleSmall.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
@ -121,6 +82,45 @@ fun AnnotatedString.Builder.applyStyles(
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_4 -> {
|
||||
addStyle(
|
||||
typography.labelLarge.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.labelLarge.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_5 -> {
|
||||
addStyle(
|
||||
typography.labelMedium.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.labelMedium.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
|
||||
MarkdownElementTypes.ATX_6 -> {
|
||||
addStyle(
|
||||
typography.labelSmall.toSpanStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
node.endOffset - rootOffset,
|
||||
)
|
||||
addStyle(
|
||||
typography.labelSmall.toParagraphStyle(),
|
||||
node.startOffset - rootOffset,
|
||||
min(node.endOffset + 1 - rootOffset, length)
|
||||
)
|
||||
}
|
||||
}
|
||||
for (child in node.children) {
|
||||
applyStyles(child, typography, delimiterStyle, rootOffset)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user