nausharipov commented on code in PR #23662:
URL: https://github.com/apache/beam/pull/23662#discussion_r997859535


##########
learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit_content.dart:
##########
@@ -30,6 +32,76 @@ class UnitContentWidget extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    return MarkdownBody(data: unitContent.description);
+    final textTheme = Theme.of(context).textTheme;
+    final markdownStyle = MarkdownStyleSheet(
+      h1: textTheme.headlineLarge,
+      h3: textTheme.headlineMedium,
+      p: textTheme.bodyMedium,
+      code: Theme.of(context)
+          .extension<BeamThemeExtension>()!
+          .codeRootStyle
+          .copyWith(
+            backgroundColor: BeamColors.transparent,
+            fontSize: BeamSizes.size12,
+          ),
+      codeblockDecoration: BoxDecoration(
+        // TODO(nausharipov): where to store these colors?
+        color: Theme.of(context).brightness == Brightness.dark
+            ? BeamDarkThemeColors.codeBackground
+            : BeamLightThemeColors.codeBackground,
+        border: Border.all(color: Theme.of(context).primaryColor),
+        borderRadius: const BorderRadius.all(
+          Radius.circular(BeamSizes.size4),
+        ),
+      ),
+    );
+
+    return Markdown(
+      selectable: true,
+      data: unitContent.description,
+      builders: {
+        'code': CodeBuilder(),
+      },
+      styleSheet: markdownStyle,
+    );
+  }
+}
+
+class CodeBuilder extends MarkdownElementBuilder {
+  @override
+  Widget? visitElementAfter(md.Element element, TextStyle? preferredStyle) {
+    final String textContent = element.textContent;
+    final bool isMultilineCode = textContent.contains('\n');

Review Comment:
   I couldn't find a way to check for the number of backticks in 
`MarkdownElementBuilder`. 
   
   <img width="864" alt="Screen Shot 2022-10-18 at 13 31 51" 
src="https://user-images.githubusercontent.com/31556582/196365565-90f1d44e-08c0-467b-94f9-e35e1d419262.png";>
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to