adoc-usermacro
adoc-usermacro copied to clipboard
Links to www.norganna.com are dead.
The code template includes some references to www.norganna.com that do not work.
=> Please update the link or => Please update the documentation on how to modify the template to get it working.
I tried to reference my own javascript files and use the raw css files from this github repo. However, I did not get it working.
Got it working using my own links. (Replace http://myserver with your server if you want to use this example)
## Macro name: adoc
## Macro title: AsciiDoc Markup with Asciidoctor
## Categories: Formatting
## Description: Display content in AsciiDoc format using the asciidoctor.js engine.
## Visibility: to all users
## Icon URL: https://raw.githubusercontent.com/norganna/adoc-usermacro/master/adoc.png
## Documentation URL: http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
## Macro has a body: Y
## Body processing: Unrendered
## Generates: HTML
##
## @noparams
##
## Developed by: Ken Allan (https://github.com/norganna)
## Date created: 2015-09-02
## Modified by Stefan Eidelloth
## You can select whether to use the Foundation AsciiDoctor style, which will make articles look different to standard confluence styles, or leave it as is if
##you want to achieve something closer to the standard Confluence styling by setting the following to either "confluence" or "foundation":
#set($style="confluence")
## A handy macro to generate a new random ID between 0 and maxint each time you call it:
#set ($randomId="")
#macro(getRandomId)
#set ($string="")
#set ($rand=$string.class.forName("java.util.Random").getConstructor().newInstance())
#set ($randomId=$rand.nextInt(2147483647).toString())
#end
#getRandomId()
<div id="adoc-content-$randomId" class="adoc-content">
</div>
#if($style == "confluence")
<link type="text/css" rel="stylesheet" href="http://**myserver**/adoc-confluence.css" media="all">
#else
##<link type="text/css" rel="stylesheet" href="http://**myserver**/adoc-foundation.css" media="all">
#end
## This CSS is the FontAwesome font which enables the admonition icons.
<link type="text/css" rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" media="all">
##reference to asciidoctor.js
<script src="http://**myserver**/asciidoctor.min.js">
</script>
##reference to mathjax.js
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { fonts: ["TeX"] }
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js">
<script>
jQuery(function() {
var asciidocContent= $jsonator.convert($body).serialize();
var asciidoctor = Asciidoctor();
var asciidoctorOptions = {
safe: 'safe'
};
var renderedHtmlOutput = asciidoctor.convert(asciidocContent, asciidoctorOptions);
jQuery('#adoc-content-$randomId').html(renderedHtmlOutput);
});
</script>
It would be more convenient to put the file on the CDNJS, just like asciidoctor.js.
Hey @stefaneidelloth did you have any luck with replacing the asciidoctor.min.js with a cdnjs link?
##reference to asciidoctor.js
<script src="http://**myserver**/asciidoctor.min.js">
</script>
I used the following:
##reference to asciidoctor.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/asciidoctor.js/1.5.9/asciidoctor.min.js">
</script>
Did you also have success replacing the css files with hosted locations? I went to the themes demo for Asciidoctor and loaded in the following templates as a first step:
#if($style == "confluence")
<link type="text/css" rel="stylesheet" href="http://themes.asciidoctor.org/stylesheets/asciidoctor.css" media="all">
#else
##<link type="text/css" rel="stylesheet" href="http://themes.asciidoctor.org/stylesheets/asciidoctor.css" media="all">
#end
I realise that both conditions refer to the same stylesheet location but for now I'm OK with that. I just want to see if I can get this working to a point where I can get safe mode working and load files in from Bitbucket or raw files.
At this stage I'm not getting a rendered view of the basic AsciiDoc text I've defined in the macro body.
The full version of my macro is here:
## Macro name: adoc
## Macro title: AsciiDoc Markup with Asciidoctor
## Categories: Formatting
## Description: Display content in AsciiDoc format using the asciidoctor.js engine.
## Visibility: to all users
## Icon URL: https://raw.githubusercontent.com/norganna/adoc-usermacro/master/adoc.png
## Documentation URL: http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
## Macro has a body: Y
## Body processing: Unrendered
## Generates: HTML
##
## @noparams
##
## Developed by: Ken Allan (https://github.com/norganna)
## Date created: 2015-09-02
## Modified by Stefan Eidelloth
## You can select whether to use the Foundation AsciiDoctor style, which will make articles look different to standard confluence styles, or leave it as is if
##you want to achieve something closer to the standard Confluence styling by setting the following to either "confluence" or "foundation":
#set($style="confluence")
## A handy macro to generate a new random ID between 0 and maxint each time you call it:
#set ($randomId="")
#macro(getRandomId)
#set ($string="")
#set ($rand=$string.class.forName("java.util.Random").getConstructor().newInstance())
#set ($randomId=$rand.nextInt(2147483647).toString())
#end
#getRandomId()
<div id="adoc-content-$randomId" class="adoc-content">
</div>
#if($style == "confluence")
<link type="text/css" rel="stylesheet" href="http://themes.asciidoctor.org/stylesheets/asciidoctor.css" media="all">
#else
#<link type="text/css" rel="stylesheet" href="http://themes.asciidoctor.org/stylesheets/asciidoctor.css" media="all">
#end
## This CSS is the FontAwesome font which enables the admonition icons.
<link type="text/css" rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" media="all">
##reference to asciidoctor.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/asciidoctor.js/1.5.9/asciidoctor.min.js">
</script>
##reference to mathjax.js
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { fonts: ["TeX"] }
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js">
<script>
jQuery(function() {
var asciidocContent= $jsonator.convert($body).serialize();
var asciidoctor = Asciidoctor();
var asciidoctorOptions = {
safe: 'safe'
};
var renderedHtmlOutput = asciidoctor.convert(asciidocContent, asciidoctorOptions);
jQuery('#adoc-content-$randomId').html(renderedHtmlOutput);
});
</script>
I don't use Confluence any more. I roughly remember that I had to serve the files from our own server due to cross reference - or mime type - issues when linking the files from github. CDNJS might work. Did not try.