Remove all anchor tags before exporting to HTML

New Here ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

My .html file is filled with anchor tags after I export to HTML. <a id="_idTextAnchor006"></a>.

 

I'm trying to figure out how to use GREP to remove these. Here is my code:

 

Find what:

<a id="_idTextAnchor\d\d\d"></a>

Change to:

blank

TOPICS
Scripting

Views

125

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

I'm not sure this is even an InDesign question? Sounds like you're asking how to perform a GREP search using a text editor? If you don't want the anchors, why not delete them from the InDesign document prior to export?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

I am using the built-in InDesign search and replace, not with a text editor. The .HTML file I was referencing is from an .indd export.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

A text anchor is ~a

In InDesign Grep search

 

You would look for

(<a id="_id)~a(\d\d\d"></a>)

 

Change to

$1$2

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

If you want to delete all anchors in InDesign, just reolace ~a with nothing. To delete certain anchors in .html files, the code you posted should do the trick. Are you sure that your text editor supports GREP?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Thank you, this is the solution!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Which one? Deleting the anchors in InDesign or using your Grep replacement in the html files?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Sorry for the confusion. It actually seems like neither is working to remove the text anchors.

Here is the code I tried.

grep    {findWhat:"~a"}	{changeTo:""}	{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}	

 

grep    {findWhat:"~a(\d\d\d"></a>)"}	{changeTo:""}	{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

There's no point trying the second one because your document contains anchors as InDesign objects, not as text strings. That second one should be used on your html files (using any editor that supports grep).

 

The first one doesn't work, probably because of the option 'wholeWord', which is not compatible with Grep. Try removing that option and try again.

 

P.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Thank you for the help. I tried your suggestions with the code variants below. Neither work to remove the anchors.

```grep {findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.```

```text{findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.```

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Sorry for the incorrect formatting. This forum seems to have some trouble with Chrome.

 

grep {findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.
text{findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Also, is there a guide or any resources you can suggest for how to use find/replace with inDesign? There are so many nuances with inDesign's find/replace and GREP doesn't seem to function like regular regex.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Do you find anything when you search for ~a using the Find/Change window? Before trying to find it with a script, make sure that what you're after is in fact in your document.

 

GREP doesn't seem to function like regular regex

Nowadays the notion 'regular regex' is a variable and fluid one. There are several dialects of regular expressions. For InDesign's grep, see https://creativepro.com/now-available-grep-in-indesign-3rd-edition/

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines