GitHub中的Markdown用于代码块

9
以下代码没有将```之间的内容格式化为汇编代码,我想知道原因。谢谢!
- 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

1
你说的“formatting”,是指“语法高亮”吗? - guido
3个回答

13

就这个问题而言,现在(问题提出后3年),汇编似乎运行良好。

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

7

不同的Markdown实现可能会使用不同的语法高亮字符串。

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

可惜没有汇编语言的支持。
根据这个元问题,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文件:https://github.com/github/linguist/blob/master/lib/linguist/languages.yml 正确的字符串是assembly

Discord: 可以在此处找到语言列表:https://highlightjs.org/static/demo/ 对于Intel x86,相关代码是x86asm


1

他们的“语言学家”引擎只能识别有限的语言进行语法高亮。似乎汇编代码不在其中,因为我在他们的linguist/samples目录中找不到任何示例。

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


1
这个答案已经过时了。正如下面的alexo_o所解释的,你需要使用assembly指定符。nasmasm也可以工作。 - pchaigno

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接