Showing
2 changed files
with
16 additions
and
7 deletions
| @@ -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,10 +102,15 @@ class MdWidget extends StatelessWidget { | @@ -102,10 +102,15 @@ 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( |
| 111 | + child: Padding( | ||
| 112 | + padding: const EdgeInsets.symmetric( | ||
| 113 | + horizontal: 8, vertical: 4), | ||
| 109 | child: MdWidget( | 114 | child: MdWidget( |
| 110 | (e[index] ?? "").trim(), | 115 | (e[index] ?? "").trim(), |
| 111 | textDirection: textDirection, | 116 | textDirection: textDirection, |
| @@ -114,6 +119,7 @@ class MdWidget extends StatelessWidget { | @@ -114,6 +119,7 @@ class MdWidget extends StatelessWidget { | ||
| 114 | latexWorkaround: latexWorkaround, | 119 | latexWorkaround: latexWorkaround, |
| 115 | latexBuilder: latexBuilder, | 120 | latexBuilder: latexBuilder, |
| 116 | ), | 121 | ), |
| 122 | + ), | ||
| 117 | ); | 123 | ); |
| 118 | }, | 124 | }, |
| 119 | ), | 125 | ), |
-
Please register or login to post a comment