kovetskiy / mark

Sync your markdown files with Confluence pages.
https://samizdat.dev
Other
988 stars 147 forks source link

ac:details usage issues #466

Closed OnceUponALoop closed 1 month ago

OnceUponALoop commented 1 month ago

What happened?

I'm trying to use the ac:details template to populate page properties but i'm unable to due to errors in parsing.

com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format

What did you expect to happen?

I expected a page properties element with a table of key value pairs

image

How can we reproduce the behavior you experienced?

Using the following example

<!-- Space: ~01234567 -->
<!-- Parent: Test -->
<!-- Title: Testing Mark -->

<!-- Macro: :details_start:([^:][\s\S]*?):details_end:
     Template: ac:details
     Body: ${1}
-->

:details_start:
| Key1 | Key2 |
| --- | --- |
| Value1 | Value 2 |

:details_end:

Further Information (please complete the following information)

Logs or other output

Markdown parsing section of the log

2024-07-15 18:07:18.471 TRACE rendering markdown:

                              <ac:structured-macro ac:name="details" ac:schema-version="1""><ac:rich-text-body>
                              | Key1 | Key2 |
                              | --- | --- |
                              | Value1 | Value 2 |

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

2024-07-15 18:07:18.471 TRACE rendered markdown to html:
                              <p>&lt;ac:structured-macro ac:name=&quot;details&quot; ac:schema-version=&quot;1&quot;&quot;&gt;<ac:rich-text-body></p>
                              <table>
                              <thead>
                              <tr>
                              <th>Key1</th>
                              <th>Key2</th>
                              </tr>
                              </thead>
                              <tbody>
                              <tr>
                              <td>Value1</td>
                              <td>Value 2</td>
                              </tr>
                              </tbody>
                              </table>
                              <p></ac:rich-text-body></ac:structured-macro></p>

Additional context

I'm unclear if my ac:details usage is correct.

Looking at the code it seems there's an extra " in the <ac:structured-macro ac:name="details" ac:schema-version="1""> line (here) but i'm unsure if that's the cause of my problem.

I don't currently have a golang build env otherwise I would test fixing it myself

OnceUponALoop commented 1 month ago

Attempt 1 - Manual Definition (Fail)

I tried just defining the html manually, that seems to break due to the <p> incorrectly wrapping the ac instead of the table

<!-- Space: ~0123456 -->
<!-- Parent: Test -->
<!-- Title: Testing Mark -->

<ac:structured-macro ac:name="details" ac:schema-version="1">
<ac:rich-text-body><table>
  <thead>
    <tr>
      <th>Key1</th>
      <th>Key2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Value1</td>
      <td>Value2</td>
    </tr>
  </tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>

TRACE

2024-07-15 18:20:09.558 TRACE rendering markdown:

                              <ac:structured-macro ac:name="details" ac:schema-version="1">
                              <ac:rich-text-body><table>
                                <thead>
                                  <tr>
                                    <th>Key1</th>
                                    <th>Key2</th>
                                  </tr>
                                </thead>
                                <tbody>
                                  <tr>
                                    <td>Value1</td>
                                    <td>Value2</td>
                                  </tr>
                                </tbody>
                              </table>
                              </ac:rich-text-body>
                              </ac:structured-macro>

2024-07-15 18:20:09.559 TRACE rendered markdown to html:
                              <p><ac:structured-macro ac:name="details" ac:schema-version="1">
                              <ac:rich-text-body><table></p>
                                <thead>
                                  <tr>
                                    <th>Key1</th>
                                    <th>Key2</th>
                                  </tr>
                                </thead>
                                <tbody>
                                  <tr>
                                    <td>Value1</td>
                                    <td>Value2</td>
                                  </tr>
                                </tbody>
                              </table>
                              </ac:rich-text-body>
                              </ac:structured-macro>
OnceUponALoop commented 1 month ago

Attempt 2 - Manual Definition (Works)

If I take my table and make it a one-line it works. Here the <p> surrounds the whole thing.

<ac:structured-macro ac:name="details" ac:schema-version="1">
<ac:rich-text-body><table><thead><tr><th>Key1</th><th>Key2</th></tr></thead><tbody><tr><td>Value1</td><td>Value2</td></tr></tbody></table>
</ac:rich-text-body>
</ac:structured-macro>

TRACE

2024-07-15 18:25:01.143 TRACE rendering markdown:

                              <ac:structured-macro ac:name="details" ac:schema-version="1">
                              <ac:rich-text-body><table><thead><tr><th>Key1</th><th>Key2</th></tr></thead><tbody><tr><td>Value1</td><td>Value2</td></tr></tbody></table>
                              </ac:rich-text-body>
                              </ac:structured-macro>

2024-07-15 18:25:01.144 TRACE rendered markdown to html:
                              <p><ac:structured-macro ac:name="details" ac:schema-version="1">
                              <ac:rich-text-body><table><thead><tr><th>Key1</th><th>Key2</th></tr></thead><tbody><tr><td>Value1</td><td>Value2</td></tr></tbody></table>
                              </ac:rich-text-body>
                              </ac:structured-macro></p>
mrueg commented 1 month ago

Yes that unfortunately doesn't work right now. See also: https://github.com/kovetskiy/mark/issues/324

OnceUponALoop commented 1 month ago

Btw I rebuilt it after removing the syntax error (here) but the behavior remained the same.

Like you I looked into block parsing but couldn't get it to work properly. I ran it through the debugger for a while and finally gave up, waiting for someone smarter to dust it off :|

mrueg commented 1 month ago

Good catch! Quoting is fixed in 9.13.1. Feel free to give it a shot.

mrueg commented 1 month ago

Please test with https://github.com/kovetskiy/mark/releases/tag/10.0.0 and report back if it's still not working as expected.

OnceUponALoop commented 3 weeks ago

Can confirm - working as expected now :clap:

024-08-01 12:10:51.432 TRACE rendering markdown:

                              <ac:structured-macro ac:name="details" ac:schema-version="1"><ac:rich-text-body>
                              | Key1 | Key2 |
                              | --- | --- |
                              | Value1 | Value 2 |

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

2024-08-01 12:10:51.433 TRACE rendered markdown to html:
                              <ac:structured-macro ac:name="details" ac:schema-version="1"><ac:rich-text-body>
                              <table>
                              <thead>
                              <tr>
                              <th>Key1</th>
                              <th>Key2</th>
                              </tr>
                              </thead>
                              <tbody>
                              <tr>
                              <td>Value1</td>
                              <td>Value 2</td>
                              </tr>
                              </tbody>
                              </table>
                              </ac:rich-text-body></ac:structured-macro>