How do I add content for warning macro using storage format? - confluence

I'm creating a markdown to confluence tool (using python markdown). I'm having an issue adding content for the warning macro.
The following creates the warning box with the title, but the content is missing.
<ac:structured-macro ac:name="warning">
<ac:parameter ac:name="title">Do Not Modify This Page</ac:parameter>
<ac:rich-text-body><p>
This page is generated by a script. Any changes made
here will be erased the next time this page is
generated.
</p></ac:rich-text-body>
</ac:structured-macro>
The docs for the warning macro don't specify what should be used.
When I edit the warning box in the ui and get body.storage for the page this is what is returned.
<ac:structured-macro ac:name=\"warning\" ac:schema-version=\"1\" ac:macro-id=\"3520f15e-e8af-4b26-bf94-4dbc226d8284\">
<ac:parameter ac:name=\"title\">Do Not Modify This Page</ac:parameter>
<ac:rich-text-body><p>blah frickin blah</p></ac:rich-text-body>
</ac:structured-macro>
I have tried replacing <ac:rich-text-body> with nothing, plain-text-body, body, content and a few others I can't remember. None of these have worked.
Any ideas or pointers?

Adding the macro-id to the definition made it work.
<ac:structured-macro ac:name="warning" ac:macro-id="3520f15e-e8af-4b26-bf94-4dbc226d8284">
<ac:parameter ac:name="title">Do Not Modify This Page</ac:parameter>
<ac:rich-text-body><p>
This page is generated by a script. Any changes made
here will be erased the next time this page is
generated.
</p></ac:rich-text-body>
</ac:structured-macro>

Related

Have VSCode ignore specific reference links in markdown validation

In Visual Studio Code with Markdown validation enabled (markdown.validate.enabled: true), I can ignore links to specific files that may not exist in the current context via the markdown.validate.ignoredLinks setting. However, that setting does not seem to apply to reference links (e.g. [link]: some-reference), nor can I find a corresponding setting specific to reference links.
Why do I want this? My specific use-case involves an extension the "standard" (CommonMark) markdown format to auto-generate a table-of-contents using the following syntax (and no, I don't expect VSCode to generate a preview of that TOC):
[[_TOC_]]
<!-- or -->
[TOC]
VScode happily generates a warning for such links, namely:
No link definition found: 'TOC' (link.no-such-reference)
Somewhat obviously, I can make the warning disappear I define a (bogus) TOC reference, such as:
[toc]: bogus
I can also disable validation of all reference links ("markdown.validate.referenceLinks.enabled": false), but I don't want to do that. I want to ignore the error for a specific reference, much like one can ignore a GLOB pattern for file links (markdown.validate.ignoredLinks).
Does anyone know of a such a setting before I submit a bug/missing-feature report?

how do I clear the Plugin svelte: A11y: on:blur error/warning?

In svelte if I setup a <select> control like this:
<select bind:value={selected} on:change="{() => changeTheme()}">
the change event fires correctly and the value is bound but I get a warning in vscode:
(!) Plugin svelte: A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.
If I change the binding to on:blur as described, the event only works if you click elsewhere in the page after you make your selection (causing the select control to lose focus). on:click kind of works, but is annoying.
on:change seems correct - how do I clear this warning?
All you need to do is put a comment above the line with your select element.
<!-- svelte-ignore a11y-no-onchange -->
You will need to reload the window to clear the error. https://svelte.dev/docs#Comments if you're ever curious how to disable a warning in VS code it tells you the name of it after the warning, whatever is in the parenthesis goes after svelte-ignore.

Content altered in HTL/ Sightly in AEM 6

This is the weirdest issue I've ever faced in a long time. I have a URL that is authored inside a multifield. The URL has an underscore eg. http://example.net/_pinkPanther_is_pink it is currently inside ${item.link}
When I do Click <br> ${item.link} and inspect, it renders as
Click
<br> http://example.net/_pinkPanther_is_pink
If you notice both values are coming from the same variable in Sightly still when the link is used inside href of anchor tag there is double underscore added by God know who after example.net/
Does anybody have a clue as to what on earth is going on ?
That's caused by the display context aware XSS protection. Sightly/HTL automatically detects the display context of a HTL expression, using its location within the structure of the HTML page to detect it.
For example, if the expression appears in a place that would produce a text once rendered, then it is said to be in a text context. If it is found within the value of an attribute, then it is said to be in an attribute context, and so forth. More about contexts in the htl specification page.
In your example, the implicit context inside the href attribute is uri while in the later case is text.
In order to overwrite this behaviour, you may explicitly set the context like href="${item.link # context='text'}.

Mezzanine/TinyMCE filtering script type

I'm building a website using brython and I came by a problem that has nothign to do with it.
My problem is with Mezzanine or TinyMCE editor (I'm not sure which). To make brython work I need the script tag to be "text/python". But the editor filters it automatically to "text/javascript".
I disabled the filtering already, both in the admin panel and in the actual source code, I tried adding "text/python" to the RICHTEXT_ALLOWED defaults in the mezzanine configuration too.
Just to be clear, security is not an issue, this particular feature won't go online in the final version of the website.
Although the HTML specification does allow one to put any value other than "text/javascript" in script's type attribute, few projects do that, and Brython is one of those few. It is likely the "text/javascript" value is simply hardcoded in the editor and it won't allow you to change that.
(There is probably a big chance of having an issue closed as "won't fix/not a bug" or equivalent if you try to report this to the editor's issue tracker).
I think the workaround in this case is to write some javascript to change the text on the attribute on the relevant script tags to "text/python" prior to calling Brython. i.e., instead of triggering Brython on your page with
<body onload="brython()" >
Do something along
<body onload="function (){var x = document.getElementsByName("python"); for(var i=0; i < x.length; x++){x.type="text/python"};brython()}()" >
(and of course, add the attribute name='python' to all your python script tags)

How to auto-update matching html/xml tag in Code Mirror

I really like how Visual Studio html editor updates the matching tag. Example:
<h2>Header</h2>
If we replace <h2> opening tag with <h3>, then the closing tag should change automatically to </h3>. This should happen as we type.
I'm trying to implement this on my own, but no luck so far. I thought that matchtags addon would be a good starting point, but it stops working if tag names do not match.
Also, I noticed that xml mode marks closing tag as error on tag name mismatch, but I'm not sure how to use this to update the closing tags.
I would appreciate any help from more experienced CodeMirror users.
Thanks
So once the edit has been done, you no longer have the information needed to find the matching tag (which is why the matchtag addon can't help anymore). A good solution might be to track the current matching tag when editing starts (when the cursor is in a tag name) by using the CodeMirror.findMatchingTag function exported by the addon/fold/xml-fold.js file. Then, on "change" events that look like local editing inside the tag name (i.e. their start and end are inside the tag name), immediately follow up by modifying the matching tag.
add matchtags.js, xml-fold.js
config : matchTags: {bothTags: true}