File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -749,6 +749,13 @@ export const findAttachments = (
749
749
export const footnoteTransform = ( bodyValue : string ) : string => {
750
750
const BACK_ANCHOR_FINDER : RegExp = / < a h r e f = " # f n ( \d ) " / g;
751
751
const ANCHOR_FINDER : RegExp = / < a h r e f = " # f n r e f ( \d ) " / g;
752
+ const CONFLUENCE_ANCHOR_FINDER : RegExp =
753
+ / a c : m a c r o - i d = " d 2 c b 5 b e 1 2 1 7 a e 6 e 0 8 6 b c 6 0 0 0 5 e 9 d 2 7 b 7 " > < a c : p a r a m e t e r a c : n a m e = " " > f n / g;
754
+
755
+ if ( bodyValue . search ( CONFLUENCE_ANCHOR_FINDER ) !== - 1 ) {
756
+ //the footnote transform has already happened
757
+ return bodyValue ;
758
+ }
752
759
753
760
const buildConfluenceAnchor = ( id : string ) =>
754
761
`<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:local-id="a6aa6f25-0bee-4a7f-929b-71fcb7eba592" ac:macro-id="d2cb5be1217ae6e086bc60005e9d27b7"><ac:parameter ac:name="">${ id } </ac:parameter></ac:structured-macro>` ;
Original file line number Diff line number Diff line change @@ -4171,6 +4171,19 @@ const runFootnoteTransform = () => {
4171
4171
assertEquals ( expected , footnoteTransform ( value ) ) ;
4172
4172
} ) ;
4173
4173
4174
+ otest ( suiteLabel ( "ignore_existing" ) , async ( ) => {
4175
+ const value =
4176
+ '<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:local-id="a6aa6f25-0bee-4a7f-929b-71fcb7eba592" ac:macro-id="d2cb5be1217ae6e086bc60005e9d27b7"><ac:parameter ac:name="">fnref1</ac:parameter></ac:structured-macro><a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>' +
4177
+ '<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">' +
4178
+ "<hr />" +
4179
+ "<ol>" +
4180
+ '<li id="fn1"><p>Here is the footnote.<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:local-id="a6aa6f25-0bee-4a7f-929b-71fcb7eba592" ac:macro-id="d2cb5be1217ae6e086bc60005e9d27b7"><ac:parameter ac:name="">fn1</ac:parameter></ac:structured-macro><a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>' +
4181
+ "</ol>" +
4182
+ "</section>" ;
4183
+ const actual = footnoteTransform ( value ) ;
4184
+ assertEquals ( value , footnoteTransform ( value ) ) ;
4185
+ } ) ;
4186
+
4174
4187
test ( suiteLabel ( "one_note_forward_back" ) , async ( ) => {
4175
4188
const value =
4176
4189
'<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>\n' +
You can’t perform that action at this time.
0 commit comments