mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
Rename markdownToPlainText -> stripMarkdownFormatting
It better reflects what the function actually does
This commit is contained in:
@ -44,7 +44,7 @@ class MarkdownBuilder implements md.NodeVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String markdownToPlainText(String markdown) {
|
String stripMarkdownFormatting(String markdown) {
|
||||||
final List<String> lines = markdown.replaceAll('\r\n', '\n').split('\n');
|
final List<String> lines = markdown.replaceAll('\r\n', '\n').split('\n');
|
||||||
var doc = md.Document(encodeHtml: false);
|
var doc = md.Document(encodeHtml: false);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class JournalList extends StatelessWidget {
|
|||||||
title = basename(journal.filePath);
|
title = basename(journal.filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var body = markdownToPlainText(journal.body);
|
var body = stripMarkdownFormatting(journal.body);
|
||||||
|
|
||||||
var textTheme = Theme.of(context).textTheme;
|
var textTheme = Theme.of(context).textTheme;
|
||||||
var children = <Widget>[];
|
var children = <Widget>[];
|
||||||
|
@ -2,10 +2,10 @@ import 'package:journal/utils/markdown.dart';
|
|||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Markdown To Text', () {
|
group('Markdown Remove Formatting', () {
|
||||||
test('Test Headers', () {
|
test('Test Headers', () {
|
||||||
var input = '# Hello\nHow are you?';
|
var input = '# Hello\nHow are you?';
|
||||||
expect(markdownToPlainText(input), 'Hello How are you?');
|
expect(stripMarkdownFormatting(input), 'Hello How are you?');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Test Header2', () {
|
test('Test Header2', () {
|
||||||
@ -15,7 +15,7 @@ void main() {
|
|||||||
Hello
|
Hello
|
||||||
""";
|
""";
|
||||||
|
|
||||||
expect(markdownToPlainText(input), 'Test Header Hello');
|
expect(stripMarkdownFormatting(input), 'Test Header Hello');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Itemized LIsts', () {
|
test('Itemized LIsts', () {
|
||||||
@ -26,7 +26,7 @@ look like:
|
|||||||
* that one
|
* that one
|
||||||
""";
|
""";
|
||||||
|
|
||||||
expect(markdownToPlainText(input),
|
expect(stripMarkdownFormatting(input),
|
||||||
'Itemized lists look like: this one that one');
|
'Itemized lists look like: this one that one');
|
||||||
});
|
});
|
||||||
});
|
});
|
Reference in New Issue
Block a user