GitHub markdown不会渲染并且git在没有变化时检测到变化 [英] GitHub markdown not rendering and git detecting changes when no changes
问题描述
我在GitHub markdown,VSCode markdown扩展和其他地方也注意到了一个小故障.在GitHub上并使用git时,它的行为特别异常.
There's a glitch that I've noticed in GitHub markdown, the VSCode markdown extension and other places too. It's behaving particularly unusually on GitHub and using git.
当我输入诸如# heading
或## sub-heading
之类的标题时,标题经常显示不正确.这是一个降价文件的提交示例:
Very frequently when I type in headings such as # heading
or ## sub-heading
, the heading does not render correctly. Here is an example commit for a markdown file:
来源差异:
富差异:
如您所见,丰富的差异无法正确呈现,当我进入浏览文件"(无论我使用什么计算机/设备)时,文件也没有正确呈现:
As you can see, the rich diff isn't rendering correctly, and so isn't the file when I go into "browse files" (regardless of what computer/device I use):
以某种方式,在删除###
之后的空格字符并重新键入之后,需要进行更改.据我所知,这是不应该发生的(因为实际上没有任何改变,我只是重新输入了空格字符).但无论如何,我还是提交了它,并得到了以下差异:
Somehow, after deleting the space character after ###
and re-typing it, there were changes to be committed. From my knowledge this shouldn't happen (because nothing has actually changed, I just re-typed the space character). But I committed it anyways and got the following diff:
您会看到空格字符已突出显示.现在,我神奇地得到了以下丰富的差异,它现在显示标题:
As you can see the space character is highlighted. Now I magically get the following rich diff, which is now showing the heading:
现在,当我浏览文件"时,标题显示在我使用的每台计算机上:
And now, when I "browse files", the heading shows on every computer I use:
这在我身上经常发生,我想知道为什么会这样,git怎么甚至不能提交更改,是否有办法解决这个问题?
This is happening to my a lot, and I'm wondering why this is happening, how git is even able to commit no change, and if there is a way to solve this?
这绝对不只是我,因为过去其他人也向我提到过这一点.
This is definitely not just me because others have mentioned this to me too in the past.
注意:我的GitHub存储库是私有的,因此我不能共享链接,但是应该易于复制.
Note: My GitHub repo is private so I can't share a link, but it should be easy to reproduce.
更新
我打开了HxD中存在问题的修订,并获得了以下十六进制输出:
I opened the revision with the issue inside HxD and got the following hex output:
然后我替换了VSCode中的空格字符,并获得了以下十六进制输出:
I then replaced the space character inside VSCode and got the following hex output:
还有一个额外的Â
字符,该字符未在VSCode中显示并且我没有输入.我在Windows和Mac OS上都遇到了这个问题.
There's an extra Â
character that is not shown in VSCode and that I didn't input. I've had this problem on both Windows and Mac OS.
更新2
ascii和utf-8都将字符定义为Â
,所以我不知道为什么它未在VSCode或GitHub文本编辑器中显示.
Both ascii and utf-8 define the character as Â
so I can't figure out why it's not showing up in VSCode or GitHub text editor.
我还在 https://www.asciitable.com/上看到ascii对其进行了如下定义. a>
推荐答案
字节序列0xC2 0xA0
是字符不间断空格字符,它解释了为什么它看起来像一个空格在编辑器中显示,并且与简单空间相比有区别.
The byte sequence 0xC2 0xA0
is the UTF-8 sequence of for the character U+00A0
NO-BREAK SPACE. So it is a non-breaking space character which explains why it is looking like a space in editors and shows up as a difference when compared to a simple space.
它在十六进制编辑器中显示为Â
的事实仅仅是因为十六进制编辑器一次只显示一个字节,所以只在文本表示形式中显示ASCII.因此,他们不会寻找这样的字符序列,而UTF-8则需要这样的字符序列才能在ASCII空间之外对字符进行编码.
The fact that it shows up as Â
within the hex editor is simply because hex editors only ever display ASCII in the text representation since they only look at a single byte at a time. So they don’t look for character sequences like this which is required for UTF-8 to encode characters outside of the ASCII space.
关于不间断空格破坏Markdown解析器的原因,如果解析器符合 CommonMark规范一个>.根据它,ATX标题必须后跟一个空格,其中空格明确定义为U+0020
SPACE字符.
As for why the non-breaking space breaks the Markdown parser, this is expected if the parser conforms to the CommonMark specification. According to it, the ATX headings are required to be followed by a space, where a space is explicitly defined to be a U+0020
SPACE character.
这篇关于GitHub markdown不会渲染并且git在没有变化时检测到变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!