Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SuperEditorMarkdown] Attributions not placed according to markdown standard when serializing document (#2424) #2452

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions super_editor_markdown/test/attributed_text_markdown_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,75 @@ void main() {
"This is **ove*rla**pping* styles.",
);
});

test("First character in the attribution span is white space", () {
expect(
AttributedText(
// b b
"This is bold text.",
AttributedSpans(
attributions: [
const SpanMarker(attribution: boldAttribution, offset: 7, markerType: SpanMarkerType.start),
const SpanMarker(attribution: boldAttribution, offset: 11, markerType: SpanMarkerType.end),
],
),
).toMarkdown(),
"This is **bold** text.",
);
});

test("Last character in the attribution span is white space", () {
expect(
AttributedText(
// b b
"This is bold text.",
AttributedSpans(
attributions: [
const SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start),
const SpanMarker(attribution: boldAttribution, offset: 12, markerType: SpanMarkerType.end),
],
),
).toMarkdown(),
"This is **bold** text.",
);
});

test("First and last character in overlapping attribution spans is white space", () {
expect(
AttributedText(
// b b
// i i
"This is bold text.",
AttributedSpans(
attributions: [
const SpanMarker(attribution: boldAttribution, offset: 7, markerType: SpanMarkerType.start),
const SpanMarker(attribution: boldAttribution, offset: 12, markerType: SpanMarkerType.end),
const SpanMarker(attribution: italicsAttribution, offset: 7, markerType: SpanMarkerType.start),
const SpanMarker(attribution: italicsAttribution, offset: 12, markerType: SpanMarkerType.end),
],
),
).toMarkdown(),
"This is ***bold*** text.",
);
});

test("First and last character in one attribution span is white space", () {
expect(
AttributedText(
// b b
// i i
"This is bold text.",
AttributedSpans(
attributions: [
const SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start),
const SpanMarker(attribution: boldAttribution, offset: 11, markerType: SpanMarkerType.end),
const SpanMarker(attribution: italicsAttribution, offset: 7, markerType: SpanMarkerType.start),
const SpanMarker(attribution: italicsAttribution, offset: 12, markerType: SpanMarkerType.end),
],
),
).toMarkdown(),
"This is ***bold*** text.",
);
});
});
}
Loading