Skip to content

Commit f38b56f

Browse files
committed
Add partial support for sub and remove unused functions
1 parent f1fe495 commit f38b56f

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Make it so `width=100%` doesn't throw error. Fixes [#118](https://github.com/Sub6Resources/flutter_html/issues/118).
44
* You can now set width and/or height in `ImageProperties` to negative to ignore the `width` and/or `height` values from the html. Fixes [#97](https://github.com/Sub6Resources/flutter_html/issues/97)
55
* The `img` `alt` property now renders correctly when the image fails to load and with the correct style. Fixes [#96](https://github.com/Sub6Resources/flutter_html/issues/96)
6+
* Add partial support for `sub` tag.
67

78
## [0.10.4] - June 22, 2019:
89

lib/rich_text_parser.dart

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:convert';
2-
import 'dart:io';
32

43
import 'package:flutter/gestures.dart';
54
import 'package:flutter/material.dart';
@@ -224,6 +223,7 @@ class HtmlRichTextParser extends StatelessWidget {
224223
"time",
225224
"span",
226225
"big",
226+
"sub",
227227
];
228228

229229
// specialty elements require unique handling
@@ -523,6 +523,13 @@ class HtmlRichTextParser extends StatelessWidget {
523523
childStyle = childStyle.merge(
524524
TextStyle(backgroundColor: Colors.yellow, color: Colors.black));
525525
break;
526+
case "sub":
527+
childStyle = childStyle.merge(
528+
TextStyle(
529+
fontSize: childStyle.fontSize * OFFSET_TAGS_FONT_SIZE_FACTOR,
530+
),
531+
);
532+
break;
526533
case "del":
527534
case "s":
528535
case "strike":
@@ -958,39 +965,11 @@ class HtmlRichTextParser extends StatelessWidget {
958965
}
959966
}
960967

961-
Paint _getPaint(Color color) {
962-
Paint paint = new Paint();
963-
paint.color = color;
964-
return paint;
965-
}
966-
967968
String condenseHtmlWhitespace(String stringToTrim) {
968969
stringToTrim = stringToTrim.replaceAll("\n", " ");
969970
while (stringToTrim.indexOf(" ") != -1) {
970971
stringToTrim = stringToTrim.replaceAll(" ", " ");
971972
}
972973
return stringToTrim;
973974
}
974-
975-
bool _isNotFirstBreakTag(dom.Node node) {
976-
int index = node.parentNode.nodes.indexOf(node);
977-
if (index == 0) {
978-
if (node.parentNode == null) {
979-
return false;
980-
}
981-
return _isNotFirstBreakTag(node.parentNode);
982-
} else if (node.parentNode.nodes[index - 1] is dom.Element) {
983-
if ((node.parentNode.nodes[index - 1] as dom.Element).localName == "br") {
984-
return true;
985-
}
986-
return false;
987-
} else if (node.parentNode.nodes[index - 1] is dom.Text) {
988-
if ((node.parentNode.nodes[index - 1] as dom.Text).text.trim() == "") {
989-
return _isNotFirstBreakTag(node.parentNode.nodes[index - 1]);
990-
} else {
991-
return false;
992-
}
993-
}
994-
return false;
995-
}
996975
}

0 commit comments

Comments
 (0)