Comments (6)
Could you provide an example of how this new function would be used within an Rmd document? I've had some success embedding macro's like this:
p(tag("ac:structured-macro", list("ac:name"="expand", "ac:schema"="1", "ac:macro-id"="80df63ef-6ccf-4270-84d9-d3bc5f9a3ff8", tag("ac:parameter", list("ac:name"="title", "Click here to expand...")), tag("ac:rich-text-body", "Hidden Text"))))
But what I would like to do is embed images within the Expand macro (and/or nest more Expand's). Do you know if this is possible?
from conflr.
Thanks for the idea. Do you mean using macro in markup form like this?
{expand:This is my message}
This text is _hidden_ until you expand it.
{expand}
If so, it would be a bit tricky because Confluence's REST API doesn't directly support the format.
c.f. #54 (comment)
from conflr.
Well, I guess I just mean being able to invoke macros in any way possible. I'm not that familiar with the Confluence API, but it looks like you send the body as html (is this "storage format"?)?
Funny enough, I just tried inserting the following macro into my Rmd and it rendered properly when published to Confluence:
<p><ac:structured-macro ac:name="status" ac:schema-version="1" ac:macro-id="77d8c727-052a-4875-9591-9d0674e2fa22"><ac:parameter ac:name="title">Status</ac:parameter></ac:structured-macro></p>
Pretty neat! So it looks like a decent solution is to figure out the tags for a macro within Confluence itself and then just copy+paste that into one's Rmd.
from conflr.
Oh, I see. Glad to know inserting the <ac:...>
tag directly works! (though probably I need to implement some tweak to prevent the content of the tag from various conversions by conflr...)
but it looks like you send the body as html (is this "storage format"?)?
Yes, it's Confluence Storage Format.
from conflr.
Gotcha. Looks like it's some kind of custom XML/HTML format. I think I have a better idea of how the render + API posting process is working in this package now.
One idea is that one can use the htmltools
package inside of a knitr chunk, like so:
```{r}
library(htmltools)
p(tag("ac:structured-macro",list("ac:name"="status", "ac:schema"="1", tag("ac:parameter", list("ac:name"="title", "DRAFT")))))
```
It would probably be rather tedious to encode every Confluence macro in its own function, but it might be fairly easy to just create some tag()
functions for the most relevant tags (ac:structured-macro
and ac:parameter
).
I actually think it might be possible to do something like you originally suggested with the markup format too, by having a function that calls the conversion endpoint on Confluence's API:
Their documentation provides the following example of posting some markup:
curl -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"value":"{cheese}",
"representation":"wiki"}' "http://localhost:8080/confluence/rest/api/contentbody/convert/storage"
| python -mjson.tool
...which gets converted to storage format:
{
"_links": {
"base": "http://localhost:8080/confluence"
},
"representation": "storage",
"value": "<ac:structured-macro ac:name=\"cheese\" />"
}
So one idea could be to have a function convert_macro
that talks to the Confluence API to convert the macro markup and returns the corresponding storage format:
conflr::convert_macro(
"{expand:This is my message}
This text is _hidden_ until you expand it.
{expand}"
)
That function could just be used on its own easily enough, but it could also possibly be used somewhere in the rendering process via hook or similar. For example, with a knitr chunk hook, I think one could then define a custom knitr block, like so...
```{block, type='conflr-macro'}
{expand:This is my message}
This text is _hidden_ until you expand it.
{expand}
```
Defining a knitr engine may be another approach, but I think that has the disadvantage of not being able to share variables within the block w/o getting fancy with engine options. (The same may be true of the block
chunk engine though).
Anyway, none of this might be useful or necessary, but I thought I'd make a record of some options :)
from conflr.
So one idea could be to have a function
convert_macro
that talks to the Confluence API to convert the macro markup and returns the corresponding storage format:
Thanks, not sure how useful it would be, but I added a function confl_contentbody_convert()
(#58).
from conflr.
Related Issues (20)
- Error after rendering HOT 4
- error during uploading of images HOT 1
- How can I publish R package documentation to confluence HOT 4
- Issue 'Base URL of Confluence API' "Error : ! Invalid credentials" RStudio HOT 2
- post to confluence from html HOT 3
- Including interactive network map with visNetwork? HOT 1
- Error rendering macro 'code' HOT 1
- Is it possible to programmatically untick "notify watchers" when posting to confluence? HOT 3
- `code_folding: hide` is not folding code HOT 2
- 403 forbidden HOT 3
- read html file as `body` in `conflr::confl_update_page()` HOT 2
- Rmarkdown upload with interactive plots HOT 2
- Fix for inline maths/ list elements not getting translated
- Invalid credentials / no access with personal access token
- add R markdown template
- Quarto support HOT 1
- Links to headings
- How to create links to top of the document?
- scrollbars on wide tables? HOT 1
- DT::datatable only shows header HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conflr.