Comments (6)
#81 is related.
It fixed relative links, but it considers only those links that start with /
to be relative.
See func isRelativeLink(link []byte) (yes bool)
for the current logic of what constitutes a relative link.
So, if you apply this patch to your example:
diff --git a/gistfile1.go b/gistfile1.go
index 19f4e6e..07adaf6 100644
--- a/gistfile1.go
+++ b/gistfile1.go
@@ -7,8 +7,8 @@ import (
func main() {
outb := blackfriday.MarkdownCommon([]byte(`
-![pic](media/pic.png)
-[url](docs/doc.html)
+![pic](/media/pic.png)
+[url](/docs/doc.html)
`))
fmt.Print(string(outb))
}
\ No newline at end of file
Then the output is:
<p><img src="/media/pic.png" alt="pic"/>
<a href="/docs/doc.html">url</a></p>
Can you confirm/deny if that solves your problem?
from blackfriday.
It does allow the Markdown to render the URL - however in my case that is the wrong URL. Starting with slash is an absolute reference to the server root, not a relative reference. My pages are rooted in another location, so I need a true relative reference. It seems like isRelativeLink is actually testing for an absolute link on the same server.
from blackfriday.
Note that relative URLs are notoriously hard to sanitise - make sure that
this doesn't compromise sanitisation.
On Donnerstag, 29. Mai 2014 16:22:21, Michael Lore [email protected]
wrote:
It does allow the Markdown to render the URL - however in my case that is
the wrong URL. Starting with slash is an absolute reference to the
server root, not a relative reference. My pages are rooted in another
location, so I need a true relative reference.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/87#issuecomment-44536838
.
from blackfriday.
In my case I may be able to disable sanitization. I will try it.
from blackfriday.
Yeah that will work for me because my application doesn't allow random users to input Markdown. So I have a solution - just need to decide how you want sanitization to work for that scenario.
from blackfriday.
Now when Blackfriday no longer attempts to do sanitization internally, it renders them fine again. Closing.
from blackfriday.
Related Issues (20)
- Panic on listItem function HOT 1
- List after paragraph not rendenring HOT 1
- Is it possible to not wrap <div> inside <a> in <p>
- `AutoLink` becomes turned off when running with `HardLineBreak` ext
- How to support some UML plug-ins? For example: mermaid
- parse bitcoin uri's as links HOT 2
- List convert error HOT 1
- index out of range panic in v2.scanLinkRef (line 659 in markdown.go file)
- index out of range panic in v2.listItem (line 1369 in block.go file)
- code blocks break line has been deleted
- Buggy, fragile list behavior
- Column alignement in tables?
- What flags to (un)set if i want no header tags?
- Is v2 OK with Go 1.17?
- enclosed parentheses in markdown links not rendered properly in html
- Support single dash table define
- Is this repository dead? HOT 1
- Code blocks not parsed correctly
- Empty data while parsing markdown
- panic: block input is missing terminating newline
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 blackfriday.