Comments (4)
I only use this parseInline()
method because parse()
adds surrounding <p>
tags to the output, which I don't want. I don't use any extension and it's a pain in the ass constantly having to write as string
.
Why doesn't parse()
suffer from the same issue? Does that method not support extensions? Shouldn't maybe an extension fail if you specify async: false
and the extension cannot run synchronously? Not being able to predict the return type for the most basic usage of the method without any extensions seems a little bit poor regarding Typescript support.
Any other workaround to not have to do unsafe as string
casting? Or any other way I can help?
from marked.
Parse does the same thing. I think the types are wrong there. Unfortunately typescript isn't smart enough to know if an extension sets async: true
.
The way that typescript recommends using typescript in this situation is to use as string
if you know there are no async extensions or always await the output (will work even for string)
from marked.
I think parseInline is actually correct. If an extension sets async: true
then marked.parse(md, {async: false})
will still return Promise<string>
from marked.
Got it, it's a shame that Typescript cannot figure it out. I hoped that it may be something that could be easily fixed.
Thanks for the tip, didn't thought I could await a regular string, but that works and I prefer it to having unsafe castings. That way if I add an extension in the future (whatever those are for 😆) it will continue to work.
from marked.
Related Issues (20)
- Equals sign in code block breaks it HOT 1
- Setext continuation in blockquote
- URL.canParse is not a function on Brave Browser HOT 1
- Add Support for Customizable Tab Handling in Markdown Code Blocks HOT 2
- add support to node 20 HOT 1
- Docusaurus + redocusaurus == The language "shell" has no grammar HOT 4
- Issues with various Markdown aspects HOT 2
- Improved TypeScript types for TokenizerAndRendererExtension HOT 2
- Nested pre-formatted text block are not handled properly HOT 2
- When both bold and normal fonts appear in a line of text, if there is no space after the bold double asterisk, it cannot be parsed normally. HOT 1
- Text rendered in h2 heading title HOT 3
- Link and tilde symbol parsing issues detected. HOT 1
- Unable to read titles HOT 3
- marked v12 with webpack 5.9x HOT 5
- Display Github permalink to a code snippet HOT 7
- Block level extension not rendering correctly HOT 2
- Emphasis cannot be rendered HOT 3
- could not resolve module HOT 4
- Support unordered lists with hyphens (-) in addition to asterisks (*) HOT 1
- problem when inserting a picture HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marked.