代码块的github markdown

时间:2013-11-09 00:23:05

标签: github markdown

以下代码没有格式化```作为汇编代码之间的东西,我想知道为什么。谢谢!

- here is an example of an appropriate input file


```
.text
main:
        la   $s0, A              # load variables A and B into registers
        lw   $s0, 0($s0)
        la   $s1, B
        lw   $s1, 0($s1)

        add  $s2, $s0, $s1       # calculate sum
        la   $s3, Sum            # assign result to Sum
        sw   $s2, 0($s3)

        sub  $s2, $s0, $s1       # calculate difference
        la   $s3, Diff           # assign result to Diff
        sw   $s2, 0($s3)
exit:
        li   $v0, 10             # system call to terminate program
        syscall                  # make call

.data
A:      .word   32
B:      .word   16
Sum:    .word    0
Diff:   .word    0
```

<h3>Output:</h3> a ASCII text file with the corresponding MIPS machine code. Here is the corresponding output file to the above input file

3 个答案:

答案 0 :(得分:3)

For what it's worth, now (3 years after the question was asked), assembly seems to work like a charm

```assembly
.text
main:
        la   $s0, A              # load variables A and B into registers
        lw   $s0, 0($s0)
        la   $s1, B
        lw   $s1, 0($s1)
```

答案 1 :(得分:0)

不同的markdown实现可能使用不同的语法突出显示字符串。

Stackoverflow使用以下JavaScript文件:https://dev.sstatic.net/js/prettify-full.en.js

很遗憾,不支持组装。
根据{{​​3}}元问题,stackexchange支持的语言列表为:

"bsh", "c", "cc", "cpp", "cs", "csh",
"cyc", "cv", "htm", "html", "java",
"js", "m", "mxml", "perl", "pl", "pm",
"py", "rb", "sh", "xhtml", "xml", "xsl"

Github使用以下yaml文件:this 正确的字符串是assembly

Discord: 可以在以下位置找到语言列表:https://github.com/github/linguist/blob/master/lib/linguist/languages.yml 对于Intel x86,相关代码为x86asm

答案 2 :(得分:-1)

他们的语言学家&#39;语法高亮引擎只知道这么多语言;似乎汇编代码不在其中,因为我似乎无法在linguist/samples目录中看到任何样本。

它仍然应该以等宽字体显示为代码块,但是,如果它在```标签之间。