saminsohag

Table heading color added

... ... @@ -122,8 +122,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
child: ListView(
children: [
AnimatedBuilder(
animation: _controller,
... ... @@ -172,6 +171,18 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
tex.replaceAllMapped(RegExp(r"align\*"),
(match) => "aligned"),
latexBuilder: (contex, tex) {
if (tex.contains(r"\begin{tabular}")) {
// return table.
String tableString = "|${(RegExp(
r"^\\begin\{tabular\}\{.*?\}(.*?)\\end\{tabular\}$",
multiLine: true,
dotAll: true,
).firstMatch(tex)?[1] ?? "").trim()}|";
tableString = tableString
.replaceAll(r"\\", "|\n|")
.replaceAll("&", "|");
return TexMarkdown(tableString);
}
var controller = ScrollController();
return Column(
children: [
... ... @@ -201,7 +212,6 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
],
),
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200),
child: Padding(
... ...
... ... @@ -58,6 +58,8 @@ class MdWidget extends StatelessWidget {
.asMap(),
)
.toList();
bool heading =
RegExp(r"^\|.*?\|\n\|-[-\\ |]*?-\|\n").hasMatch(eachLn.trim());
int maxCol = 0;
for (final each in value) {
if (maxCol < each.keys.length) {
... ... @@ -80,11 +82,23 @@ class MdWidget extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurface,
),
children: value
.asMap()
.entries
.map<TableRow>(
(e) => TableRow(
(entry) => TableRow(
decoration: (heading)
? BoxDecoration(
color: (entry.key == 0)
? Theme.of(context)
.colorScheme
.surfaceVariant
: null,
)
: null,
children: List.generate(
maxCol,
(index) {
var e = entry.value;
String data = e[index] ?? "";
if (RegExp(r"^---+$").hasMatch(data.trim())) {
return const SizedBox();
... ...