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,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_math_fork/flutter_math.dart';
import '../../theme/theme_extensions.dart';
class LatexBlockWidget extends StatelessWidget {
const LatexBlockWidget({
super.key,
required this.content,
required this.isInline,
required this.style,
required this.isDark,
});
final String content;
final bool isInline;
final TextStyle style;
final bool isDark;
@override
Widget build(BuildContext context) {
final mathWidget = Math.tex(
content,
mathStyle: MathStyle.text,
textStyle: style,
textScaleFactor: 1,
onErrorFallback: (error) {
return Text(content, style: style.copyWith(color: Colors.red));
},
);
if (isInline) {
return mathWidget;
}
return Padding(
padding: const EdgeInsets.symmetric(vertical: Spacing.xs),
child: Center(child: mathWidget),
);
}
}