10

我正在尝试在 github 评论中显示一些原始 xml,如果我可以让它显示出来,我会很烦恼。当我粘贴并保存时,标签被解释,我只得到内容。但该评论旨在显示需要发送到第三方应用程序的内容。

这是我想作为评论插入的内容。

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:catalogCategoryTree soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <sessionId xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">blablaa</sessionId>
         <parentId xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">?</parentId>
         <storeView xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">?</storeView>
      </urn:catalogCategoryTree>
   </soapenv:Body>
</soapenv:Envelope>

这是呈现给我的同事的内容

soapenv:Header/
soapenv:Body

blablaa
?
?
/urn:catalogCategoryTree
/soapenv:Body
/soapenv:Envelope

有没有办法让我输入的内容显示出来?

4

1 回答 1

34

您可以在注释中使用三重反引号 (```) 来多行引用代码。如果你想要语法高亮,你也可以指定语言:

```xml
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
    <soapenv:Header/
    <soapenv:Body>
        <urn:catalogCategoryTreevsoapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <sessionId xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">blablaa</sessionId>
            <parentId xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">?</parentId>
            <storeView xsi:type="xsd:string" xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">?</storeView>
        </urn:catalogCategoryTree>
    </soapenv:Body>
</soapenv:Envelope>
```
于 2013-05-08T08:28:47.573 回答