refactor: enhance markdown processing and code structure

- Updated the ConduitMarkdown class to streamline markdown rendering, improving maintainability and clarity.
- Refactored the markdown configuration to utilize new methods for building markdown blocks and handling LaTeX syntax.
- Improved the StreamingMarkdownWidget to leverage the updated markdown processing logic, ensuring a cohesive user experience.
- Enhanced the handling of Mermaid diagrams and LaTeX rendering, providing better support for complex markdown content.
This commit is contained in:
cogwheel0
2025-10-04 16:04:49 +05:30
parent e04b43949b
commit 758ed411b0
6 changed files with 453 additions and 258 deletions

View File

@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import '../../theme/theme_extensions.dart';
class CodeBlockHeader extends StatelessWidget {
const CodeBlockHeader({
super.key,
required this.language,
required this.onCopy,
});
final String language;
final VoidCallback onCopy;
@override
Widget build(BuildContext context) {
final theme = context.conduitTheme;
final label = language.isEmpty ? 'code' : language;
return Container(
padding: const EdgeInsets.symmetric(
horizontal: Spacing.sm,
vertical: Spacing.xs,
),
decoration: BoxDecoration(
color: theme.surfaceContainer.withValues(alpha: 0.35),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppBorderRadius.sm),
),
),
child: Row(
children: [
Text(
label,
style: AppTypography.codeStyle.copyWith(
color: theme.textSecondary,
fontWeight: FontWeight.w600,
),
),
const Spacer(),
IconButton(
icon: const Icon(Icons.copy_rounded, size: 18),
color: theme.iconPrimary,
tooltip: 'Copy code',
onPressed: onCopy,
),
],
),
);
}
}