如何在字面字符串中缩进文字?

发布于 2025-02-04 02:33:03 字数 936 浏览 2 评论 0 原文

我想通过划线,然后是缩进的字面输出,以使结果看起来像这样:

int write(const std::string sFileName, int iStep, float fStartTime,
          const std::string sInfoString, int iWhat

但是当我使用它时

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``          const std::string sInfoString, int iWhat,``

int write(const std::string sFileName, int iStep, float fStartTime,
`` const std::string sInfoString, int iWhat,``

我也尝试了一个非破坏空间的Unicode替换:

 .. |xx| unicode:: U+00A0

但这不是替换:

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``|xx||xx||xx|const std::string sInfoString, int iWhat,``

结果

int write(const std::string sFileName, int iStep, float fStartTime,
|xx||xx||xx|const std::string sInfoString, int iWhat

如何在双重报价之间达到我想要的凹痕?

I would like to get literal output with a line break, and then an indentation, so that the result would look like this:

int write(const std::string sFileName, int iStep, float fStartTime,
          const std::string sInfoString, int iWhat

But when i use this

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``          const std::string sInfoString, int iWhat,``

i get

int write(const std::string sFileName, int iStep, float fStartTime,
`` const std::string sInfoString, int iWhat,``

I also tried a unicode substitution for non-breaking space:

 .. |xx| unicode:: U+00A0

But this is not being substituted:

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``|xx||xx||xx|const std::string sInfoString, int iWhat,``

results in

int write(const std::string sFileName, int iStep, float fStartTime,
|xx||xx||xx|const std::string sInfoString, int iWhat

How can achieve the indentation i want between the double back-quotes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶ ̄淡然 2025-02-11 02:33:03

我建议使用指令。凹痕将相对于第一行代码渲染。

.. code-block:: c++

    int write(const std::string sFileName, int iStep, float fStartTime,
              const std::string sInfoString, int iWhat

另外,我不知道您使用的是什么语言,但是您可以通过在 mylang 来代替 mylang “ rel =“ nofollow noreferrer”> Pygments Lexers Page

编辑

更新以使用 lexer code> c ++ c ++

I would suggest using the code-block directive. Indentation will be rendered relative to the first line of code.

.. code-block:: c++

    int write(const std::string sFileName, int iStep, float fStartTime,
              const std::string sInfoString, int iWhat

Also I don't know what language you use, but you can substitute the proper lexer for mylang by looking it up on the Pygments lexers page.

Edit

Updated to use the lexer c++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文