Use dark background for inline code in markdown widget

This commit is contained in:
Héctor Ramón Jiménez 2024-07-28 13:15:04 +02:00
parent ddcf02f9d0
commit 4dc7b9b961
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 10 additions and 13 deletions

View file

@ -28,11 +28,8 @@ impl Markdown {
(
Self {
content: text_editor::Content::with_text(INITIAL_CONTENT),
items: markdown::parse(
INITIAL_CONTENT,
theme.extended_palette(),
)
.collect(),
items: markdown::parse(INITIAL_CONTENT, &theme.palette())
.collect(),
theme,
},
widget::focus_next(),
@ -49,7 +46,7 @@ impl Markdown {
if is_edit {
self.items = markdown::parse(
&self.content.text(),
self.theme.extended_palette(),
&self.theme.palette(),
)
.collect();
}

View file

@ -8,9 +8,8 @@ use crate::core::border;
use crate::core::font::{self, Font};
use crate::core::padding;
use crate::core::text::Background;
use crate::core::theme::palette;
use crate::core::theme::Theme;
use crate::core::{self, Element, Length, Pixels};
use crate::core::theme::{self, Theme};
use crate::core::{self, color, Color, Element, Length, Pixels};
use crate::{column, container, rich_text, row, scrollable, span, text};
pub use pulldown_cmark::HeadingLevel;
@ -39,7 +38,7 @@ pub enum Item {
/// Parse the given Markdown content.
pub fn parse<'a>(
markdown: &'a str,
palette: &'a palette::Extended,
palette: &'a theme::Palette,
) -> impl Iterator<Item = Item> + 'a {
struct List {
start: Option<u64>,
@ -250,7 +249,7 @@ pub fn parse<'a>(
};
let span = if let Some(link) = link.as_ref() {
span.color(palette.primary.base.color).link(link.clone())
span.color(palette.primary).link(link.clone())
} else {
span
};
@ -262,13 +261,14 @@ pub fn parse<'a>(
pulldown_cmark::Event::Code(code) if !metadata && !table => {
let span = span(code.into_string())
.font(Font::MONOSPACE)
.color(Color::WHITE)
.background(Background {
color: palette.background.weak.color,
color: color!(0x111111),
border: border::rounded(2),
});
let span = if let Some(link) = link.as_ref() {
span.color(palette.primary.base.color).link(link.clone())
span.color(palette.primary).link(link.clone())
} else {
span
};