Macro to replace tab with 4 spaces?

E September 2, 2012

If it possible to create a user macro that can replace a tab with 4 spaces?

The Codeblock macro has a bug that means tabs print as a single space, so I'm wondering if a macro could be created that would create a code block and then look at the text entered in the codeblock and replace the tabs with 4 spaces.

Is this possible? Any suggestions how?

1 answer

0 votes
CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 3, 2012
I imagine the code block can be pinpointed easily, perhaps because it is a div with a certain class. In this case I would suggest trying to use jQuery to analyse the div content and replace the tab character with four non breaking space characters. JQuery is bundled with Confluence, so is easily used in user macros. String replacement example: http://www.jquery4u.com/dom-modification/replace-string-characters-javascript/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events