Git Product home page Git Product logo

Comments (13)

yutannihilation avatar yutannihilation commented on May 23, 2024 1

A pandoc expert told me that we can use raw attribute here. Could you try this?

---
title: "test page"
output:
  conflr::confluence_document:
    space_key: "***"
---

<ac:structured-macro ac:name="expand">
  <ac:parameter ac:name="title">hidden stuff below</ac:parameter>
  <ac:rich-text-body>`<![CDATA[<p>foo</p>]]>`{=html}</ac:rich-text-body>
</ac:structured-macro>

from conflr.

atusy avatar atusy commented on May 23, 2024 1

You can also treat the whole block as raw HTML.
This would be easier to read and debug.

```{=html}
<ac:structured-macro ac:name="expand">
  <ac:parameter ac:name="title">hidden stuff below</ac:parameter>
  <ac:rich-text-body><![CDATA[<p>foo</p>]]></ac:rich-text-body>
</ac:structured-macro>
```

from conflr.

yutannihilation avatar yutannihilation commented on May 23, 2024 1

Thanks @atusy!

from conflr.

daroczig avatar daroczig commented on May 23, 2024

Jumping into translate_to_confl_macro shows the below for html_text:

[1] "<p><confl-ac-structured-macro confl-ac-name=\"expand\"> <confl-ac-parameter confl-ac-name=\"title\">hidden stuff below</confl-ac-parameter> <confl-ac-rich-text-body>&lt;![CDATA[<p>foo</p>\n</p>\n<p>]]&gt;</confl-ac-rich-text-body> </confl-ac-structured-macro></p>\n"

from conflr.

yutannihilation avatar yutannihilation commented on May 23, 2024

Hmm, thanks. I guess this is basically because CDATA syntax is not supported by commonmark (yes, GitHub flavored markdown does...). Maybe I need to bypass CDATA section...?

This Rmd (conflr uses commonmark variant)

---
output:
  md_document:
    variant: commonmark
---

<ac:rich-text-body><![CDATA[<p>foo</p>]]></ac:rich-text-body>

will be knitted to this:

<ac:rich-text-body><![CDATA[<p>foo

</p>

\]\]\></ac:rich-text-body>

from conflr.

daroczig avatar daroczig commented on May 23, 2024

Oh, I see -- thank you!

Interesting, as cdata seems to be part of the commonmark specs at https://spec.commonmark.org/0.29/#cdata-section

Anyway, do you know about any workaround passing arbitrary text in a macro using rich-text-body? Including eg an exclamation mark or similar character triggers that opening/closing tag mismatch error.

from conflr.

yutannihilation avatar yutannihilation commented on May 23, 2024

Interesting, as cdata seems to be part of the commonmark specs at https://spec.commonmark.org/0.29/#cdata-section

Wow! Sorry, then I simply misunderstood the spec...

Hmm, I don't come up with any workaround at the moment.

from conflr.

yutannihilation avatar yutannihilation commented on May 23, 2024

One problem is that ac: namespace is not recognized, so this can be avoided by replacing ac: with confl-ac- (this is done in the post processor anyway)

commonmark::markdown_commonmark("<ac:rich-text-body><![CDATA[<p>foo</p>]]></ac:rich-text-body>")
#> [1] "<ac:rich-text-body><![CDATA[<p>foo</p>]]>\\</ac:rich-text-body\\>\n"
commonmark::markdown_commonmark("<ac-rich-text-body><![CDATA[<p>foo</p>]]></ac-rich-text-body>")
#> [1] "<ac-rich-text-body><![CDATA[<p>foo</p>]]></ac-rich-text-body>\n"

Created on 2020-05-30 by the reprex package (v0.3.0)

But, this doesn't actually solve the problem. I have no idea what's happening here.

from conflr.

daroczig avatar daroczig commented on May 23, 2024

Thanks for looking into this further.

I also spent some time on this, and found that the problem for the tag mismatch is that something in the middle of the flow adds p tags, eg

<confl-ac-structured-macro confl-ac-name="expand">
  <confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter>
  <confl-ac-rich-text-body><p>foo!</p></confl-ac-rich-text-body>
</confl-ac-structured-macro>

Will be rendered in md as:

<confl-ac-structured-macro confl-ac-name="expand"> <confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter> <confl-ac-rich-text-body>

<p>

foo\!

</p>

</confl-ac-rich-text-body> </confl-ac-structured-macro>

Which is OK, but if I peek into html_text in eg translate_to_confl_macro, I see this:

<p><confl-ac-structured-macro confl-ac-name="expand"> <confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter> <confl-ac-rich-text-body></p>
<p>
<p>foo!</p>
</p>
<p></confl-ac-rich-text-body> </confl-ac-structured-macro></p>

So something adding the p tags that of course messes up the original opening/closing tags.

Any thoughts on what's causing that?

Interestingly, using eg b tags in the original text instead of p works:

<confl-ac-structured-macro confl-ac-name="expand">
  <confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter>
  <confl-ac-rich-text-body><b>foo!</b></confl-ac-rich-text-body>
</confl-ac-structured-macro>

And this actually get pushed to Confluence and renders as foo! there without any issue.

from conflr.

daroczig avatar daroczig commented on May 23, 2024

The problem is I think that commonmark::markdown_html adds those extra p tags due to the blank lines in the markdown version ... that I have no idea yet what inserts.

from conflr.

daroczig avatar daroczig commented on May 23, 2024

Well, now I think I know that's the root problem:

$ echo '<confl-ac-structured-macro confl-ac-name="expand"><confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter><confl-ac-rich-text-body><p>foo!</p></confl-ac-rich-text-body></confl-ac-structured-macro>' | pandoc -t commonmark

<confl-ac-structured-macro confl-ac-name="expand"><confl-ac-parameter confl-ac-name="title">hidden
stuff below</confl-ac-parameter><confl-ac-rich-text-body>

<p>

foo\!

</p>

</confl-ac-rich-text-body></confl-ac-structured-macro>

Sorry for the many messages here 🤦

I will let you know if I find a solution to this problem -- not really related to conflr

from conflr.

daroczig avatar daroczig commented on May 23, 2024

Awesome, thank you very much to both @yutannihilation and @atusy 🙇

FTR this is a bit more complex example on what I tried to achieve (someone might find this useful):

---
title: "gergely test page"
output:
  conflr::confluence_document:
    space_key: "***
---

```{=html}
<confl-ac-structured-macro confl-ac-name="expand">
  <confl-ac-parameter confl-ac-name="title">hidden stuff below</confl-ac-parameter>
  <confl-ac-rich-text-body>
    <p>foo! `r 4+8`</p>
    ```{r echo=FALSE, results='asis'}
    library(pander)
    panderOptions('knitr.auto.asis', FALSE)
    library(commonmark)
    cat(markdown_html(pander_return(head(iris), style = 'rmarkdown'), extensions = TRUE))
    ```
  </confl-ac-rich-text-body>
</confl-ac-structured-macro>
```

OK!

Resulting in:

image


Also, closing the ticket as no need for CDATA 😄
Thanks again!

from conflr.

yutannihilation avatar yutannihilation commented on May 23, 2024

Phew, pretty complex! Glad that you find that way, thanks for sharing.

conflr might eventually support CDATA (or introduce some special syntax for expand macro?), but I'm not sure if it's worth implementing at the moment, considering the complexity we found here. I filed a new issue #110 for this. If you find some case where we need better support for CDATA, please comment there :)

from conflr.

Related Issues (20)

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.