• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

511

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
Community Expert ,
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?

Votes

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.

Votes

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
Community Expert ,
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

Votes

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
Community Expert ,
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?

Votes

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!

Votes

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
Community Expert ,
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?

Votes

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}

Votes

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
Community Expert ,
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.

Votes

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.```

Votes

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.

 

Votes

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.

Votes

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
Community Expert ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

LATEST

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/

 

Votes

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