Git Product home page Git Product logo

marked-base-url's People

Contributors

btnguyen2k avatar dependabot[bot] avatar github-actions[bot] avatar jceb avatar rafipiccolo avatar semantic-release-bot avatar sinotaotao avatar uzitech avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

marked-base-url's Issues

marked in the browser via cdn.jsdelivr.net

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>

Base URL not added to img tag embedded in Markdown

See output to the following lines. The base URL is added properly to the standard MD format, but not to the img tag:

image

Output:

image

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.

Dealing with changing `baseUrl`s

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

Feature request: don't base-url local references

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'

maybe we need a index.d.ts

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

Path is ignored when using baseUrl

Hi,

I'm trying to append a base url to relative image paths but it ignores the path of provided URL.


Part of the input that includes the image path;

kleur met een lege waarde:\n\n![image](/uploads/ce5034e9855d2508f52fd51bc4ee8158/image.png)\n\nDe link die

The marked implementation

    <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;

HTML result;

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.