Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
gpt_markdown
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
saminsohag
2023-04-02 05:35:18 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8be35f2a3b9d2e4c25ae27feac31ddb6525b27f7
8be35f2a
1 parent
94758ed4
bug fixed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
20 deletions
tex_markdown/CHANGELOG.md
tex_markdown/example/lib/main.dart
tex_markdown/example/pubspec.lock
tex_markdown/lib/markdown_component.dart
tex_markdown/pubspec.yaml
tex_markdown/CHANGELOG.md
View file @
8be35f2
## 0.1.2
*
Bug fixes.
*
Shortcut syntax to math added.
## 0.1.1
*
Html parser math fixed.
...
...
tex_markdown/example/lib/main.dart
View file @
8be35f2
...
...
@@ -56,17 +56,24 @@ class MyHomePage extends StatefulWidget {
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
final
TextEditingController
_controller
=
TextEditingController
(
text:
'''# hi how are you?
## hi how are you?
final
TextEditingController
_controller
=
TextEditingController
(
text:
r''
'
# hi how are you?
$my
is^2
$
## hi how are you
$
(
\
frac ab)^2
$
?
### hi how are you?
#### hi how are you?
##### hi how are you?
###### hi how are you?

##### hi how are you?
$my
name is x^2
$
###### hi how are you?
$x
^2
$
hello
---
**bold text**
*Italic text*
my name is

**bold
$x
^2
\
cfrac a{
\
cfrac ab}
$
text**
*Italic text
$x
^2
\
cfrac a{b}
$
*
**hello**
$hello
$
$sdf
\
frac a{
\
frac ab}
$
$hello
$
[Link]()
- unordered list
1. ordered list 1
...
...
tex_markdown/example/pubspec.lock
View file @
8be35f2
...
...
@@ -238,15 +238,15 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.
1
"
version: "0.1.
2
"
tex_text:
dependency: transitive
description:
name: tex_text
sha256: "
33bd11ec8eb58ca9d32919a71629ab80d704405da1a6e03d48ec3f6a266f1267
"
sha256: "
46942a9587170f5130d2f7110083abd4335b66d763b0cf6a241c80e74826d71d
"
url: "https://pub.dev"
source: hosted
version: "0.1.
4
"
version: "0.1.
5
"
tuple:
dependency: transitive
description:
...
...
tex_markdown/lib/markdown_component.dart
View file @
8be35f2
...
...
@@ -50,7 +50,10 @@ abstract class MarkdownComponent {
if
(
each
is
InlineMd
)
{
if
(
spans
.
isNotEmpty
)
{
spans
.
add
(
TextSpan
(
text:
" "
,
style:
style
),
TextSpan
(
text:
" "
,
style:
style
,
),
);
}
spans
.
add
(
each
.
inlineSpan
(
...
...
@@ -83,7 +86,9 @@ abstract class MarkdownComponent {
if
(
spans
.
isNotEmpty
)
{
children
.
add
(
Text
.
rich
(
TextSpan
(
children:
List
.
from
(
spans
)),
TextSpan
(
children:
List
.
from
(
spans
),
),
textAlign:
TextAlign
.
left
,
),
);
...
...
@@ -168,7 +173,13 @@ class HTag extends BlockMd {
),
],
),
if
(
match
[
1
]!.
length
==
1
)
const
Divider
(
height:
6
),
if
(
match
[
1
]!.
length
==
1
)
Divider
(
height:
6
,
thickness:
2
,
color:
style
?.
color
??
Theme
.
of
(
context
).
colorScheme
.
onSurfaceVariant
,
),
],
);
}
...
...
@@ -190,8 +201,10 @@ class HrLine extends BlockMd {
TextStyle
?
style
,
final
void
Function
(
String
url
,
String
title
)?
onLinkTab
,
)
{
return
const
Divider
(
height:
5
,
return
Divider
(
height:
6
,
thickness:
2
,
color:
style
?.
color
??
Theme
.
of
(
context
).
colorScheme
.
onSurfaceVariant
,
);
}
...
...
@@ -393,6 +406,8 @@ class BoldMd extends InlineMd {
var
match
=
exp
.
firstMatch
(
text
.
trim
());
return
WidgetSpan
(
// text: "${match?[1]}",
alignment:
PlaceholderAlignment
.
baseline
,
baseline:
TextBaseline
.
alphabetic
,
child:
TexText
(
"
${match?[1]}
"
,
style:
style
?.
copyWith
(
fontWeight:
FontWeight
.
bold
)
??
...
...
@@ -423,6 +438,8 @@ class ItalicMd extends InlineMd {
)
{
var
match
=
exp
.
firstMatch
(
text
.
trim
());
return
WidgetSpan
(
alignment:
PlaceholderAlignment
.
baseline
,
baseline:
TextBaseline
.
alphabetic
,
child:
TexText
(
"
${match?[1]}
"
,
style:
...
...
@@ -455,6 +472,8 @@ class ATagMd extends InlineMd {
return
const
TextSpan
();
}
return
WidgetSpan
(
alignment:
PlaceholderAlignment
.
baseline
,
baseline:
TextBaseline
.
alphabetic
,
child:
GestureDetector
(
onTap:
()
{
if
(
onLinkTab
==
null
)
{
...
...
@@ -502,7 +521,7 @@ class ImageMd extends InlineMd {
height
=
double
.
tryParse
(
size
?[
2
]?.
toString
().
trim
()
??
'a'
);
}
return
WidgetSpan
(
// alignment: PlaceholderAlignment.middle
,
alignment:
PlaceholderAlignment
.
bottom
,
child:
SizedBox
(
width:
width
,
height:
height
,
...
...
@@ -526,7 +545,15 @@ class ImageMd extends InlineMd {
@override
String
toHtml
(
String
text
)
{
var
match
=
exp
.
firstMatch
(
text
.
trim
());
return
'<img src="
${match?[2].toString().trim()}
">'
;
double
?
height
;
double
?
width
;
if
(
match
?[
1
]
!=
null
)
{
var
size
=
RegExp
(
r"^([0-9]+)?x?([0-9]+)?"
)
.
firstMatch
(
match
![
1
].
toString
().
trim
());
width
=
double
.
tryParse
(
size
?[
1
]?.
toString
().
trim
()
??
'a'
);
height
=
double
.
tryParse
(
size
?[
2
]?.
toString
().
trim
()
??
'a'
);
}
return
'<img src="
${match?[2].toString().trim()}
" height="
$height
" width="
$width
">'
;
}
}
...
...
tex_markdown/pubspec.yaml
View file @
8be35f2
name
:
tex_markdown
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.
version
:
0.1.
1
version
:
0.1.
2
homepage
:
https://github.com/saminsohag/flutter_packages/tree/main/tex_markdown
environment
:
...
...
@@ -10,7 +10,7 @@ environment:
dependencies
:
flutter
:
sdk
:
flutter
tex_text
:
^0.1.
4
tex_text
:
^0.1.
5
dev_dependencies
:
flutter_test
:
...
...
Please
register
or
login
to post a comment