Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/BuildConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

object BuildConstants {

const val VersionName = "3.0.0-alpha11"
const val VersionName = "3.0.0-alpha12"

const val Namespace = "com.moveagency.markymark"

const val MinSdk = 24
const val TargetSdk = 34
const val TargetSdk = 35
}
9 changes: 8 additions & 1 deletion detekt-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build:
excludeCorrectable: true
maxIssues: 10
maxIssues: 25

comments:
CommentOverPrivateFunction:
Expand Down Expand Up @@ -69,6 +69,7 @@ formatting:
naming:
BooleanPropertyNaming:
active: true
allowedPattern: '^[a-z][A-Za-z0-9]*$'
EnumNaming:
active: true
enumEntryPattern: '^(?:[A-Z]+[a-z0-9]+)[A-Za-z0-9]*$'
Expand Down Expand Up @@ -142,6 +143,12 @@ style:
ignoreAnnotated: [ 'Preview', 'Composable' ]
SerialVersionUIDInSerializableClass:
active: false
MaxLineLength:
active: true
maxLineLength: 120
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: true

compose:
ReusedModifierInstance:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ private fun rememberHighlights(language: SyntaxLanguage, code: String): Highligh
}
}

private val previewMarkdownContent = """
val someText = "I am text"

fun something() {
println(someText.clean())
}

fun String.clean() = trim()
""".trimIndent()

@Preview
@Composable
private fun PreviewCodeBlock() {
val node = CodeBlock(
metadata = Root,
content = """
val someText = "I am text"

fun something() {
println(someText.clean())
}

fun String.clean() = trim()
""".trimIndent(),
content = previewMarkdownContent,
language = "kotlin",
)

Expand All @@ -123,15 +125,7 @@ private fun PreviewCodeBlock() {
private fun PreviewCodeBlockNoLanguage() {
val node = CodeBlock(
metadata = Root,
content = """
val someText = "I am text"

fun something() {
println(someText.clean())
}

fun String.clean() = trim()
""".trimIndent(),
content = previewMarkdownContent,
language = null,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ private fun CaptionedImage(
}
}

private const val previewImageUrl = "https://images.unsplash.com/photo-1459262838948-3e2de6c1ec80?q=80&w=3269&auto=format" +
"&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"

@Preview
@Composable
private fun PreviewImage() {
val node = Image(
metadata = Root,
url = "https://images.unsplash.com/photo-1459262838948-3e2de6c1ec80?q=80&w=3269&auto=format&fit=crop&ixlib" +
"=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
url = previewImageUrl,
altText = "A cute koala",
title = null,
)
Expand All @@ -116,8 +118,7 @@ private fun PreviewImage() {
private fun PreviewImageCaptioned() {
val node = Image(
metadata = Root,
url = "https://images.unsplash.com/photo-1459262838948-3e2de6c1ec80?q=80&w=3269&auto=format&fit=crop&ixlib" +
"=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
url = previewImageUrl,
altText = "A cute koala",
title = "A cute koala in a tree",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private fun TaskIndicator(type: Task) {

@Preview
@Composable
fun PreviewOrderedListItem() {
private fun PreviewOrderedListItem() {
MarkyMarkListItem(
item = ListItem(
type = Ordered(index = 1),
Expand All @@ -263,7 +263,7 @@ fun PreviewOrderedListItem() {

@Preview
@Composable
fun PreviewUnorderedListItem() {
private fun PreviewUnorderedListItem() {
Column {
MarkyMarkListItem(
item = ListItem(
Expand Down Expand Up @@ -330,7 +330,7 @@ fun PreviewUnorderedListItem() {

@Preview
@Composable
fun PreviewUnorderedListItemCustom() {
private fun PreviewUnorderedListItemCustom() {
val theme = LocalMarkyMarkTheme.current
val previewTheme = remember(theme) {
markyMarkTheme {
Expand Down Expand Up @@ -597,7 +597,7 @@ fun PreviewUnorderedListItemCustom() {

@Preview
@Composable
fun PreviewTaskListItem() {
private fun PreviewTaskListItem() {
Column {
MarkyMarkListItem(
item = ListItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,23 @@ fun MarkyMarkQuote(
}
.padding(style.innerPadding)
) {
if (theme?.colors != null) {
CompositionLocalProvider(LocalMarkyMarkColors provides theme.colors) {
val parent = LocalMarkyMarkTheme.current.styles.composable
val inner = style.contentStyle?.invoke(parent) ?: parent

CompositionLocalProvider(
LocalMarkyMarkTheme provides LocalMarkyMarkTheme.current.copy(
styles = LocalMarkyMarkTheme.current.styles.copy(
composable = inner
)
)
) {
if (theme?.colors != null) {
CompositionLocalProvider(LocalMarkyMarkColors provides theme.colors) {
children()
}
} else {
children()
}
} else {
children()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ open class DefaultMarkyMarkComposer : MarkyMarkComposer {

@Composable
protected open fun Image(
modifier: Modifier,
node: Image,
modifier: Modifier,
) = MarkyMarkImage(
modifier = modifier.fillMaxWidth(),
node = node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ data class Headline(

/**
* The top-level heading, typically used for document titles or major section headings.
*
*
* __Syntax:__
*
* ```markdown
Expand All @@ -118,7 +118,7 @@ data class Headline(

/**
* Second-level heading, used for major sections within the document.
*
*
* __Syntax:__
*
* ```markdown
Expand All @@ -139,7 +139,7 @@ data class Headline(

/**
* Third-level heading, used for subsections within major sections.
*
*
* __Syntax:__
*
* ```markdown
Expand All @@ -153,7 +153,7 @@ data class Headline(

/**
* Fourth-level heading, used for smaller divisions within subsections.
*
*
* __Syntax:__
*
* ```markdown
Expand All @@ -167,7 +167,7 @@ data class Headline(

/**
* Fifth-level heading, used for fine-grained content organization.
*
*
* __Syntax:__
*
* ```markdown
Expand All @@ -181,7 +181,7 @@ data class Headline(

/**
* Sixth-level heading, the lowest level available in Markdown.
*
*
* __Syntax:__
*
* ```markdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ object MarkyMarkThemeDefaults {

indicator { shape = UnorderedListItemStyle.Indicator.Shape.Rectangle }

indicator { // Line
indicator { // Line
shape = UnorderedListItemStyle.Indicator.Shape.Rectangle
size = DpSize(width = 6.dp, height = 2.dp)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ data class HeadingsStyle(
h3 = builder.h3
h4 = builder.h4
h5 = builder.h5
h6 = builder.h6
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ data class UnorderedListItemStyle private constructor(
/**
* Builder for constructing the list of indicators for the unordered list item.
*/
private var indicators = UnorderedListIndicatorsBuilder()
private val indicators = UnorderedListIndicatorsBuilder()

/**
* Includes another [Builder] instance's configuration into `this` builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.moveagency.markymark.composable.MarkyMarkQuote
import com.moveagency.markymark.model.composable.BlockQuote
import com.moveagency.markymark.theme.ComposableStyles
import com.moveagency.markymark.theme.MarkyMarkThemeBuilderMarker
import com.moveagency.markymark.theme.Padding
import kotlinx.collections.immutable.ImmutableList
Expand All @@ -40,9 +41,9 @@ import kotlinx.collections.immutable.toImmutableList
* @property innerPadding The padding inside the block quote.
* @property outerPadding The padding outside the block quote, around the entire block.
* @property indicatorThickness The thickness of the block quote indicator, defined in [Dp].
* @property indicatorTint The color tint applied to the block quote indicator.
* @property themes A list of themes used for rendering the block quote's content.
* @property shape The shape of the block quote, such as a rectangle or other custom shape.
* @property contentStyle The composable style to be applied to the content inside the block quote.
*/
@Immutable
data class BlockQuoteStyle private constructor(
Expand All @@ -51,6 +52,7 @@ data class BlockQuoteStyle private constructor(
val indicatorThickness: Dp,
val themes: ImmutableList<BlockQuoteTheme>,
val shape: Shape,
val contentStyle: ((parent: ComposableStyles) -> ComposableStyles)? = null,
) {

/**
Expand All @@ -77,13 +79,18 @@ data class BlockQuoteStyle private constructor(
/**
* Builder for configuring the themes used for rendering the block quote's content.
*/
private var themes = BlockQuoteThemesBuilder()
private val themes = BlockQuoteThemesBuilder()

/**
* The shape of the block quote. Default is [RectangleShape].
*/
var shape: Shape = RectangleShape

/**
* The composable style applied to the content inside the code block. Default is an empty [ComposableStyles].
*/
var contentStyle: ((ComposableStyles) -> ComposableStyles)? = null

/**
* Includes another [Builder] instance's configuration into `this` builder.
*
Expand All @@ -97,6 +104,7 @@ data class BlockQuoteStyle private constructor(
indicatorThickness = builder.indicatorThickness
themes.include(builder.themes)
shape = builder.shape
contentStyle = builder.contentStyle
}

/**
Expand All @@ -112,6 +120,7 @@ data class BlockQuoteStyle private constructor(
indicatorThickness = style.indicatorThickness
themes.include(style.themes)
shape = style.shape
contentStyle = style.contentStyle
}

/**
Expand All @@ -135,17 +144,32 @@ data class BlockQuoteStyle private constructor(
*/
fun themes(block: BlockQuoteThemesBuilder.() -> Unit) = block(themes)

/**
* Configures the content style for the block quote.
*
* @param overrides A lambda to override the [ComposableStyles.Builder] for the content.
*/
fun contentStyle(overrides: ComposableStyles.Builder.() -> Unit) {
contentStyle = { parent ->
ComposableStyles.Builder().apply {
include(parent)
overrides()
}.build()
}
}

/**
* Builds a new [BlockQuoteStyle] instance with the current configuration.
*
* @return A [BlockQuoteStyle] object with the set properties for the block quote.
*/
internal fun build() = BlockQuoteStyle(
internal fun build(): BlockQuoteStyle = BlockQuoteStyle(
innerPadding = innerPadding.build(),
outerPadding = outerPadding.build(),
indicatorThickness = indicatorThickness,
themes = themes.build(),
shape = shape,
contentStyle = contentStyle
)
}

Expand Down
Loading