dart-lang / markdown

A Dart markdown library
https://pub.dev/packages/markdown
BSD 3-Clause "New" or "Revised" License
440 stars 200 forks source link

Github single tilde strikethrough #592

Closed robertoestivill closed 4 months ago

robertoestivill commented 4 months ago

I'm using this library through flutter_markdown and I'm having issues supporting single tilde ~ strikethrough.

From the Github Flavored Markdown specification I can see that single tilde should also produce strike through text.

Screenshot 2024-03-05 at 10 23 09
My reproducible example ```dart import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:markdown/markdown.dart' as md; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { const markdown = '~~this works~~ \n\n~this doesnt work~'; print( md.markdownToHtml( markdown, extensionSet: md.ExtensionSet.gitHubFlavored, ), ); return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: const Text( 'Markdown bug report\nSingle tildes not working', ), ), body: Markdown( data: markdown, extensionSet: md.ExtensionSet.gitHubFlavored, ), ), ); } } ```

Generates the following outputs

Screenshot 2024-03-05 at 10 55 37


Screenshot 2024-03-05 at 10 58 22

As you can see in the last console screenshot, the lack of <del> elements in the second line is the problem and the reason why I decided to create the bug in this repository instead of creating it in flutter_markdown.

flutter doctor ``` ➜ bugreport fvm flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale en-DE) [!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [!] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development. Download at: https://developer.apple.com/xcode/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] Connected device (2 available) [✓] Network resources ! Doctor found issues in 2 categories. ```

Any ideas? What am I missing? Cheers

srawlins commented 4 months ago

I think it's a bug. Reproduces at https://dart-lang.github.io/markdown/

And it appears we have only have unit tests for ~~. But the pattern that we use for StrikethroughSyntax is '~+' which should support single tildes. Not sure what's going on.