Markdown support in recipe ingredients, instructions and tools

This commit is contained in:
VincentMeilinger
2025-05-26 17:30:36 +02:00
parent b66ef63b6a
commit 6cecdcf1fd
6 changed files with 51 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ struct RecipeListSection: View {
ForEach(list, id: \.self) { item in
HStack(alignment: .top) {
Text("\u{2022}")
Text("\(item)")
Text(ObservableRecipeDetail.applyMarkdownStyling(item))
.multilineTextAlignment(.leading)
}
.padding(4)

View File

@@ -129,7 +129,7 @@ fileprivate struct IngredientListItem: View {
.foregroundStyle(.red)
}
if unmodified {
Text(ingredient)
Text(ObservableRecipeDetail.applyMarkdownStyling(ingredient))
.multilineTextAlignment(.leading)
.lineLimit(5)
} else {
@@ -142,9 +142,9 @@ fileprivate struct IngredientListItem: View {
}
.onChange(of: servings) { newServings in
if recipeYield == 0 {
modifiedIngredient = ObservableRecipeDetail.adjustIngredient(ingredient, by: newServings)
modifiedIngredient = ObservableRecipeDetail.adjustIngredient(ObservableRecipeDetail.applyMarkdownStyling(ingredient), by: newServings)
} else {
modifiedIngredient = ObservableRecipeDetail.adjustIngredient(ingredient, by: newServings/recipeYield)
modifiedIngredient = ObservableRecipeDetail.adjustIngredient(ObservableRecipeDetail.applyMarkdownStyling(ingredient), by: newServings/recipeYield)
}
}
.foregroundStyle(isSelected ? Color.secondary : Color.primary)

View File

@@ -47,7 +47,7 @@ fileprivate struct RecipeInstructionListItem: View {
HStack(alignment: .top) {
Text("\(index)")
.monospaced()
Text(instruction)
Text(ObservableRecipeDetail.applyMarkdownStyling(instruction))
}.padding(4)
.foregroundStyle(isSelected ? Color.secondary : Color.primary)
.onTapGesture {