当然。如果信息能有所帮助,我将不胜感激。我想重申我之前的说法:
不过,我很乐意证明自己是错的
。
- 复制以下 C++ 代码:
#include <iostream> int main() { std::cout << __FILE__; } - 打开帖子编辑器。
- 将编辑器置于“富文本编辑器”模式。
- 将复制的内容粘贴到编辑器中。
内容已损坏:
#include
int main() {
std::cout << FILE;
}
(请注意,iostream 已被抑制,因为它看起来像一个不受支持的 HTML 标签,而 __FILE__ 已被当作粗体标记处理)
这可以被视为用户错误,因为可以通过在粘贴非散文内容之前触发代码块来避免这种情况。然而,我们可以预期,在粘贴内容后应用代码块格式的替代工作流程同样有效(正如在 Markdown 编辑器中使用时那样)。
设备
- 任何 Arduino 板(官方或第三方)
说明
- 安装 Arduino IDE 2.3.6,可从 Arduino 网站的“软件”页面下载:
https://www.arduino.cc/en/software/#ide-download-section - 启动 Arduino IDE。
- 在 Arduino IDE 菜单中选择 文件 > 新建草图。
- 用以下代码替换新草图的内容:
void setup() { Serial.begin(9600); while (!Serial) {} // 等待串口端口打开。 delay(500); // 一些板子在串口端口初始化后需要延迟。 Serial.println("foo"); Serial.println("bar"); } void loop() {} - 在 Arduino IDE 菜单中选择 工具 > 串行监视器,如果尚未打开,则打开“串行监视器”视图。
- 在“串行监视器”视图的波特率菜单中选择“9600”。
- 将草图上传到您的 Arduino 板。
- 从“串行监视器”视图中的字段中选择串行输出。
- 复制选定的内容。
- 打开 Discourse 帖子编辑器。
- 将编辑器置于“富文本编辑器”模式。
- 将复制的内容粘贴到编辑器中。
复制内容的每一行都放在一个单独的代码块中:
foo
bar
如果检查剪贴板内容,您会发现除了预期的“text/plain”类型内容之外:
foo
bar
它还包含以下“text/html”类型内容:
<div style="color: rgb(78, 91, 97); font-family: monospace; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: nowrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; position: absolute; left: 0px; top: 0px; height: 18px; width: 1862px;"><pre style="margin: 0px;">foo
</pre></div><div style="color: rgb(78, 91, 97); font-family: monospace; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: nowrap; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; position: absolute; left: 0px; top: 18px; height: 18px; width: 1862px;"><pre style="margin: 0px;">bar</pre></div>
由于 Arduino IDE 2.x 串行监视器错误地将复制内容的每一行包装在 <pre> 标签中,因此 Discourse 富文本编辑器将粘贴内容的每一行呈现为单独的代码块是正确的,也是符合预期的。
与我上面描述的其他问题一样,可以通过在粘贴内容之前主动触发代码块格式来避免意外的格式问题。