2

I have body of text in a Google Doc containing a large number of links. I need to get the text – and all the links – into my client's CMS.

Unfortunately, it seems Google Docs no longer allows users to export HTML. I've tried "Download as" > "Web page (.html, zipped)" and uploading that file into Text Wrangler to clean it up, but the links are all scrambled – e.g something twitter.com/sree becomes:

<a href="https://www.google.com/url?q=https://twitter.com/sree&amp;sa=D&amp;ust=1465095908840000&amp;usg=AFQjCNHpFpNdY6Hsr5xrZZlF5vCGTGIt6w">Sree Sreenivasan</a>

Rather than go in and re-do all the links manually, is there any way to get the html code I need from the Google Doc?

2 Answers 2

2

You can use a regular expression like this in Text Wrangler :

<a href="https://www.google.com/url\?q=(.*)\&amp;sa(.*)">(.*)</a>

and replace by :

<a href="$1">$3</a>
1

If you want to convert links in Google Docs to HTML, give the gd2md-html add-on a try (full disclosure: I developed this): https://github.com/evbacher/gd2md-html/wiki

You can select a section of text from a Google Doc that includes links, and convert that to HTML. For example this section from a Google Doc:

enter image description here

converts to this relatively clean HTML:

<h2>Markdown syntax, standards information</h2>
<ul>
<li>Basic Markdown syntax from John Gruber, the inventor of Markdown: 
<a href="https://daringfireball.net/projects/markdown/syntax">https://daringfireball.net/projects/markdown/syntax</a>
<li>CommonMark standard: <a href="http://commonmark.org/">http://commonmark.org/</a>
3
  • If you are affiliate with the project, please disclose that in your answer. Also, a brief explanation of how this software is an answer to the question will make this a much valuable answer.
    – jonsca
    Jul 16, 2017 at 5:04
  • Thanks -- you're absolutely correct. Tried to clarify and added an example of converting a partial selection with links.
    – evb
    Jul 17, 2017 at 4:12
  • Thanks much! This should get some votes now to counter the downvotes,
    – jonsca
    Jul 17, 2017 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.