Showing
4 changed files
with
29 additions
and
5 deletions
| @@ -238,15 +238,15 @@ packages: | @@ -238,15 +238,15 @@ packages: | ||
| 238 | path: ".." | 238 | path: ".." |
| 239 | relative: true | 239 | relative: true |
| 240 | source: path | 240 | source: path |
| 241 | - version: "0.1.2" | 241 | + version: "0.1.4" |
| 242 | tex_text: | 242 | tex_text: |
| 243 | dependency: transitive | 243 | dependency: transitive |
| 244 | description: | 244 | description: |
| 245 | name: tex_text | 245 | name: tex_text |
| 246 | - sha256: "46942a9587170f5130d2f7110083abd4335b66d763b0cf6a241c80e74826d71d" | 246 | + sha256: "67e06376b479ab48e8cb2b49e6eafc57f830976bc25bdf791ded089ac989937c" |
| 247 | url: "https://pub.dev" | 247 | url: "https://pub.dev" |
| 248 | source: hosted | 248 | source: hosted |
| 249 | - version: "0.1.5" | 249 | + version: "0.1.7" |
| 250 | tuple: | 250 | tuple: |
| 251 | dependency: transitive | 251 | dependency: transitive |
| 252 | description: | 252 | description: |
| @@ -17,6 +17,8 @@ abstract class MarkdownComponent { | @@ -17,6 +17,8 @@ abstract class MarkdownComponent { | ||
| 17 | HrLine(), | 17 | HrLine(), |
| 18 | TextMd(), | 18 | TextMd(), |
| 19 | ]; | 19 | ]; |
| 20 | + | ||
| 21 | + /// Convert markdown to html | ||
| 20 | static String toHtml(String text) { | 22 | static String toHtml(String text) { |
| 21 | String html = ""; | 23 | String html = ""; |
| 22 | text.split(RegExp(r"\n+")).forEach((element) { | 24 | text.split(RegExp(r"\n+")).forEach((element) { |
| @@ -35,6 +37,7 @@ abstract class MarkdownComponent { | @@ -35,6 +37,7 @@ abstract class MarkdownComponent { | ||
| 35 | return html; | 37 | return html; |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 40 | + /// Generate widget for markdown widget | ||
| 38 | static Widget generate( | 41 | static Widget generate( |
| 39 | BuildContext context, | 42 | BuildContext context, |
| 40 | String text, | 43 | String text, |
| @@ -103,6 +106,7 @@ abstract class MarkdownComponent { | @@ -103,6 +106,7 @@ abstract class MarkdownComponent { | ||
| 103 | bool get inline; | 106 | bool get inline; |
| 104 | } | 107 | } |
| 105 | 108 | ||
| 109 | +/// Inline component | ||
| 106 | abstract class InlineMd extends MarkdownComponent { | 110 | abstract class InlineMd extends MarkdownComponent { |
| 107 | @override | 111 | @override |
| 108 | bool get inline => true; | 112 | bool get inline => true; |
| @@ -115,6 +119,7 @@ abstract class InlineMd extends MarkdownComponent { | @@ -115,6 +119,7 @@ abstract class InlineMd extends MarkdownComponent { | ||
| 115 | String toHtml(String text); | 119 | String toHtml(String text); |
| 116 | } | 120 | } |
| 117 | 121 | ||
| 122 | +/// Block component | ||
| 118 | abstract class BlockMd extends MarkdownComponent { | 123 | abstract class BlockMd extends MarkdownComponent { |
| 119 | @override | 124 | @override |
| 120 | bool get inline => false; | 125 | bool get inline => false; |
| @@ -127,6 +132,7 @@ abstract class BlockMd extends MarkdownComponent { | @@ -127,6 +132,7 @@ abstract class BlockMd extends MarkdownComponent { | ||
| 127 | String toHtml(String text); | 132 | String toHtml(String text); |
| 128 | } | 133 | } |
| 129 | 134 | ||
| 135 | +/// Heading component | ||
| 130 | class HTag extends BlockMd { | 136 | class HTag extends BlockMd { |
| 131 | @override | 137 | @override |
| 132 | final RegExp exp = RegExp(r"^(#{1,6})\s([^\n]+)$"); | 138 | final RegExp exp = RegExp(r"^(#{1,6})\s([^\n]+)$"); |
| @@ -191,6 +197,7 @@ class HTag extends BlockMd { | @@ -191,6 +197,7 @@ class HTag extends BlockMd { | ||
| 191 | } | 197 | } |
| 192 | } | 198 | } |
| 193 | 199 | ||
| 200 | +/// Horizontal line component | ||
| 194 | class HrLine extends BlockMd { | 201 | class HrLine extends BlockMd { |
| 195 | @override | 202 | @override |
| 196 | final RegExp exp = RegExp(r"^(--)[-]+$"); | 203 | final RegExp exp = RegExp(r"^(--)[-]+$"); |
| @@ -214,6 +221,7 @@ class HrLine extends BlockMd { | @@ -214,6 +221,7 @@ class HrLine extends BlockMd { | ||
| 214 | } | 221 | } |
| 215 | } | 222 | } |
| 216 | 223 | ||
| 224 | +/// Checkbox component | ||
| 217 | class CheckBoxMd extends BlockMd { | 225 | class CheckBoxMd extends BlockMd { |
| 218 | get onLinkTab => null; | 226 | get onLinkTab => null; |
| 219 | 227 | ||
| @@ -259,6 +267,7 @@ class CheckBoxMd extends BlockMd { | @@ -259,6 +267,7 @@ class CheckBoxMd extends BlockMd { | ||
| 259 | } | 267 | } |
| 260 | } | 268 | } |
| 261 | 269 | ||
| 270 | +/// Radio Button component | ||
| 262 | class RadioButtonMd extends BlockMd { | 271 | class RadioButtonMd extends BlockMd { |
| 263 | get onLinkTab => null; | 272 | get onLinkTab => null; |
| 264 | 273 | ||
| @@ -304,6 +313,7 @@ class RadioButtonMd extends BlockMd { | @@ -304,6 +313,7 @@ class RadioButtonMd extends BlockMd { | ||
| 304 | } | 313 | } |
| 305 | } | 314 | } |
| 306 | 315 | ||
| 316 | +/// Unordered list component | ||
| 307 | class UnOrderedList extends BlockMd { | 317 | class UnOrderedList extends BlockMd { |
| 308 | get onLinkTab => null; | 318 | get onLinkTab => null; |
| 309 | 319 | ||
| @@ -348,6 +358,7 @@ class UnOrderedList extends BlockMd { | @@ -348,6 +358,7 @@ class UnOrderedList extends BlockMd { | ||
| 348 | } | 358 | } |
| 349 | } | 359 | } |
| 350 | 360 | ||
| 361 | +/// Ordered list component | ||
| 351 | class OrderedList extends BlockMd { | 362 | class OrderedList extends BlockMd { |
| 352 | @override | 363 | @override |
| 353 | final RegExp exp = RegExp(r"^([0-9]+\.)\s([^\n]+)$"); | 364 | final RegExp exp = RegExp(r"^([0-9]+\.)\s([^\n]+)$"); |
| @@ -392,6 +403,7 @@ class OrderedList extends BlockMd { | @@ -392,6 +403,7 @@ class OrderedList extends BlockMd { | ||
| 392 | } | 403 | } |
| 393 | } | 404 | } |
| 394 | 405 | ||
| 406 | +/// Bold text component | ||
| 395 | class BoldMd extends InlineMd { | 407 | class BoldMd extends InlineMd { |
| 396 | @override | 408 | @override |
| 397 | final RegExp exp = RegExp(r"^\*{2}(([\S^\*].*)?[\S^\*])\*{2}$"); | 409 | final RegExp exp = RegExp(r"^\*{2}(([\S^\*].*)?[\S^\*])\*{2}$"); |
| @@ -425,6 +437,7 @@ class BoldMd extends InlineMd { | @@ -425,6 +437,7 @@ class BoldMd extends InlineMd { | ||
| 425 | } | 437 | } |
| 426 | } | 438 | } |
| 427 | 439 | ||
| 440 | +/// Italic text component | ||
| 428 | class ItalicMd extends InlineMd { | 441 | class ItalicMd extends InlineMd { |
| 429 | @override | 442 | @override |
| 430 | final RegExp exp = RegExp(r"^\*{1}(([\S^\*].*)?[\S^\*])\*{1}$"); | 443 | final RegExp exp = RegExp(r"^\*{1}(([\S^\*].*)?[\S^\*])\*{1}$"); |
| @@ -456,6 +469,7 @@ class ItalicMd extends InlineMd { | @@ -456,6 +469,7 @@ class ItalicMd extends InlineMd { | ||
| 456 | } | 469 | } |
| 457 | } | 470 | } |
| 458 | 471 | ||
| 472 | +/// Link text component | ||
| 459 | class ATagMd extends InlineMd { | 473 | class ATagMd extends InlineMd { |
| 460 | @override | 474 | @override |
| 461 | final RegExp exp = RegExp(r"^\[([^\s\*].*[^\s]?)?\]\(([^\s\*]+)?\)$"); | 475 | final RegExp exp = RegExp(r"^\[([^\s\*].*[^\s]?)?\]\(([^\s\*]+)?\)$"); |
| @@ -500,6 +514,7 @@ class ATagMd extends InlineMd { | @@ -500,6 +514,7 @@ class ATagMd extends InlineMd { | ||
| 500 | } | 514 | } |
| 501 | } | 515 | } |
| 502 | 516 | ||
| 517 | +/// Image component | ||
| 503 | class ImageMd extends InlineMd { | 518 | class ImageMd extends InlineMd { |
| 504 | @override | 519 | @override |
| 505 | final RegExp exp = RegExp(r"^\!\[([^\s].*[^\s]?)?\]\(([^\s]+)\)$"); | 520 | final RegExp exp = RegExp(r"^\!\[([^\s].*[^\s]?)?\]\(([^\s]+)\)$"); |
| @@ -557,6 +572,7 @@ class ImageMd extends InlineMd { | @@ -557,6 +572,7 @@ class ImageMd extends InlineMd { | ||
| 557 | } | 572 | } |
| 558 | } | 573 | } |
| 559 | 574 | ||
| 575 | +/// Text component | ||
| 560 | class TextMd extends InlineMd { | 576 | class TextMd extends InlineMd { |
| 561 | @override | 577 | @override |
| 562 | final RegExp exp = RegExp(".*"); | 578 | final RegExp exp = RegExp(".*"); |
| 1 | name: tex_markdown | 1 | name: tex_markdown |
| 2 | description: This package is used to create flutter widget that can render markdown and latex formulas. It is very simple to use and uses native flutter components. | 2 | description: This package is used to create flutter widget that can render markdown and latex formulas. It is very simple to use and uses native flutter components. |
| 3 | -version: 0.1.2 | 3 | +version: 0.1.4 |
| 4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_markdown | 4 | homepage: https://github.com/saminsohag/flutter_packages/tree/main/tex_markdown |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
| @@ -10,7 +10,7 @@ environment: | @@ -10,7 +10,7 @@ environment: | ||
| 10 | dependencies: | 10 | dependencies: |
| 11 | flutter: | 11 | flutter: |
| 12 | sdk: flutter | 12 | sdk: flutter |
| 13 | - tex_text: ^0.1.5 | 13 | + tex_text: ^0.1.7 |
| 14 | 14 | ||
| 15 | dev_dependencies: | 15 | dev_dependencies: |
| 16 | flutter_test: | 16 | flutter_test: |
-
Please register or login to post a comment