Giter VIP home page Giter VIP logo

gdocs2md's People

Contributors

mangini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdocs2md's Issues

Unsupported child: INLINE_DRAWING

I'm getting the following error while parsing a Google Doc.

Paragraph 438 of type PARAGRAPH has an unsupported child: INLINE_DRAWING index=438 (line 155, file "Code")

allow footer

The script crashes when the document includes a footer.

Sometimes links include Google tracking stuff

Here's an example:

[this article](http://www.google.com/url?q=http%3A%2F%2Fwww.stavros.io%2Ftutorials%2Fpython%2F&sa=D&sntz=1&usg=AFQjCNHYROYMTY1rv3hrdYcchdGK4bsc4w)

This should be:

http://www.stavros.io/tutorials/python/

Put converted text in a dialogue box instead of emailing (enhancement)

I appreciate this script's ability to convert a Docs document to Markdown. It came in very handy.

However, I didn't want the script to email the converted document. The contents of my document were somewhat confidential. I was happier keeping it off the insecure public email system and away from possible eavesdroppers. I preferred to have the script pop up a dialogue box with the converted Markdown text, allowing me to copy the text and paste it into a text editor for further manipulation.

I commented out Lines 71-77, which generate an email message with the converted text attached, and put in the following calls:

  var ui = HtmlService.createHtmlOutput("<pre>"+text+"</pre>")
  DocumentApp.getUi().showModelessDialog(ui,"Markdown");

This worked fine for my one document one time. It would nice to have this integrated into this script somehow. It would probably be better to offer the option of emailing or putting up a dialogue box, instead of hard-coding one or the other. I don't want to take the time right now to design that, so I am not offering a Pull Request. Maybe this request will encourage someone else to do that work.

Script fails in documents with tables

TypeError: Cannot find function getTextAttributeIndices in object TableRow.

Not that the script needs to try to do anything fancy with tables, but it probably shouldn't blow up.

Determine <code> blocks

This project is awesome.

It would be even more awesome if it detected monospace fonts (e.g. Courier, Roboto Mono) and produced inline markdown surrounded with single backticks (producing a <code>foo</code>).

This would work if the monospace-styled text is in a paragraph with normal text.

Enable Multimarkdown / Pandoc numbering for Footnotes

Sigh, over 100 lessons at Code Academy (?) and I can't figure out how to change the code myself; though I am guessing it is very simple.

Basically, MM and PANDOC can read footnotes with the following syntaxis

Tex tex text1.

I can obviously change the text between brackets in line 110, but I can't figure out how to create a loop function that would (a) number each footnote with a different number (continuing numbering preferred, of course) and (b) force a line brake in Markdown before the second 1 with the actual content of the footnote. That would make the final Markdown document capable of being processed by Pandoc easily and beautifully. Would highly appreciate ideas regarding this and would love to check the code after that becaues --as I said-- I am sure it is EASY as HELL. Regards!

Footnotes

  1. content of footnote. 2

Multi-part code blocks are mangled

I get this:

`module ListComprehension`

`  def c(comprehension)`

`    parts = comprehension.split(' ')`

`    if parts[0] == parts[2]`

`      eval(comprehension.scan(/\[.*\]/).last)`

`    end`

`  end`

`end`

But I should get this:

module ListComprehension
  def c(comprehension)
    parts = comprehension.split(' ')
    if parts[0] == parts[2]
      eval(comprehension.scan(/\[.*\]/).last)
    end
  end
end

List - Empty line in unorderd list

Unorderd lists in GDrive get a blank line between them in the exported MD file, which renders an empty line between *, which is unwanted.

Enable batch editing files

The script should be applicable to more than one document at a time. Right now one needs to copy and paste the script to every new document one wants to convert. It should be possible to batch convert files from GDrive.

Treat consolas font as monospaced/backticked text as well.

Hi, I found the Consolas font "cuter" in my google docs and I am using this change to lines 267-268 of the script:

     if (!inSrc && (font===font.COURIER_NEW || font=="Consolas")) {
        while (i>=1 && txt.getFontFamily(attrs[i-1]) && (txt.getFontFamily(attrs[i-1])===font.COURIER_NEW || txt.getFontFamily(attrs[i-1])=="Consolas")) {

I'm not keen enough to guess what constant is from font.* that will match the Consolas font, but this way works for me. :)

(sorry I am too lazy to make a proper/decent pull request, so the alternative is here for whoever wants to implement to the code)

Can't find created script

Followed all the directions but in Google Apps for Business / Google Drive / Google Docs / My Doc

I do not see the Script Manager option under the Tools menu.

Lists have spaces around them

A list usually ends up like this:

1. A

2. B

3. C

Which ends up with weird formatting (<p> elements around the list items) when converting to HTML.

Email from Google

G Suite/Google Doc admins are receiving emails in regards to this script.

Hello Apps Script user,

As a G Suite user, this notification is to alert you of an update to one or more of your Apps Script projects that are attached to Docs, Sheets, and Forms documents with script sharing settings that differ from those of the document.

Starting on or after June 13th, 2017, those script sharing settings will be updated to match those of the documents to which they're attached.

The sharing settings update simplifies sharing settings for documents with attached Apps Script projects by treating them like a single document.

As a result of the sharing settings update, and according to the document access level, some users may:

  • Gain or lose access to affected projects
  • Change their access levels (for example, owner, editor, reader)

This change will not affect sharing settings for the documents. Only sharing settings of attached Apps Script projects will be updated.

A CSV file attached to this message lists all Apps Script projects where you're the owner and whose sharing settings will change as a result of this migration. Please review these documents and confirm that their sharing settings are also appropriate for their attached Apps Script projects.

If changes are required, for each document where settings need to be changed, use one of these methods:

  • In Docs or Sheets, click Share.
  • In Forms, click Add Collaborator.
  • In Google Drive, click Share.

Sincerely,

The Apps Script Team

Bugs in "--- source code" handling

There are still some bugs in the "--- source code" function:

  • All lines are indented four spaces, EXCEPT some are not.
  • Blank lines in the source are lost (mostly). These can be important for breaking up blocks of meaning.

Example files have been sent by private email.

Couple of suggestions and a question: add menu, export to hosted doc.

Firstly, thanks for this great script.

1: Did you know you can add a menu very simply?

function onOpen() {
  DocumentApp.getUi().createMenu('Markdown Conversion')
      .addItem('Convert and email', 'ConvertToMarkdown')
      .addToUi();
}

2: Does anyone know a way of adding this script so it's globally available to all docs in my account rather than adding per doc? I've been trawling through https://developers.google.com/apps-script/scripts_containers and sadly it doesn't look like it can be. I hope I'm wrong though.

3: Would you consider adding support for automatically "pushing" the page to a Google Hosted folder so it can be easily published in 2 clicks using something like Markdown-js.

Finally, thanks again!

Excessive Permissions for Google Drive

Could you detail and explain why this script is requesting so much access and varying types of permissions from google drive?

This script seems like it could be accomplished with far less invasiveness

Cannot call method "getActiveSection"

Getting this error when I run after authenticating.

TypeError: Cannot call method "getActiveSection" of null. (line 2, file "Code")

I also can't see the script in the scripts manager.

Support for Horizontal Rules

Currently throws an exception at ~line 110 if a horizontal rule is encountered.

Suggested fix:

else if (t === DocumentApp.ElementType.HORIZONTAL_RULE) {
textElements.push('* * *\n');
}

Doesn't fail gracefully on footnotes

When attempting to export a document with footnotes the following fatal error occurs: "TypeError: Cannot find function getText in object Footnote." Other documents without footnotes work as expected.

Server error

Any time I try to run this script, I'm getting an error:

We're sorry, a server error occurred. Please wait a bit and try again. (line 130, file "")

Is there a problem on my side?

EDIT: Seems there's something too complex with my document for this script - I'll try to track it down.

escape HTML < and > inside source code blocks

(reported by August Mohr)

The GDoc lines:

--- source code
<html data-cast-api-enabled="true">

---

generates this in the MD file:

<pre>
    <html data-cast-api-enabled="true">
</pre>

and that gets passed through to the HTML version unchanged.

So of course it does not display desired.

Not really an issue - my changes to support a new mode of operation

Hi There,

First off: thanks for providing this code - it has been very helpful for me.

I have made some reasonably big changes - not fixes - but a new mode of operation. I have no idea if you'll be interested in them, but I I just wanted to let you know. Because I have changed the way the script works (not email based any more) it didn't feel like a pull request was suitable.

My requirement was to have the markdown version created in Google Drive alongside the original document (in a "markdown" folder) - instead of being emailed. I also needed to enable hyperlinking from one document to another in the same directory or a sub directory. The code now looks at all links - if these refer to a document in the same directory or a sub directory then the absolute link is replaced by just a relative path name. It will also automatically (recursively) process the file being referenced - thus if you process a top level file and this links to a number of sub-files then all of the files will be processed and markdown versions created - all with suitable internal links. All in all this enables large multi-file documentation packages to be maintained in Google Drive then easily exported to Markdown files.

My version is available here:
https://gist.github.com/bafta-benj/a5c432e5957ba48f98007fb802f48ca4

If this is of interest let me know - I've only just finished it and haven't used it much so there will probably be some tweaks/fixes over the next couple of weeks.

All the best

Ben

Ordered list

The export of ordered list does not work correctly. The exported lists look like:

1. Text1
1. Text2
1. Text3

The numbers should be increasing.

Code Block "--- source code" only handles indented lines

As far as I can tell, only the lines between "--- source code" and "---" which
are ALREADY indented by four spaces are getting turned into "pre" code.
[This system didn't like me using anglebrackets around "pre".]

Thus a block of code that has some lines fully exdented and some lines indented
gets turned into paragraphs for the exdented lines and "pre" blocks for the indented
lines, alternating through the block, up to the ---.

I have not tried what happens to normal paragraphs, outside the --- source code
block, that are indented by 4 spaces.

It worked earlier today and I have been getting the script from github each time
I use it so it is likely caused by recent work.

Help request: Preserve newlines

Anyone know how I could modify the script to preserve single newlines vs double newlines?
I have some song verses that I would like to use this script on which are of the form:

Verse1 line1
Verse1 line2

Chorus line 1
Chorus line2 

Verse2 line1
Verse2 line2

However, this script doesn't preserve this spacing and produces:

Verse1 line1

Verse1 line2

Chorus line 1

Chorus line2 

Verse2 line1

Verse2 line2

Its broken now

Hey It doesn't works in 2015 nothing in google docs change, function executes with no error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.