feat: Add Markdown preprocessing utility to standardize rendering across all views

- Create MarkdownUtils.preprocessMarkdown() for consistent Markdown normalization
- Apply preprocessing to LinkDetailsView description rendering
- Apply preprocessing to MarkdownPreview and MarkdownReader components
- Bump version to 1.4.0 (VERSION_CODE 13)
This commit is contained in:
Bruno Charest 2026-02-13 08:29:48 -05:00
parent aa32ff1c2b
commit fc0fe3b30b
4 changed files with 27 additions and 6 deletions

View File

@ -0,0 +1,19 @@
package com.shaarit.core.util
/**
* Prétraitement du Markdown pour corriger l'affichage des éléments
* non supportés nativement par compose-markdown (checkboxes, etc.)
*/
object MarkdownUtils {
/**
* Convertit les checkboxes Markdown (- [ ] et - [x]) en caractères Unicode visuels.
* Gère aussi les variantes avec * au lieu de -.
*/
fun preprocessMarkdown(markdown: String): String {
return markdown
.replace(Regex("""^(\s*[-*])\s+\[x]\s""", RegexOption.MULTILINE), "$1 ☑ ")
.replace(Regex("""^(\s*[-*])\s+\[X]\s""", RegexOption.MULTILINE), "$1 ☑ ")
.replace(Regex("""^(\s*[-*])\s+\[ ]\s""", RegexOption.MULTILINE), "$1 ☐ ")
}
}

View File

@ -44,6 +44,7 @@ import com.shaarit.ui.components.GlassCard
import com.shaarit.ui.components.TagChip import com.shaarit.ui.components.TagChip
import com.shaarit.ui.theme.Typography import com.shaarit.ui.theme.Typography
import dev.jeziellago.compose.markdowntext.MarkdownText import dev.jeziellago.compose.markdowntext.MarkdownText
import com.shaarit.core.util.MarkdownUtils
import coil.compose.AsyncImage import coil.compose.AsyncImage
import coil.request.ImageRequest import coil.request.ImageRequest
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
@ -960,7 +961,7 @@ fun LinkDetailsView(
// Description // Description
if (link.description.isNotBlank()) { if (link.description.isNotBlank()) {
MarkdownText( MarkdownText(
markdown = link.description, markdown = MarkdownUtils.preprocessMarkdown(link.description),
style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.onBackground), style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.onBackground),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) )

View File

@ -42,6 +42,7 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex import androidx.compose.ui.zIndex
import com.shaarit.ui.theme.Typography import com.shaarit.ui.theme.Typography
import dev.jeziellago.compose.markdowntext.MarkdownText import dev.jeziellago.compose.markdowntext.MarkdownText
import com.shaarit.core.util.MarkdownUtils
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -657,7 +658,7 @@ fun MarkdownPreview(
) )
} else { } else {
MarkdownText( MarkdownText(
markdown = markdown, markdown = MarkdownUtils.preprocessMarkdown(markdown),
color = MaterialTheme.colorScheme.onBackground, color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) )
@ -901,7 +902,7 @@ fun MarkdownReader(
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
) { ) {
MarkdownText( MarkdownText(
markdown = markdown, markdown = MarkdownUtils.preprocessMarkdown(markdown),
color = androidx.compose.ui.graphics.Color.White, color = androidx.compose.ui.graphics.Color.White,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) )

View File

@ -1,3 +1,3 @@
#Thu Feb 12 12:09:07 2026 #Thu Feb 12 20:32:53 2026
VERSION_NAME=1.3.0 VERSION_NAME=1.4.0
VERSION_CODE=12 VERSION_CODE=13