GithubHelp home page GithubHelp logo

Comments (4)

stefaneidelloth avatar stefaneidelloth commented on August 16, 2024

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>

from adoc-usermacro.

gotnix avatar gotnix commented on August 16, 2024

It would be more convenient to put the file on the CDNJS, just like asciidoctor.js.

from adoc-usermacro.

jaredmorgs avatar jaredmorgs commented on August 16, 2024

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>

from adoc-usermacro.

stefaneidelloth avatar stefaneidelloth commented on August 16, 2024

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.

from adoc-usermacro.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.