How to format an inline code in Confluence?

2019-01-29 19:11发布

How can I format an inline code in Confluence like this? I mean, not a separate code block, but just inline classname, for example.

14条回答
霸刀☆藐视天下
2楼-- · 2019-01-29 19:15

If you have WinWord, you can copy what you need into that, touch up the results, and then paste that into Confluence. I've found that easier than the other solutions here.

查看更多
淡お忘
3楼-- · 2019-01-29 19:16

If you want to insert a large code block with optional line numbers, etc use the Code Macro (available under Macros -> Other).

查看更多
干净又极端
4楼-- · 2019-01-29 19:20

In Confluence 5.4.2 you can add surround your inline code with <code></code> tags in the source editor thusly:

Confluence will show <code>this inline code</code> in a fixed font. 

This can be useful where there are many fragments to modify since the double-brace feature only works when adding text interactively in the Confluence editor.

查看更多
我命由我不由天
5楼-- · 2019-01-29 19:21

I use a combination of Zelphir and Peter Gluck's answers. i.e.

  1. (Mac-speak) Click COMMAND + SHIFT + D
  2. Select Markdown in the dropdown of the model pop-up
  3. Surround your text with the code tag - i.e. <code>bovvered</code>
  4. Click INSERT
查看更多
疯言疯语
6楼-- · 2019-01-29 19:23

You could ask your fiendly Confluence administrator to create a macro for you. Here is an example of a macro for Confluence 3.x

Macro Name:    inlinecode
Macro Title:   Markup text like stackoverflow inline code
Categories:    Formatting
Macro Body Processing: Convert wiki markup to HTML
Output Format: HTML
Template:

## Macro title: Inline Code
## Macro has a body: Y
## Body processing: Convert wiki markup to HTML
## Output: HTML
##
## Developed by: My Name
## Date created: dd/mm/yyyy
## Installed by: My Name
## This makes the body text look like inline code markup from stackoverflow
## @noparams
<span style="padding: 1px 5px 1px 5px; font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif; background-color: #eeeeee;">$body</span>

Then users can use {inlinecode}like this{inlinecode}

You could also use the {html} or {style} macros if they are installed or add this style to the stylesheet for your space.

While you are at it ask your Confluence admin to create a kbd macro for you. Same as the above, except Macro name is kbd and Template is:

<span style="padding: 0.1em 0.6em;border: 1px solid #ccc; font-size: 11px; font-family: Arial,Helvetica,sans-serif; background-color: #f7f7f7; color: #333;  -moz-box-shadow: 0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset; -webkit-box-shadow: 0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset; box-shadow: 0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; display: inline-block; margin: 0 0.1em; text-shadow: 0 1px 0 #fff; line-height: 1.4; white-space: nowrap; ">$body</span> 

Then you can write documentation to tell users to hit the F1 and Enter keys.

查看更多
冷血范
7楼-- · 2019-01-29 19:27

As of Confluence 4 and above, typing two curly brackets does not work.

You now need to select Monospace font. Highlight the text you want to change and:

Windows: Ctrl + Shift + M

Mac: Command + Shift + M

Alternatively, next to the bold and italic options, you can click the "more" drop down and select Monospace:

enter image description here

查看更多
登录 后发表回答