ts-stack / markdown Goto Github PK
View Code? Open in Web Editor NEWA full-featured markdown parser and compiler, written in TypeScript.
A full-featured markdown parser and compiler, written in TypeScript.
https://github.github.com/gfm/#example-113
~~~~ ruby startline=3 $%@#$
def foo(x)
return 3
end
~~~~~~~
As far as I can tell, the regexp
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
does not support that, and thus does not recognizes the code block.
How can I detect if it was a tripple backtick codeblock or a single backtick code snippet in renderer?
class MarkdownRenderer extends Renderer {
code(code: string, lang: string, escaped: boolean) {
if (escaped) return code
return `<pre><code class="codeblock lang-${lang}">${code}</code></pre>`
}
}
hi. didn't support task list
- [ ] foo
- [x] bar
First; Thank you for a wonderful Markdown parser!
When using it inside React I think i have to insert generated markup like this
return <div dangerouslySetInnerHTML={{ __html: Marked.parse(markup) }} />
Please advice me if I'm wrong. But then I get this error from React:
Warning: validateDOMNesting(...): <p> cannot appear as a descendant of <div>.
Is there a way to skip the surrounding p-tag generated by the parser ?
let options: MarkedOptions = {isNoP: true};
Marked.setOptions(options);//is working but
Marked.parse("some intput", options)//provides to error:
TypeError: this.options.escape is not a function
Please report this to https://github.com/KostyaTretyak/marked-ts
at InlineLexer.output (http://localhost:8100/build/vendor.js:74738:56)
at Parser.parseText (http://localhost:8100/build/vendor.js:74372:33)
at Parser.tok (http://localhost:8100/build/vendor.js:74387:37)
at Parser.parse (http://localhost:8100/build/vendor.js:74345:25)
at Function.Parser.parse (http://localhost:8100/build/vendor.js:74338:23)
at Function.Marked.callParser (http://localhost:8100/build/vendor.js:50612:36)
at Function.Marked.parse (http://localhost:8100/build/vendor.js:50558:25)
at MarkedProvider.webpackJsonp.214.MarkedProvider.simpleMarked (http://localhost:8100/build/main.js:162:66)
....
Documentation on how they should render are here: https://www.markdownguide.org/extended-syntax#task-lists
But the renderer is treating them like a list.
Hello,
The latest versjon of markdown-ts has issue with polyfills.
Issue is in this line
Line 25 in cb5c7cc
The latest version or 1.0.0-beta.5 does not work in IE 11
Import it in any file and open this one in IE 11
It works :) .
Nice work with marked-ts!
Wrote a little script to allow Angular to support Markdown, using marked-ts.
Given b.component.md
:
## Hello
<div *ngIf="true">
```bash
echo ${5}
```
</div>
It generates:
<h2 id="hello">Hello</h2>
<div *ngIf="true">
<code>bash
echo ${5}</code>
</div>
How would I escape things Angular doesn't support?
Namely, I want to generate:
<h2 id="hello">Hello</h2>
<div *ngIf="true">
<code>bash
echo ${{'{'}}5{{'}'}}</code>
</div>
EDIT_0: I can't escape with NgNonBindable
due to angular/angular#11859
EDIT_1: Wrote a very basic custom post processing for this:
https://github.com/SamuelMarks/ng-md-components/blob/ceec9783881a2864fe5e2fff82bec115895733de/index.ts#L73-L91
I would like to use a backslash \
instead of double spaces to render a line break, maybe this could be an option in the settings - or is it possible somehow to change the regex for a line break?
This library takes md
as input and parse
more-or-less creates HTML, but I expected a parsed IR of the markdown, versus a transformed format. parse
seems to actually be convert, vs parse.
I need to take md
=> md
, but adding content along the way.
Can this library support that use case?
Hi !
Is there a simple way to add new Renderer method ? Or can I only override the existing ones ?
Thanks for the great lib
Using following way to sanitize causes runtime error.
{@html Marked.parse(event.description ?? '', {sanitize: true})}
TypeError: this.options.escape is not a function
Please report this to https://github.com/ts-stack/markdown
at InlineLexer.output (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:797:60)
at Parser.tok (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:930:69)
at Parser.parse (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:894:29)
at Parser.parse (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:887:27)
at Marked.callParser (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:1137:31)
at Marked.parse (/Users/xxxx/node_modules/@ts-stack/markdown/bundles/ts-stack-markdown.umd.js:1078:29)
at eval (/Users/xxxx/src/lib/components/EventCard.svelte:29:1006)
at Object.$$render (/Users/xxxx/node_modules/svelte/src/runtime/internal/ssr.js:174:16)
at Object.default (/Users/xxxx/src/routes/(prerender)/(home)/+page.svelte:93:102)
at eval (/Users/xxxx/src/lib/components/Section.svelte:17:39)
When using with highlightjs the resulting <code>
element should have the hljs
class as well as lang-whatever
in order to properly theme the code with background color etc.
Is there an easy way to configure marked-ts to do this automatically?
Received an error while trying some more complicated markdown rendering.
Message: this.options.escape is not a function Please report this to https://github.com/KostyaTretyak/marked-ts
Exception type: TypeError
Failed method: Renderer.code
Stack:
TypeError:
at Renderer.code (at Renderer.code (/home/site/wwwroot/dist/server.js:78487:69)at Renderer.code (/home/site/wwwroot/dist/server.js:78487:69): /home/site/wwwroot/dist/server.jsat Renderer.code (/home/site/wwwroot/dist/server.js:78487:69): 78487)
at Parser.tok (at Parser.tok (/home/site/wwwroot/dist/server.js:78392:42)at Parser.tok (/home/site/wwwroot/dist/server.js:78392:42): /home/site/wwwroot/dist/server.jsat Parser.tok (/home/site/wwwroot/dist/server.js:78392:42): 78392)
at Parser.parse (at Parser.parse (/home/site/wwwroot/dist/server.js:78314:25)at Parser.parse (/home/site/wwwroot/dist/server.js:78314:25): /home/site/wwwroot/dist/server.jsat Parser.parse (/home/site/wwwroot/dist/server.js:78314:25): 78314)
at Function.Parser.parse (at Function.Parser.parse (/home/site/wwwroot/dist/server.js:78307:23)at Function.Parser.parse (/home/site/wwwroot/dist/server.js:78307:23): /home/site/wwwroot/dist/server.jsat Function.Parser.parse (/home/site/wwwroot/dist/server.js:78307:23): 78307)
at Function.Marked.callParser (at Function.Marked.callParser (/home/site/wwwroot/dist/server.js:78256:36)at Function.Marked.callParser (/home/site/wwwroot/dist/server.js:78256:36): /home/site/wwwroot/dist/server.jsat Function.Marked.callParser (/home/site/wwwroot/dist/server.js:78256:36): 78256)
at Function.Marked.parse (at Function.Marked.parse (/home/site/wwwroot/dist/server.js:78202:25)at Function.Marked.parse (/home/site/wwwroot/dist/server.js:78202:25): /home/site/wwwroot/dist/server.jsat Function.Marked.parse (/home/site/wwwroot/dist/server.js:78202:25): 78202)
at renderMarkdown (at renderMarkdown (/home/site/wwwroot/dist/server.js:77732:61)at renderMarkdown (/home/site/wwwroot/dist/server.js:77732:61): /home/site/wwwroot/dist/server.jsat renderMarkdown (/home/site/wwwroot/dist/server.js:77732:61): 77732)
at contentSection.item.data.contentSection.item.data.contentSection.map.section (at contentSection.item.data.contentSection.item.data.contentSection.map.section (/home/site/wwwroot/dist/server.js:79220:116)at contentSection.item.data.contentSection.item.data.contentSection.map.section (/home/site/wwwroot/dist/server.js:79220:116): /home/site/wwwroot/dist/server.jsat contentSection.item.data.contentSection.item.data.contentSection.map.section (/home/site/wwwroot/dist/server.js:79220:116): 79220)
at mapCommunicationArticle (at mapCommunicationArticle (/home/site/wwwroot/dist/server.js:79217:77)at mapCommunicationArticle (/home/site/wwwroot/dist/server.js:79217:77): /home/site/wwwroot/dist/server.jsat mapCommunicationArticle (/home/site/wwwroot/dist/server.js:79217:77): 79217)
The offending markdown (but with three backticks):
``
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
``
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.