saminsohag

Table work arround added

@@ -134,8 +134,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex @@ -134,8 +134,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
134 width: 1, 134 width: 1,
135 color: Theme.of(context).colorScheme.outline), 135 color: Theme.of(context).colorScheme.outline),
136 ), 136 ),
137 - child:  
138 - LayoutBuilder(builder: (context, constraints) { 137 + child: LayoutBuilder(builder: (context, constraints) {
139 return Theme( 138 return Theme(
140 data: Theme.of(context).copyWith( 139 data: Theme.of(context).copyWith(
141 textTheme: const TextTheme( 140 textTheme: const TextTheme(
@@ -167,9 +166,8 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex @@ -167,9 +166,8 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
167 // Regular text font size here. 166 // Regular text font size here.
168 fontSize: 15, 167 fontSize: 15,
169 ), 168 ),
170 - latexWorkaround: (tex) =>  
171 - tex.replaceAllMapped(RegExp(r"align\*"),  
172 - (match) => "aligned"), 169 + latexWorkaround: (tex) => tex.replaceAllMapped(
  170 + RegExp(r"align\*"), (match) => "aligned"),
173 latexBuilder: (contex, tex) { 171 latexBuilder: (contex, tex) {
174 if (tex.contains(r"\begin{tabular}")) { 172 if (tex.contains(r"\begin{tabular}")) {
175 // return table. 173 // return table.
@@ -180,7 +178,12 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex @@ -180,7 +178,12 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
180 ).firstMatch(tex)?[1] ?? "").trim()}|"; 178 ).firstMatch(tex)?[1] ?? "").trim()}|";
181 tableString = tableString 179 tableString = tableString
182 .replaceAll(r"\\", "|\n|") 180 .replaceAll(r"\\", "|\n|")
183 - .replaceAll("&", "|"); 181 + .replaceAll(r"\hline", "")
  182 + .replaceAll(RegExp(r"(?<!\\)&"), "|");
  183 + var tableStringList = tableString
  184 + .split("\n")
  185 + ..insert(1, "|---|");
  186 + tableString = tableStringList.join("\n");
184 return TexMarkdown(tableString); 187 return TexMarkdown(tableString);
185 } 188 }
186 var controller = ScrollController(); 189 var controller = ScrollController();
@@ -102,17 +102,23 @@ class MdWidget extends StatelessWidget { @@ -102,17 +102,23 @@ class MdWidget extends StatelessWidget {
102 (index) { 102 (index) {
103 var e = entry.value; 103 var e = entry.value;
104 String data = e[index] ?? ""; 104 String data = e[index] ?? "";
105 - if (RegExp(r"^--+$").hasMatch(data.trim())) { 105 + if (RegExp(r"^--+$").hasMatch(data.trim()) ||
  106 + data.trim().isEmpty) {
106 return const SizedBox(); 107 return const SizedBox();
107 } 108 }
  109 +
108 return Center( 110 return Center(
109 - child: MdWidget(  
110 - (e[index] ?? "").trim(),  
111 - textDirection: textDirection,  
112 - onLinkTab: onLinkTab,  
113 - style: style,  
114 - latexWorkaround: latexWorkaround,  
115 - latexBuilder: latexBuilder, 111 + child: Padding(
  112 + padding: const EdgeInsets.symmetric(
  113 + horizontal: 8, vertical: 4),
  114 + child: MdWidget(
  115 + (e[index] ?? "").trim(),
  116 + textDirection: textDirection,
  117 + onLinkTab: onLinkTab,
  118 + style: style,
  119 + latexWorkaround: latexWorkaround,
  120 + latexBuilder: latexBuilder,
  121 + ),
116 ), 122 ),
117 ); 123 );
118 }, 124 },