Skip to content

Commit 6ebc1ce

Browse files
Merge branch 'master' into master
2 parents 6962f11 + 913e277 commit 6ebc1ce

File tree

7 files changed

+193
-108
lines changed

7 files changed

+193
-108
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [0.10.0] - May 18, 2019:
2+
3+
* **BREAKING:** `useRichText` now defaults to `true`
4+
* Support for `aside`, `bdi`, `big`, `cite`, `data`, `ins`, `kbd`, `mark`, `nav`, `noscript`, `q`, `rp`, `rt`, `ruby`, `s`, `samp`, `strike`, `template`, `time`, `tt`, and `var` added to `RichText` parser.
5+
6+
## [0.9.9] - May 17, 2019:
7+
8+
* Fixes extra padding issue ([#87](https://github.com/Sub6Resources/flutter_html/issues/87))
9+
110
## [0.9.8] - May 14, 2019:
211

312
* Add support for `address` tag in `RichText` parser.
@@ -7,7 +16,7 @@
716
* Added onImageError callback
817
* Added custom textstyle and edgeinsets callback ([#72](https://github.com/Sub6Resources/flutter_html/pull/72))
918
* Update dependency versions ([#84](https://github.com/Sub6Resources/flutter_html/issues/84))
10-
* Fixes #82 and #86
19+
* Fixes [#82](https://github.com/Sub6Resources/flutter_html/issues/82) and [#86](https://github.com/Sub6Resources/flutter_html/issues/86)
1120

1221
## [0.9.6] - March 11, 2019:
1322

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Flutter widget for rendering static html tags as Flutter widgets. (Will render
99
Add the following to your `pubspec.yaml` file:
1010

1111
dependencies:
12-
flutter_html: ^0.9.8
12+
flutter_html: ^0.10.0
1313

1414
## Currently Supported HTML Tags:
1515
`a`, `abbr`, `acronym`, `address`, `article`, `aside`, `b`, `bdi`, `bdo`, `big`, `blockquote`, `body`, `br`, `caption`, `cite`, `code`, `data`, `dd`, `del`, `dfn`, `div`, `dl`, `dt`, `em`, `figcaption`, `figure`, `footer`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `header`, `hr`, `i`, `img`, `ins`, `kbd`, `li`, `main`, `mark`, `nav`, `noscript`, `ol`, `p`, `pre`, `q`, `rp`, `rt`, `ruby`, `s`, `samp`, `section`, `small`, `span`, `strike`, `strong`, `sub`, `sup`, `table`, `tbody`, `td`, `template`, `tfoot`, `th`, `thead`, `time`, `tr`, `tt`, `u`, `ul`, `var`

lib/flutter_html.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Html extends StatelessWidget {
1717
this.customEdgeInsets,
1818
this.customTextStyle,
1919
this.blockSpacing = 14.0,
20-
this.useRichText = false,
20+
this.useRichText = true,
2121
this.onImageError,
2222
this.linkStyle = const TextStyle(
2323
decoration: TextDecoration.underline,

lib/html_parser.dart

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,34 @@ class HtmlRichTextParser extends StatelessWidget {
175175
"b",
176176
"i",
177177
"address",
178+
"cite",
179+
"var",
178180
"em",
179181
"strong",
182+
"kbd",
183+
"samp",
184+
"tt",
180185
"code",
186+
"ins",
181187
"u",
182188
"small",
183189
"abbr",
184190
"acronym",
191+
"mark",
185192
"ol",
186193
"ul",
187194
"blockquote",
195+
"del",
196+
"s",
197+
"strike",
198+
"ruby",
199+
"rp",
200+
"rt",
201+
"bdi",
202+
"data",
203+
"time",
188204
"span",
205+
"big",
189206
];
190207

191208
// specialty elements require unique handling
@@ -203,6 +220,7 @@ class HtmlRichTextParser extends StatelessWidget {
203220
"th",
204221
"thead",
205222
"tr",
223+
"q",
206224
];
207225

208226
// block elements are always rendered with a new
@@ -211,6 +229,7 @@ class HtmlRichTextParser extends StatelessWidget {
211229
// we simply treat it as a new block level element
212230
static const _supportedBlockElements = [
213231
"article",
232+
"aside",
214233
"body",
215234
"center",
216235
"dd",
@@ -232,6 +251,8 @@ class HtmlRichTextParser extends StatelessWidget {
232251
"img",
233252
"li",
234253
"main",
254+
"nav",
255+
"noscript",
235256
"p",
236257
"pre",
237258
"section",
@@ -434,12 +455,18 @@ class HtmlRichTextParser extends StatelessWidget {
434455
break;
435456
case "i":
436457
case "address":
458+
case "cite":
459+
case "var":
437460
case "em":
438461
childStyle = childStyle.merge(TextStyle(fontStyle: FontStyle.italic));
439462
break;
463+
case "kbd":
464+
case "samp":
465+
case "tt":
440466
case "code":
441467
childStyle = childStyle.merge(TextStyle(fontFamily: 'monospace'));
442468
break;
469+
case "ins":
443470
case "u":
444471
childStyle = childStyle.merge(TextStyle(decoration: TextDecoration.underline));
445472
break;
@@ -450,8 +477,21 @@ class HtmlRichTextParser extends StatelessWidget {
450477
decorationStyle: TextDecorationStyle.dotted,
451478
));
452479
break;
480+
case "big":
481+
childStyle = childStyle.merge(TextStyle(fontSize: 20.0));
482+
break;
453483
case "small":
454-
childStyle = childStyle.merge(TextStyle(fontSize: 12.0));
484+
childStyle = childStyle.merge(TextStyle(fontSize: 10.0));
485+
break;
486+
case "mark":
487+
childStyle = childStyle.merge(
488+
TextStyle(backgroundColor: Colors.yellow, color: Colors.black));
489+
break;
490+
case "del":
491+
case "s":
492+
case "strike":
493+
childStyle = childStyle
494+
.merge(TextStyle(decoration: TextDecoration.lineThrough));
455495
break;
456496
case "ol":
457497
nextContext.indentLevel += 1;
@@ -469,6 +509,12 @@ class HtmlRichTextParser extends StatelessWidget {
469509
nextContext.indentLevel += 1;
470510
nextContext.blockType = 'blockquote';
471511
break;
512+
case "ruby":
513+
case "rt":
514+
case "rp":
515+
case "bdi":
516+
case "data":
517+
case "time":
472518
case "span":
473519
//No additional styles
474520
break;
@@ -597,6 +643,18 @@ class HtmlRichTextParser extends StatelessWidget {
597643
nextContext.parentElement.children.add(row);
598644
nextContext.parentElement = text.text;
599645
break;
646+
case "q":
647+
if (parseContext.parentElement != null &&
648+
parseContext.parentElement is TextSpan) {
649+
parseContext.parentElement.children
650+
.add(TextSpan(text: '"', children: []));
651+
TextSpan content = TextSpan(text: '', children: []);
652+
parseContext.parentElement.children.add(content);
653+
parseContext.parentElement.children
654+
.add(TextSpan(text: '"', children: []));
655+
nextContext.parentElement = content;
656+
}
657+
break;
600658
}
601659
}
602660

@@ -779,9 +837,14 @@ class HtmlRichTextParser extends StatelessWidget {
779837
));
780838
}
781839
BlockText blockText = BlockText(
782-
margin: _customEdgeInsets ??
783-
EdgeInsets.only(
784-
top: 8.0, bottom: 8.0, left: parseContext.indentLevel * indentSize),
840+
841+
margin: node.localName != 'body'
842+
? _customEdgeInsets ??
843+
EdgeInsets.only(
844+
top: 8.0,
845+
bottom: 8.0,
846+
left: parseContext.indentLevel * indentSize)
847+
: EdgeInsets.zero,
785848
padding: EdgeInsets.all(2.0),
786849
decoration: decoration,
787850
child: RichText(
@@ -806,30 +869,6 @@ class HtmlRichTextParser extends StatelessWidget {
806869
}
807870
}
808871

809-
// List<dynamic> _parseNodeList({
810-
// @required List<dom.Node> nodeList,
811-
// @required List<BlockText> rootWidgetList, // the widgetList accumulator
812-
// int parentIndex, // the parent spans list accumulator
813-
// int indentLevel = 0,
814-
// int listCount = 0,
815-
// String listChar = '•',
816-
// String blockType, // blockType can be 'p', 'div', 'ul', 'ol', 'blockquote'
817-
// bool condenseWhitespace = true,
818-
// }) {
819-
// return nodeList.map((node) {
820-
// return _parseNode(
821-
// node: node,
822-
// rootWidgetList: rootWidgetList,
823-
// parentIndex: parentIndex,
824-
// indentLevel: indentLevel,
825-
// listCount: listCount,
826-
// listChar: listChar,
827-
// blockType: blockType,
828-
// condenseWhitespace: condenseWhitespace,
829-
// );
830-
// }).toList();
831-
// }
832-
833872
Paint _getPaint(Color color) {
834873
Paint paint = new Paint();
835874
paint.color = color;

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages:
1414
name: async
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.2.0"
17+
version: "2.1.0"
1818
boolean_selector:
1919
dependency: transitive
2020
description:
@@ -101,7 +101,7 @@ packages:
101101
name: quiver
102102
url: "https://pub.dartlang.org"
103103
source: hosted
104-
version: "2.0.3"
104+
version: "2.0.2"
105105
sky_engine:
106106
dependency: transitive
107107
description: flutter
@@ -148,7 +148,7 @@ packages:
148148
name: test_api
149149
url: "https://pub.dartlang.org"
150150
source: hosted
151-
version: "0.2.5"
151+
version: "0.2.4"
152152
typed_data:
153153
dependency: transitive
154154
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_html
22
description: A Flutter widget for rendering static html tags as Flutter widgets. (Will render over 70 different html tags!)
3-
version: 0.9.8
3+
version: 0.10.0
44
author: Matthew Whitaker <sub6resources@gmail.com>
55
homepage: https://github.com/Sub6Resources/flutter_html
66

0 commit comments

Comments
 (0)