2016-08-15 113 views
0

文档提供了间距Example S IN标记以下代码:空间在斯威夫特斯威夫特的标记语言

/*: 
    - example: *A simple `for` loop.*\ 
    This example shows a `for` loop that prints the numbers 1 to 5.\ 
    \ 
    `for index in 1...5 {`\ 
    ` print("index = \(index)")`\ 
    `}`} 
*/ 

在呈现的标记没有空格显示:

enter image description here

你如何在代码片段中放置空格,特别是在标记中使用自定义callouts()的示例?

+0

@tktsubota,我试过,但三重反勾。不幸的是,这些对自定义'callouts()'没有帮助。 – Eric

+0

您是否使用Playgrounds或代码文档的标记? – ronatory

+0

@ronatory代码在游乐场。 – Eric

回答

1

所以显示在你的代码示例中的空间尝试那样做对于你的例子:

/*: 
A simple for loop.\ 
This example shows a for loop that prints the numbers 1 to 5. 

    for index in 1...5 { 
     print("index = \(index)") 
    } 
*/ 

结果看起来呈现标记像这样(的空间出现在代码块):评论后 enter image description here

编辑:

的唯一途径,我发现了,让你的前两行的Markup也是在这个例子里面,同样为了模拟空格就是使用这个代码(在打印行中,前两个反引号和它们之间的一个空格,然后是八个空格,直到打开反向引号):

/*: 
- example: *A simple `for` loop.*\ 
This example shows a `for` loop that prints the numbers 1 to 5.\ 
\ 
`for index in 1...5 {`\ 
` `  `print("index = \(index)")`\ 
`}`} 
*/ 

这导致到:

enter image description here

+0

如果您将图像中的侧边栏与我的图像进行比较,您会注意到前两行Markup不在该示例中。你的代码不会调用'callout()'。 – Eric

+0

更新了答案,但我并没有真正明白通过调用'callout()'的意思。 – ronatory