如何防止GitHub wiki中自动生成的链接?

时间:2014-09-07 00:28:08

标签: github

在GitHub维基页面上,如果我输入:

www.foobar.com

GitHub自动假定这是一个URL,并使文本成为http://www.foobar.com的超链接。但是,有时我不希望创建超链接。有没有办法阻止这种行为?也许某种降价?

6 个答案:

答案 0 :(得分:22)

这不仅限于维基页面,也是GFM (GitHub Flavored Markdown) url autolinking feature的一部分。

将它们放入``可以工作,但将url显示为代码:foo http://example.com bar。

foo `http://example.com` bar

另一个技巧(mentioned in this gist)是

ht<span>tp://</span>example.com 

这会将http://example.com显示为常规文字。

在你的情况下(没有http://)

w<span>ww.</span>foobar.com

这也会将www.foobar.com显示为常规文本。

答案 1 :(得分:5)

您可以使用zero-width space来防止大多数自动链接器将字符解释为URL

下面是在https:之间插入零宽度空格的示例

https://example.com/

要插入一个,您可以从上面的网址或this page

复制

另请参阅this thread on twitter

答案 2 :(得分:1)

您也可以将backslash escape应用于结肠(或其他标点符号),如下所示:

http\://www.foobar.com

答案 3 :(得分:0)

此外,如果您遇到的问题不是网址自动链接,我发现转义了。也可以。

示例:

foobar.web -> foobar&#46;web

答案 4 :(得分:0)

建议使用zero-width no-break space
在HTML中可用作Unicode字符引用:snake.append((0,0))import pygame, random as rand, os from pygame.locals import * pygame.init() screen = pygame.display.set_mode((1020, 585)) pygame.display.set_caption('2snakes!') #files location current_path = os.path.dirname(__file__) data_path = os.path.join(current_path, 'data') icon = pygame.image.load(os.path.join(data_path, 'icon.png')) pygame.display.set_icon(icon) #variables direction = 'RIGHT' direction2 = 'RIGHT' change_to = direction change2_to = direction2 fps = 15 #snake size = 15 s_pos = 60 snake = [(s_pos, s_pos),(s_pos + size, s_pos),(s_pos + size * 2, s_pos)] s_skin = pygame.Surface((size, size)) s_skin.fill((82,128,208)) #snake2 size2 = 15 s2_pos = 90 snake2 = [(s2_pos, s2_pos),(s2_pos + size2, s2_pos),(s2_pos + size2 * 2, s2_pos)] s2_skin = pygame.Surface((size2, size2)) s2_skin.fill((208,128,82)) #apple apple = pygame.Surface((size, size)) apple_pos = (165, 150) #collission def collision (c1,c2): return (c1[0] == c2[0]) and (c1[1] == c2[1]) def selfColliding(snake: list): for i in snake: if snake.count(i) > 1: return True return False def gameOver(): #pygame.quit() print("gameover") def selfColliding(snake: list): return True if snake.count(snake[0]) > 1 else False while True: #fps pygame.time.Clock().tick(fps) #basic stuff for event in pygame.event.get(): if event.type == QUIT: pygame.quit() #input elif event.type == pygame.KEYDOWN: #snake if event.key == ord('w'): change_to = 'UP' if event.key == ord('s'): change_to = 'DOWN' if event.key == ord('a'): change_to = 'LEFT' if event.key == ord('d'): change_to = 'RIGHT' #snake2 if event.key == pygame.K_UP: change2_to = 'UP' if event.key == pygame.K_DOWN: change2_to = 'DOWN' if event.key == pygame.K_LEFT: change2_to = 'LEFT' if event.key == pygame.K_RIGHT: change2_to = 'RIGHT' #quit game if event.key == pygame.K_ESCAPE: pygame.event.post(pygame.event.Event(pygame.QUIT)) #noice smooth snake movement #snake if change_to == 'UP' and direction != 'DOWN': direction = 'UP' if change_to == 'DOWN' and direction != 'UP': direction = 'DOWN' if change_to == 'LEFT' and direction != 'RIGHT': direction = 'LEFT' if change_to == 'RIGHT' and direction != 'LEFT': direction = 'RIGHT' #snake2 if change2_to == 'UP' and direction2 != 'DOWN': direction2 = 'UP' if change2_to == 'DOWN' and direction2 != 'UP': direction2 = 'DOWN' if change2_to == 'LEFT' and direction2 != 'RIGHT': direction2 = 'LEFT' if change2_to == 'RIGHT' and direction2 != 'LEFT': direction2 = 'RIGHT' #movement #snake if direction == 'DOWN': snake[0] = (snake[0][0], snake[0][1] + size) if direction == 'UP': snake[0] = (snake[0][0], snake[0][1] - size) if direction == 'LEFT': snake[0] = (snake[0][0] - size, snake[0][1]) if direction == 'RIGHT': snake[0] = (snake[0][0] + size, snake[0][1]) #snake2 if direction2 == 'DOWN': snake2[0] = (snake2[0][0], snake2[0][1] + size2) if direction2 == 'UP': snake2[0] = (snake2[0][0], snake2[0][1] - size2) if direction2 == 'LEFT': snake2[0] = (snake2[0][0] - size2, snake2[0][1]) if direction2 == 'RIGHT': snake2[0] = (snake2[0][0] + size2, snake2[0][1]) #snake apple collision if collision(snake[0], apple_pos): snake.append((0,0)) #snake2 apple collision if collision(snake2[0], apple_pos): snake2.append((0,0)) #snake wall collisison if snake[0][0] < 0 or snake[0][1] < 0: gameOver() elif snake[0][0] > 1020 or snake[0][1] > 585: gameOver() #snake2 wall collisison #if snake2[0][0] < 0 or snake2[0][1] < 0: #gameOver() #elif snake2[0][0] > 1020 or snake2[0][1] > 585: #gameOver() #all blocks follow first #snake for i in range(len(snake) -1, 0, -1): snake[i] = (snake[i-1][0], snake[i-1][1]) #snake2 for i in range(len(snake2) -1, 0, -1): snake2[i] = (snake2[i-1][0], snake2[i-1][1]) if selfColliding: print("self colliding") #rendering screen.fill((0,0,0)) apple.fill((255,0,0)) screen.blit(apple,apple_pos) for pos in snake: screen.blit(s_skin,pos) for pos2 in snake2: screen.blit(s2_skin,pos2) pygame.display.update()

好处是:

  • (显然)防止自动链接
  • 不可见
  • 没有意外的换行符
  • 可在源代码中读取

示例

对于网址,请在&#xfeff;&#65279;之间插入
http→https://example.com/

对于在:之后插入电子邮件:
https​&#65279;://example.com/→user @ example.com

答案 5 :(得分:0)

就我而言,
我用过
Traceback (most recent call last): File "send_email.py", line 166, in <module> send_mail() File "send_email.py", line 159, in send_mail server = smtplib.SMTP('localhost') File "/usr/lib64/python3.6/smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib64/python3.6/smtplib.py", line 336, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib64/python3.6/smtplib.py", line 307, in _get_socket self.source_address) File "/usr/lib64/python3.6/socket.py", line 724, in create_connection raise err File "/usr/lib64/python3.6/socket.py", line 713, in create_connection sock.connect(sa) OSError: [Errno 113] No route to host
在标题中,然后我得到一个没有外部链接的标题。

一些东西

并使用
# some&#46;thing
作为链接。
“#something”来自网络中预览的链接。