문제

Markdown 구문 분석 문서에 북마크를 포함하려면 어떻게해야합니까? 기본적으로 "이것을 구문 분석하지 마십시오"라고 말하는 Markdown에 대한 "태그"가 있습니까?

예를 들어 다음과 같은 것을 가질 수 있습니다.

<a href="javascript:function my_bookmarklet()
                {alert('Hello World');}
                my_bookmarklet();">Hello</a>

그러나 내가 JavaScript를 지나서 다음과 같은 Markdown의 링크로 지나치려고한다면.

[Hello World!](javascript:function my_bookmarklet(){alert('Hello World');}my_bookmarklet();)

아래와 같이 엉망인 링크를 얻습니다.

Hello World!] (JavaScript : 함수 my_bookmarklet () {alert ( 'hello world');} my_bookmarklet ();)

어쨌든이 주위에 있습니까?

그리고 아니요, 저는 악의적 인 북마크를 그렇게 또는 그 밖의 어떤 것에 넣으려고하지는 않지만 내 사이트에 Markdown을 사용하고 싶고 내가 쓴 책갈피를 게시하고 싶습니다.

편집 : 나는 대답이 있다고 생각했지만 지금은 그것을 가지고 있지 않은 것 같습니다.

이것은 WMD와 대결에서 훌륭하게 작동하는 것처럼 보이지만 Markdown.php 편집기에서는 그렇지 않습니다. 누구든지 Markdown.php에 대한 경험이 있습니까?

도움이 되었습니까?

해결책

Markdown will leave any HTML alone, so you can just enter

<a href="javascript:function my_bookmarklet()
                {alert('Hello World');}
                my_bookmarklet();">Hello</a>

and get Hello. Edit: No longer works on SO, which is a good thing

You can also escape special characters with a backslash (in this case it's seeing the ")"s in your Javascript as the end of the URL) and the link syntax will work:

[Hello](javascript:function my_bookmarklet(\){alert('Hello World'\);}my_bookmarklet(\);)

gives [Hello](javascript:function my_bookmarklet(){alert('Hello World');}my_bookmarklet();)

다른 팁

[Hello World!][1]
[1]:javascript:alert('Hello World')

I know this is a very old question, but (in case someone else finds their way here, as I did), if you url-encode your script, it will work.

For example:

    [Hello World](javascript:%28function%28%29%7Balert%28%22Hello%20World%22%29%7D%29%28%29%3B)

And of course, as mentioned above, it does not work here, on SO.

Note: Some url-encoders will replace space (" ") with a "+", which works fine for regular urls, but not js code, spaces should be replaced with "%20"

EDIT: This doesn't seem to be universally true. I suppose the specific markdown parser makes the final call here. But this works for me in more places where markdown is used.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top