Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Div
idProductTOC

On this page

Table of Contents
maxLevel1
excludeOn this page
typeflat
separatorpipe


Warning
titleRemoval notice:

Please note that the URL user and URL password parameters are removed from 2.2.4 release. We recommend using profiles to access your data from remote locations.

Overview

Excerpt

The The Code Pro macro extends the native code Code macro. The following features are included:

  • Source code can be from any of these sources:
    • Within your Confluence page (same as the code macro).
    • From an external URL. For example: Bitbucket, GitHub, or Stash.
    • From a file residing on the Confluence server. For example, a clone of a Git or Mercurial repository.
    • From a page attachment.
    • From a global or space template.
  • Syntax highlighting equivalent to code macro Code macro. Recognizes the same language extensions added to the code macro.
  • Supports all the current code macro Code macro parameters.
  • Subset by line number or regex selection - see Sections parameter. Allows showing one or more sections of code from the same source.
  • Expand and collapse support similar to the expand Expand macro. Option to show or collapse on initial display.
  • Automatic title generation from the file or path name.
  • Profiles allow administrators to pre-configure access to repositories and hide access credentials.
  • Enabled for CMSP to allow control of url and profile parameters. See Macro Security Managed Macros.


Info
titleUnder the covers

After retrieving the source code from the various sources, the code macro Code macro is then used under the covers. This means behavior will be equivalent to existing code macro Code macro behavior! The native code macro Code macro must be enabled (the default).

...

This macro can be deployed using one of the following methods:

Selected from the Macro Browsermacro browsercode-pro
Markup Shortcutshortcut{code-pro}

Screenshot

Image RemovedImage Added

Parameters

(info) Click a column heading to toggle the sorting of that column.

...

highlightColor#ffffec
rowStylesbackground:#f0f0f0;color:#222;font-size:14px;border-bottom:black 2px solid;border-top:black 2px solid;,
stylebackground-color:white;
autoNumbertrue

...

Parameter

...

Default

...

...

Macro editor label
CodeCode Pro
Default
Description

...

Macro parameter
Profile
(tick)

...


Select a profile from the list. Profiles are pre-defined, parameter defaults configured by your administrator. The saved parameters can be re-used across multiple macro instances. Provides support for defaulting various parameters including

...

URL related parameters:

...

URL to source code, URL user, URL password, and URL connection timeout.

If needed, usage of specific profiles can be controlled by administrators using CMSP. Profiles offer a way to secure user and password information for non-public sites.

...

profile
Language for syntax highlighting(tick)(tick)

Select from a list of languages shipped by default with the

...

Code macro. New languages can be added by using the

...

Code macro configuration. The following is the current list of shipped default languages

...

:

Table plus
autoNumbertrue


Macro Browser SelectionAliases for Wiki Markup Use
ActionScriptactionscript3, as3, actionscript
AppleScriptapplescript
Bashbash, shell
C#c#, c-sharp, csharp
C++cpp, c
CSScss
ColdFusioncoldfusion, cf
Delphidelphi, pascal, pas
Diffdiff, patch
Erlangerl, erlang
Groovygroovy
HTML and XMLxml, xhtml, xslt, html, html/xml
Javajava
Java FXjfx, javafx
JavaScriptjs, jscript, javascript
PHPphp
Perlperl, Perl, pl
Plain Texttext, plain
PowerShellpowershell, ps
Pythonpy, python
Rubyruby, rails, ror, rb
SQLsql
Sasssass, scss
Scalascala
Visual Basicvb, vbnet

...



language
Title(tick)(tick)

...


Enter the title of the code panel. May default to title provided in profile.

Table plus


Special ValueReplacement
@path


Table plus


LocationReplacementExample
URLPath portion of URLraw/master/src/main/resource/atlassian-plugin.xml
AttachmentAttachment path and name as specifiedmyspace:home^report.groovy
FileRelative file system pathsrc/main/resource/atlassian-plugin.xml
TemplateTemplate pathmytemplate or myspace:mytemplate
Otherblank



@file


Table plus


LocationReplacementExample
URLFile portion of URLatlassian-plugin.xml
AttachmentAttachment file namereport.groovy
FileFile name with extensionatlassian-plugin.xml
TemplateTemplate namemytemplate
Otherblank

...






title

...

Show line numbers(tick)(tick)

...

falseEnable this option to show line numbers for the source.

...

linenumbers
URL to source code 
(tick)

...


Enter the URL of a source file. If specified, the included data will follow the body and script data (if any). Always use the raw or download link to your source and not the HTML link your repository manager shows. Use of this parameter may be restricted for security reasons. See your administrator for details.

Examples:

  1. GIT repository on Bitbucket: https://bitbucket.org/examplegear/tools/raw/master/...
  2. Mercurial repository on Bitbucket: https://bitbucket.org/examplegear/tools/raw/tip/...

...

url
URL

...

user (Removed)
(tick)

...


Enter user name required to access URL access via basic authentication. 

Warning
titleRemoval notice:

Please note that the URL user and URL password parameters are removed from 2.2.4 release. We recommend using profiles to access your data from remote locations.


user
URL user

...

password (Removed)
(tick)

...


Enter the password required to access the specified URL via basic authentication. 

...

Warning
titleRemoval notice:

Please note that the URL user and URL password parameters are removed from 2.2.4 release. We recommend using profiles to access your data from remote locations.


password
URL connection timeout
(tick)

...


Enter time in milliseconds such that URL connections does not disconnect before getting data. Use this to increase the access time needed for slow connections. Note that if a zero is given the connection may wait infinitely.timeout
Location of source code
(tick)macro body

Enter the location of the attachment. If left blank, the macro body content is used unless a URL is given in URL to source code. If a location is specified, the included data

...

follows the body data (if any).

The following options are available:

  • ^attachment - Data is read from an attachment to the current page.
  • page^attachment - Data is read from an attachment to the page name provided.
  • space:page^attachment - Data is read from an attachment to the page name provided in the space indicated.
  • #filename - Data is read from the file located in

...

  • Confluence home directory/script/filename. Subdirectories can be specified.
  • global page template name - Data is read from a global page template.
  • space:page template name - Data is read from a space template.

...

script
Sections
(tick)

...


Enter a comma separated list of section selections. A selection can be a simple literal string or a range specified by line numbers or regular expressions. Each selection identifies one or more lines of the code that will be displayed. Since 1.1. Sections parameter has more details.

Include Page
_SectionsParameterTable
_SectionsParameterTable

...


sections

...

Collapse section type
 (tick)default

Collapse section type that determines how the expand and collapse section looks and behaves.

The following options are available:

  • blank - Use setting from profile or default to Classic if

...

  • Collapse initially is enabled.
  • Expand - Section appears like the expand macro. Recommended for inter-operability with the expand macro. Provides option to expand on initial display.
  • Classic - Compatibility with the 

...

  • Code macro. Does not support ability to expand on initial display.

...

collapseType

...

Collapse initially

...

(tick)(tick)

...

falseSelect to

...

show the code section

...

as collapsed.

...

collapse
First line number(tick)(tick)

...


Enter the number to display for the first line.

...

The first line is forced to be this number, otherwise line numbers start at 1.firstline
Theme(tick)(tick)DefaultSelect the CSS theme to

...

be applied. Same as

...

Code macro.

...

theme
File encoding
(tick)

...


Specify the encoding for an external file, if different

...

from default system

...

handling.

...

 Example: UTF8. encoding


Examples

You can get source from virtually any repository or other source of data provided they provide a url URL link to the raw source the raw source text (as if you were downloading the source file). Here are just a few examples.

Table plus
autoNumbertrue


Example Macro browser and Wiki markup
Simple macro body

Code Block
{code-pro:language=sql}
select * from places
{code-pro} 


Access Bitbucket Cloud

  • Git


Code Block
{code-pro:language=java
|linenumbers=true
|url=https://bitbucket.org/myuser/confluence-code-pro/src/master/src/main/java/com/appfire/confluence/codepro/Section.java}


Access Bitbucket Cloud 

  • Mercurial 

Code Block
{code-pro:language=groovy
|linenumbers=true
|url=https://bitbucket.org/bob_swift/gint/raw/tip/src/main/groovy/org/swift/tools/Gint.groovy}


Tip

This is a public repository, so you can try this exact configuration yourself.


Access Bitbucket Server

  • Git


Code Block
{code-pro:language=groovy
|linenumbers=true
|url=https://bitbucket.examplegear.com/projects/MYPROJECT/repos/gint/raw/src/main/groovy/org/swift/Gint.groovy}


Access Github

  • Using profile
  • Relative url 

No Format
nopaneltrue
{code-pro:profile=github
|language=javascript
|linenumbers=true
|url=/ruipgil/scraperjs/raw/master/src/DynamicScraper.js} 


Access FishEye


No Format
nopaneltrue
{code-pro:
|language=groovy
|linenumbers=true
|url=.../browse/~raw,r=default/confluence-wiki/src/itest/groovy/wiki.gant} 



...