Copy link to clipboard
Copied
I have a bunch of footnotes that appear in the the text and source code as and [iv] and [xxiii], etc. I don't need them to link anywhere.
But I do want to superscript them.
So I need a way to search the source code for [anything] and replace it with <sup>[anything]</sup>.
So any time my code contains left-bracket, any character(s), right bracket...that code stays the same except for <sup> before it and </sup> after it.
I am getting confusing with my syntax involving the brackets. thanks !
Ah, I did misunderstand your request.
In FIND: (<\s*p[^>]*>[^<]*)(\[\w+\]\s*)(<\s*\/\s*p\s*>)
In REPLACE: $1<sup>$2</sup>$3
HTH,
^ _ ^
Copy link to clipboard
Copied
Will the content always be between the same tags, every time? <div> or <span> or <blockquote>? Which?
I'm sure a RegEx would be perfect for what you want to do.
V/r,
^ _ ^
Copy link to clipboard
Copied
The content is always part of normal text paragraphs. The only tags around them are <p></p>.
RegEx does seem to be the way to go, but I can't quite get the context right on what to search for and replace with.
Copy link to clipboard
Copied
Lemme do some research. I've got a RegEx that looks for HTML tags and strip them out without removing the content in between opening and closing tags. I might be able to modify it for this purpose, but I need to look into something to see if it will work.
V/r,
^ _ ^
Copy link to clipboard
Copied
Okay.. I have not tested this, but give it a shot.
Highlight the block of code that contains the <p> tags. Open Find/Replace.
Make sure the checkbox for "Use Regular Expression" is checked.
In the Find area, enter:
(<\s*p[^>]*>([^<]*)<\s*\/\s*p\s*>)
In the Replace area, enter:
<sup>$1</sup>
Don't initially hit "Replace All", try just one or two and if it works THEN hit "Replace All".
This should work. AS LONG AS THERE ARE NO 'LESS THAN' (<) CHARACTERS IN BETWEEN OPENING AND CLOSING TAGS.
V/r,
^ _ ^
Copy link to clipboard
Copied
Wow, thanks so much. That was close, but it's putting the sup tags around the whole P tags, but I only need it around the bracketed info.
So my code is like this:
<p>This is a sentence[vii] </p>
What I want is:
<p>This is a sentence<sup>[vii]</sup> </p>
And yours did this:
<sup><p>This is a sentence[vii] </p><sup>
Copy link to clipboard
Copied
Ah, I did misunderstand your request.
In FIND: (<\s*p[^>]*>[^<]*)(\[\w+\]\s*)(<\s*\/\s*p\s*>)
In REPLACE: $1<sup>$2</sup>$3
HTH,
^ _ ^
Copy link to clipboard
Copied
I had to scoot, quickly, after posting my correction. Just following up. Did my correction work, for you?
V/r,
^ _ ^
Copy link to clipboard
Copied
Wolf, Thanks so much for your continued help and following up.
The RegEx you sent wasn't working for me. So I started playing around with yours and I got closer.
For Find, I am using this: (\[.*\])
For Replace, I use this: <sup>$1</sup>
The simplified Find works in many cases, except for one complication that is killing me!!
If a footnote appears as the only footnote in a paragraph, my Find and Replace work perfectly.
Example: <p>This is a sentence[vii] </p>
That works great. When I click "Find" it highlights the proper text (in bold below). This is exactly what I want! So far, so good:
<p>This is a sentence[vii] </p>
But, if two or more footnotes appear in the same <p> tag, then my Find syntax isn't working.
Example:
<p>This is sentence one.[vii] This is another sentence within the same p-tag. [viii] This is another sentence within the same p-tag. [ix]</p>
I want the FIND part to find [vii] and [viii] and [ix] as three separate finds.
Instead my find yields this:
<p>This is sentence one.[vii] This is another sentence within the same p-tag. [viii] This is another sentence within the same p-tag. [ix]</p>
I'm trying to end the "Find" part immediately after each ], but it's only working when there's one footnote in a p-tag.
Copy link to clipboard
Copied
Got it ! For Find, I had to adjust it to this:
(\[.*?\])
Thanks so much Wolf. Couldn't have done it without you. I have about 40 documents with dozens and dozens of footniotes each, so that why I didn't give up to easily !
Copy link to clipboard
Copied
Glad you got that fixed. Didn't even think that there would be more than one footnote in a paragraph. I get tunnel-vision, sometimes.
V/r,
^ _ ^
Copy link to clipboard
Copied
probably that you already know and use it, but one have a wonderfull tool on line that can be really helfull to adjust the expression
Copy link to clipboard
Copied
I just tested it. It works in DW CC 2016.
V/r,
^ _ ^