Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22401153
markdown-value.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
663 B
Referenced Files
None
Subscribers
None
markdown-value.ts
View Options
import
{
Parser
,
HtmlRenderer
}
from
"commonmark"
;
import
type
{
FieldValue
}
from
"./field-value.js"
;
const
parser
=
new
Parser
();
const
renderer
=
new
HtmlRenderer
();
export
class
MarkdownValue
implements
FieldValue
{
private
htmlCache
:
string
|
null
=
null
;
constructor
(
private
readonly
markdown
:
string
)
{}
toMarkdown
()
:
string
{
return
this
.
markdown
;
}
toHtml
()
:
string
{
if
(
this
.
htmlCache
===
null
)
{
const
parsed
=
parser
.
parse
(
this
.
markdown
);
this
.
htmlCache
=
renderer
.
render
(
parsed
);
}
return
this
.
htmlCache
;
}
toString
()
:
string
{
return
this
.
toMarkdown
();
}
getRestAPIValue
()
:
string
{
return
this
.
toMarkdown
();
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 18:16 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1213100
Default Alt Text
markdown-value.ts (663 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline