Skip to content

Commit 1b3506b

Browse files
committed
Version 0.10.0
1 parent 3bb61b2 commit 1b3506b

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
16
## [0.9.9] - May 17, 2019:
27

38
* Fixes extra padding issue ([#87](https://github.com/Sub6Resources/flutter_html/issues/87))

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.9
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
@@ -16,7 +16,7 @@ class Html extends StatelessWidget {
1616
this.customEdgeInsets,
1717
this.customTextStyle,
1818
this.blockSpacing = 14.0,
19-
this.useRichText = false,
19+
this.useRichText = true,
2020
this.onImageError,
2121
this.linkStyle = const TextStyle(
2222
decoration: TextDecoration.underline,

lib/html_parser.dart

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,34 @@ class HtmlRichTextParser extends StatelessWidget {
177177
"b",
178178
"i",
179179
"address",
180+
"cite",
181+
"var",
180182
"em",
181183
"strong",
184+
"kbd",
185+
"samp",
186+
"tt",
182187
"code",
188+
"ins",
183189
"u",
184190
"small",
185191
"abbr",
186192
"acronym",
193+
"mark",
187194
"ol",
188195
"ul",
189196
"blockquote",
197+
"del",
198+
"s",
199+
"strike",
200+
"ruby",
201+
"rp",
202+
"rt",
203+
"bdi",
204+
"data",
205+
"time",
190206
"span",
207+
"big",
191208
];
192209

193210
// specialty elements require unique handling
@@ -205,6 +222,7 @@ class HtmlRichTextParser extends StatelessWidget {
205222
"th",
206223
"thead",
207224
"tr",
225+
"q",
208226
];
209227

210228
// block elements are always rendered with a new
@@ -213,6 +231,7 @@ class HtmlRichTextParser extends StatelessWidget {
213231
// we simply treat it as a new block level element
214232
static const _supportedBlockElements = [
215233
"article",
234+
"aside",
216235
"body",
217236
"center",
218237
"dd",
@@ -234,6 +253,8 @@ class HtmlRichTextParser extends StatelessWidget {
234253
"img",
235254
"li",
236255
"main",
256+
"nav",
257+
"noscript",
237258
"p",
238259
"pre",
239260
"section",
@@ -448,13 +469,19 @@ class HtmlRichTextParser extends StatelessWidget {
448469
break;
449470
case "i":
450471
case "address":
472+
case "cite":
473+
case "var":
451474
case "em":
452475
childStyle =
453476
childStyle.merge(TextStyle(fontStyle: FontStyle.italic));
454477
break;
478+
case "kbd":
479+
case "samp":
480+
case "tt":
455481
case "code":
456482
childStyle = childStyle.merge(TextStyle(fontFamily: 'monospace'));
457483
break;
484+
case "ins":
458485
case "u":
459486
childStyle = childStyle
460487
.merge(TextStyle(decoration: TextDecoration.underline));
@@ -466,8 +493,19 @@ class HtmlRichTextParser extends StatelessWidget {
466493
decorationStyle: TextDecorationStyle.dotted,
467494
));
468495
break;
496+
case "big":
497+
childStyle = childStyle.merge(TextStyle(fontSize: 20.0));
498+
break;
469499
case "small":
470-
childStyle = childStyle.merge(TextStyle(fontSize: 12.0));
500+
childStyle = childStyle.merge(TextStyle(fontSize: 10.0));
501+
break;
502+
case "mark":
503+
childStyle = childStyle.merge(TextStyle(backgroundColor: Colors.yellow, color: Colors.black));
504+
break;
505+
case "del":
506+
case "s":
507+
case "strike":
508+
childStyle = childStyle.merge(TextStyle(decoration: TextDecoration.lineThrough));
471509
break;
472510
case "ol":
473511
nextContext.indentLevel += 1;
@@ -485,6 +523,12 @@ class HtmlRichTextParser extends StatelessWidget {
485523
nextContext.indentLevel += 1;
486524
nextContext.blockType = 'blockquote';
487525
break;
526+
case "ruby":
527+
case "rt":
528+
case "rp":
529+
case "bdi":
530+
case "data":
531+
case "time":
488532
case "span":
489533
//No additional styles
490534
break;
@@ -621,6 +665,17 @@ class HtmlRichTextParser extends StatelessWidget {
621665
nextContext.parentElement.children.add(row);
622666
nextContext.parentElement = text.text;
623667
break;
668+
case "q":
669+
if (parseContext.parentElement != null &&
670+
parseContext.parentElement is TextSpan) {
671+
parseContext.parentElement.children
672+
.add(TextSpan(text: '"', children: []));
673+
TextSpan content = TextSpan(text: '', children: []);
674+
parseContext.parentElement.children.add(content);
675+
parseContext.parentElement.children.add(TextSpan(text: '"', children: []));
676+
nextContext.parentElement = content;
677+
}
678+
break;
624679
}
625680
}
626681

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.9
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)