Skip to content

Commit a34d3bf

Browse files
committed
Update changelong and some last minute fixes
1 parent b9fc0cb commit a34d3bf

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

PRE_CHANGELOG.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@ This changelog highlights changes as we work to implement version 1.0.0.
22

33

44
# [1.0.0-pre.1]
5-
* BREAKING CHANGES (most of these are temporary):
5+
* BREAKING CHANGES (see the [Migration Guide](https://github.com/Sub6Resources/flutter_html/wiki/1.0.0-Migration-Guide) for a full overview of breaking changes.):
6+
* The default parser has been completely rewritten and the RichText parser has been deprecated.
67
* `useRichText` now defaults to `false` (the new parser uses RichText, though)
7-
* `customRender` no longer does anything (just for now).
8-
* `img` `alt` tags are no longer rendered.
9-
* `table` is no longer supported.
10-
* `sub` and `sup` are no longer correctly rendered.
11-
* `HtmlParser` has been entirely rewritten. (It now uses `RichText` extensively)
8+
* `customRender` now works for the default parser.
9+
* Adds support for `<audio>`, `<video>`, `<iframe>`, `<svg>`, `<ruby>`, `<rt>`, `<rp>`, `<sub>`, and `<sup>`
10+
* Adds support for over 20 CSS attributes.
11+
* Fixes 22 issues (see the list at [#122](https://github.com/Sub6Resources/flutter_html/pull/122))
1212
* The following parameters of `Html` have been deprecated and should no longer be used:
1313
* `useRichText`
1414
* `padding`
1515
* `backgroundColor`
1616
* `defaultTextStyle`
17+
* `renderNewlines`
1718
* `customEdgeInsets`
1819
* `customTextStyle`
1920
* `blockSpacing`
21+
* `customTextAlign`
2022
* `linkStyle`
23+
* `imageProperties`
24+
* `showImages`
2125
* The default text style now matches the app's Material `TextTheme.body1` (Fixes [#18](https://github.com/Sub6Resources/flutter_html/issues/18)).
2226
* Fixed quite a few issues with `img`
2327
* Added a fancy new `style` attribute (this should be used in place of the deprecated styling parameters).
24-
* Added an even fancier new `css` attribute that takes a CSS string and applies those styles to your widgets.
2528

2629

lib/html_parser.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,11 @@ class HtmlParser extends StatelessWidget {
595595
/// [removeEmptyElements] recursively removes empty elements.
596596
///
597597
/// An empty element is any [EmptyContentElement], any empty [TextContentElement],
598-
/// or any block-level [TextContentElement] that contains only whitespace.
598+
/// or any block-level [TextContentElement] that contains only whitespace and doesn't follow
599+
/// a block element or a line break.
599600
static StyledElement _removeEmptyElements(StyledElement tree) {
600601
List<StyledElement> toRemove = new List<StyledElement>();
602+
bool lastChildBlock = true;
601603
tree.children?.forEach((child) {
602604
if (child is EmptyContentElement) {
603605
toRemove.add(child);
@@ -606,11 +608,17 @@ class HtmlParser extends StatelessWidget {
606608
} else if (child is TextContentElement &&
607609
child.style.whiteSpace != WhiteSpace.PRE &&
608610
tree.style.display == Display.BLOCK &&
609-
child.text.trim().isEmpty) {
611+
child.text.trim().isEmpty &&
612+
lastChildBlock) {
610613
toRemove.add(child);
611614
} else {
612615
_removeEmptyElements(child);
613616
}
617+
618+
// This is used above to check if the previous element is a block element or a line break.
619+
lastChildBlock = (child.style.display == Display.BLOCK ||
620+
child.style.display == Display.LIST_ITEM ||
621+
(child is TextContentElement && child.text == '\n'));
614622
});
615623
tree.children?.removeWhere((element) => toRemove.contains(element));
616624

lib/src/replaced_element.dart

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,23 @@ class ImageContentElement extends ReplacedElement {
133133
);
134134
}
135135

136-
return RawGestureDetector(
137-
child: imageWidget,
138-
gestures: {
139-
MultipleTapGestureRecognizer:
140-
GestureRecognizerFactoryWithHandlers<MultipleTapGestureRecognizer>(
141-
() => MultipleTapGestureRecognizer(),
142-
(instance) {
143-
instance..onTap = () => context.parser.onImageTap?.call(src);
144-
},
145-
),
146-
},
136+
return ContainerSpan(
137+
style: style,
138+
newContext: context,
139+
shrinkWrap: context.parser.shrinkWrap,
140+
child: RawGestureDetector(
141+
child: imageWidget,
142+
gestures: {
143+
MultipleTapGestureRecognizer: GestureRecognizerFactoryWithHandlers<
144+
MultipleTapGestureRecognizer>(
145+
() => MultipleTapGestureRecognizer(),
146+
(instance) {
147+
instance..onTap = () => context.parser.onImageTap?.call(src);
148+
},
149+
),
150+
},
151+
),
147152
);
148-
return imageWidget;
149153
}
150154
}
151155

@@ -303,7 +307,7 @@ class RubyElement extends ReplacedElement {
303307

304308
@override
305309
Widget toWidget(RenderContext context) {
306-
dom.Node textNode = null;
310+
dom.Node textNode;
307311
List<Widget> widgets = List<Widget>();
308312
//TODO calculate based off of parent font size.
309313
final rubySize = max(9.0, context.style.fontSize.size / 2);

lib/src/styled_element.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ StyledElement parseStyledElement(
349349
verticalAlign: VerticalAlign.SUPER,
350350
);
351351
break;
352+
case "th":
353+
continue bold;
352354
case "tt":
353355
continue monospace;
354356
underline:

0 commit comments

Comments
 (0)