markedjs / marked-base-url Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://www.npmjs.com/package/marked-base-url
License: MIT License
Home Page: https://www.npmjs.com/package/marked-base-url
License: MIT License
i found that this work in the browser. in case someone needs it
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-base-url"></script>
<script>
marked.use(markedBaseUrl.baseUrl(`.....`));
const html = marked.parse('# markdown\n\nhello', {
breaks: true,
});
</script>
See output to the following lines. The base URL is added properly to the standard MD format, but not to the img tag:
Output:
Using marked version 4.3.0 and marked-base-url version 1.0.2.
This functionality might not be within the scope of this parser, but might be a good addition for those who want more control over their markdown images using HTML tags.
Hi guys,
first of all, thanks for marked
, it's awesome.
I'm in the process of upgrading a personal app from "marked": "^1.2.8",
, and it's easy sailing, except for the thing where the baseUrl
option was removed from the main parsing function (markedjs/marked#2936).
My app has changing baseUrls depending on the document I'm trying to parse. With the previous atomic formulation marked(doc, {baseUrl: theBaseUrlOfDoc})
, this was no problem, but I have some issues incorporating the new way of doing things, which I guess amounts to marked.use(baseUrl(theBaseUrlOfDoc))
followed by marked.parse(doc)
. It's like the new baseUrl is not applied properly and multiple (updating) calls marked.use are not supported.
Can you point me in the right direction with regards to upgrading this usecase to your changed plugin-based API? Any hints greatly appreciated. For now, I'm stuck upgrading to ^7
which doesn't have this breaking change.
Cheers, Georg
I recently ran into a issue with a reference to an anchor tag in the local document that was also put on the base url. Since the tag is local, i.e. .href.startsWith('#')
, to the currently viewed document, could marked-base-url be changed to not put the base url in front?
Current behavior:
marked.parse("[local link](#anchor)");
'<p><a href="https://example.com/folder/#anchor">local link</a></p>\n'
Desired new behavior:
marked.parse("[local link](#anchor)");
'<p><a href="#anchor">local link</a></p>\n'
marked reached version 8 and removed baseUrl support so this package is the only way to make this work.
in marked-base-url version 1.0.6 i see peerdependencies state "marked": "^4 || ^5 || ^6 || ^7"
please update it and release
there is a node_modules\marked-highlight\src\index.d.ts file in marked-highlight npm package. but this project has no this d.ts file. Please add it for TypeScript
Hi,
I'm trying to append a base url to relative image paths but it ignores the path of provided URL.
kleur met een lege waarde:\n\n![image](/uploads/ce5034e9855d2508f52fd51bc4ee8158/image.png)\n\nDe link die
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-base-url/lib/index.umd.js"></script>
marked.use(markedBaseUrl.baseUrl("https://example.com/folder/"));
var input = x.innerHTML;
var output = DOMPurify.sanitize(marked.parse(input));
x.innerHTML = output;
kleur met een lege waarde:</p>
<p><img alt="image" src="https://example.com/uploads/ce5034e9855d2508f52fd51bc4ee8158/image.png"></p>
<p>De link die
As you can see on the img src, the folder/
path is ignored. Am I missing something or?
When reading the documentation it looks to me like it should accept paths. Following code block is from the documentation;
marked.use(baseUrl("https://example.com/folder/"));
marked.parse("[my url](./relative/path)");
// <p><a href="https://example.com/folder/relative/path">my url</a></p>
Thanks in advance,
Erwin
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.