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:
41
lib/shared/widgets/markdown/latex_block_widget.dart
Normal file
41
lib/shared/widgets/markdown/latex_block_widget.dart
Normal 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user