removed print calls and fix no expect in test

pull/1955/head
CatHood0 10 months ago
parent bbdc68cd26
commit b66f8167b3
  1. 7
      lib/src/packages/quill_markdown/markdown_to_delta.dart
  2. 10
      lib/src/utils/html2md_utils.dart
  3. 7
      test/utils/delta_x_test.dart

@ -1,6 +1,5 @@
import 'dart:collection'; import 'dart:collection';
import 'dart:convert'; import 'dart:convert';
import 'dart:math';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:markdown/markdown.dart' as md; import 'package:markdown/markdown.dart' as md;
@ -125,7 +124,6 @@ class MarkdownToDelta extends Converter<String, Delta>
_topLevelNodes.addAll(mdNodes); _topLevelNodes.addAll(mdNodes);
for (final node in mdNodes) { for (final node in mdNodes) {
print(node.toString());
node.accept(this); node.accept(this);
} }
@ -178,8 +176,6 @@ class MarkdownToDelta extends Converter<String, Delta>
@override @override
bool visitElementBefore(md.Element element) { bool visitElementBefore(md.Element element) {
print(
'Visit before: [tag: ${element.tag}, attributes: ${element.attributes}]');
_insertNewLineBeforeElementIfNeeded(element); _insertNewLineBeforeElementIfNeeded(element);
final tag = element.tag; final tag = element.tag;
@ -212,9 +208,6 @@ class MarkdownToDelta extends Converter<String, Delta>
void visitElementAfter(md.Element element) { void visitElementAfter(md.Element element) {
final tag = element.tag; final tag = element.tag;
print(
'Visit after: [tag: ${element.tag}, attributes: ${element.attributes}]');
if (_isEmbedElement(element)) { if (_isEmbedElement(element)) {
_delta.insert(_toEmbeddable(element).toJson()); _delta.insert(_toEmbeddable(element).toJson());
} }

@ -6,6 +6,11 @@ import 'package:markdown/src/ast.dart' as ast;
import 'package:markdown/src/util.dart' as util; import 'package:markdown/src/util.dart' as util;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
// [ character
const int $lbracket = 0x5B;
final RegExp youtubeVideoUrlValidator = RegExp(
r'^(?:https?:)?(?:\/\/)?(?:youtu\.be\/|(?:www\.|m\.)?youtube\.com\/(?:watch|v|embed)(?:\.php)?(?:\?.*v=|\/))([a-zA-Z0-9\_-]{7,15})(?:[\?&][a-zA-Z0-9\_-]+=[a-zA-Z0-9\_-]+)*(?:[&\/\#].*)?$');
///Local syntax implementation for underline ///Local syntax implementation for underline
class UnderlineSyntax extends md.DelimiterSyntax { class UnderlineSyntax extends md.DelimiterSyntax {
UnderlineSyntax() UnderlineSyntax()
@ -17,11 +22,6 @@ class UnderlineSyntax extends md.DelimiterSyntax {
); );
} }
// [ character
const int $lbracket = 0x5B;
final RegExp youtubeVideoUrlValidator = RegExp(
r'^(?:https?:)?(?:\/\/)?(?:youtu\.be\/|(?:www\.|m\.)?youtube\.com\/(?:watch|v|embed)(?:\.php)?(?:\?.*v=|\/))([a-zA-Z0-9\_-]{7,15})(?:[\?&][a-zA-Z0-9\_-]+=[a-zA-Z0-9\_-]+)*(?:[&\/\#].*)?$');
class VideoSyntax extends md.LinkSyntax { class VideoSyntax extends md.LinkSyntax {
VideoSyntax({super.linkResolver}) VideoSyntax({super.linkResolver})
: super( : super(

@ -25,6 +25,11 @@ void main() {
Operation.insert('\n'), Operation.insert('\n'),
]); ]);
final expectedDeltaVideo = Delta.fromOperations([
Operation.insert({'video': 'https://www.youtube.com/embed/dQw4w9WgXcQ'}),
Operation.insert('\n'),
]);
test('should detect emphasis and parse correctly', () { test('should detect emphasis and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithEmp); final delta = DeltaX.fromHtml(htmlWithEmp);
expect(delta, expectedDeltaEmp); expect(delta, expectedDeltaEmp);
@ -37,6 +42,6 @@ void main() {
test('should detect video and parse correctly', () { test('should detect video and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithVideo); final delta = DeltaX.fromHtml(htmlWithVideo);
print(delta); expect(delta, expectedDeltaVideo);
}); });
} }

Loading…
Cancel
Save