• Stars
    star
    4,479
  • Rank 9,531 (Top 0.2 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate Google Slides from markdown

Generate Google Slides from markdown & HTML. Run from the command line or embed in another application.

This project was developed as an example of how to use the Slides API.

While it does not yet produce stunningly beautiful decks, you are encouraged to use this tool for quickly prototyping presentations.

Contributions are welcome.

Installation and usage

For command line use, install md2gslides globally:

npm install -g md2gslides

Then get your OAuth client ID credentials:

  • Create (or reuse) a developer project at https://console.developers.google.com
  • Enable Google Slides API at API library page
  • Go to Credentials page and click "+ Create credentials" at the top
  • Select "OAuth client ID" authorization credentials
  • Choose type "Computer Application" and give it some name.
  • Download client credentials file.
  • Copy it to client_id.json (name has to match) and save to ~/.md2googleslides.

After installing, import your slides by running:

md2gslides slides.md --title "Talk Title"

This will generate new Google Slides in your account with title Talk Title.

NOTE: The first time the command is run you will be prompted for authorization. OAuth token credentials are stored locally in a file named ~/.md2googleslides/credentials.json.

Each time you will run the above comment, new slide deck will be generated. In order to work on exactly the same deck, just get the ID of the already generated slides. For example, you can use following command:

# To reuse deck available at: https://docs.google.com/presentation/d/<some id>/edit#
md2gslides slides.md --title "Talk Title" --append <some id> --erase

Supported markdown rules

md2gslides uses a subset of the CommonMark and Github Flavored Markdown rules for markdown.

Slides

Each slide is typically represented by a header, followed by zero or more block elements.

Begin a new slide with a horizontal rule (---). The separator may be omitted for the first slide.

The following examples show how to create slides of various layouts:

Title slide

    ---

    # This is a title slide
    ## Your name here

Title slide

Section title slides

    ---

    # This is a section title

Section title slide

Section title & body slides

    ---

    # Section title & body slide

    ## This is a subtitle

    This is the body

Section title & body slide

Title & body slides

    ---

    # Title & body slide

    This is the slide body.

Title & body slide

Main point slide

Add {.big} to the title to make a slide with one big point

    ---

    # This is the main point {.big}

Main point slide

Big number slide

Use {.big} on a header in combination with a body too.

    ---

    # 100% {.big}

    This is the body

Big number slide

Two column slides

Separate columns with {.column}. The marker must appear on its own line with a blank both before and after.

    ---

    # Two column layout

    This is the left column

    {.column}

    This is the right column

Two column slide

Themes

md2googleslides does not edit or control any theme related options. Just set a base theme you want on Google Slides directly. Even if you will use --append option for deck reuse, theme will be not changed.

Images

Inline images

Images can be placed on slides using image tags. Multiple images can be included. Mulitple images in a single paragraph are arranged in columns, mutiple paragraphs arranged as rows.

Note: Images are currently scaled and centered to fit the slide template.

    ---

    # Slides can have images

    ![](https://placekitten.com/900/900)

Slide with image

Background images

Set the background image of a slide by adding {.background} to the end of an image URL.

    ---

    # Slides can have background images

    ![](https://placekitten.com/1600/900){.background}

Slide with background image

Videos

Include YouTube videos with a modified image tag.

    ---

    # Slides can have videos

    @[youtube](MG8KADiRbOU)

Slide with video

Speaker notes

Include speaker notes for a slide using HTML comments. Text inside the comments may include markdown for formatting, though only text formatting is allowed. Videos, images, and tables are ignored inside speaker notes.

    ---

    # Slide title

    ![](https://placekitten.com/1600/900){.background}

    <!--
    These are speaker notes.
    -->

Formatting

Basic formatting rules are allowed, including:

  • Bold
  • Italics
  • Code
  • Strikethrough
  • Hyperlinks
  • Ordered lists
  • Unordered lists

The following markdown illustrates a few common styles.

**Bold**, *italics*, and ~~strikethrough~~ may be used.

Ordered lists:
1. Item 1
1. Item 2
  1. Item 2.1

Unordered lists:
* Item 1
* Item 2
  * Item 2.1

Additionally, a subset of inline HTML tags are supported for styling.

  • <span>
  • <sup>
  • <sub>
  • <em>
  • <i>
  • <strong>
  • <b>

Supported CSS styles for use with <span> elements:

  • color
  • background-color
  • font-weight: bold
  • font-style: italic
  • text-decoration: underline
  • text-decoration: line-through
  • font-family
  • font-variant: small-caps
  • font-size (must use points for units)

You may also use {style="..."} attributes after markdown elements to apply styles. This can be used on headers, inline elements, code blocks, etc.

Emoji

Use Github style emoji in your text using the :emoji:.

The following example inserts emoji in the header and body of the slide.

### I :heart: cats

:heart_eyes_cat:

Code blocks

Both indented and fenced code blocks are supported, with syntax highlighting.

The following example renders highlighted code.

### Hello World

```javascript
console.log('Hello world');
```

To change the syntax highlight theme specify the --style <theme> option on the command line. All highlight.js themes are supported. For example, to use the github theme

md2gslides slides.md --style github

You can also apply additional style changes to the entire block, such as changing the font size:

### Hello World

```javascript
console.log('Hello world');
```{style="font-size: 36pt"}

Tables

Tables are supported via GFM syntax.

Note: Including tables and other block elements on the same slide may produce poor results with overlapping elements. Either avoid or manually adjust the layout after generating the slides.

The following generates a 2x5 table on the slide.

### Top pets in the United States

Animal | Number
-------|--------
Fish   | 142 million
Cats   | 88 million
Dogs   | 75 million
Birds  | 16 million

Local images

Images referencing local paths temporarily uploaded and hosted to file.io. File.io is an emphemeral file serving service that generates short-lived random URLs to the upload file and deletes content shortly after use.

Since local images are uploaded to a thrid party, explicit opt-in is required to use this feature. Include the --use-fileio option to opt-in to uploading images. This applies to file-based images as well as automatically rasterized content like math expressions and SVGs.

Image rasterization

Slides can also include generated images, using $$$ fenced blocks for the data. Currently supported generated images are math expression (TeX and MathML) as well as SVG. Rasterized images are treated like local images are require opt-in to uploading images to a 3rd party service via the --use-fileio option.

Using TeX:

# How about some math?

$$$ math
\cos (2\theta) = \cos^2 \theta - \sin^2 \theta
$$$

SVG

# Or some SVG?

$$$ svg
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     viewBox="0 0 48 48">
  <defs>
    <path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/>
  </defs>
  <clipPath id="b">
    <use xlink:href="#a" overflow="visible"/>
  </clipPath>
  <path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/>
  <path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/>
  <path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/>
</svg>
$$$

Like local images, generated images are temporarily served via file.io.

Pull requests for other image generators (e.g. mermaid, chartjs, etc.) are welcome!

Reading from standard input

You can also pipe markdown into the tool by omitting the file name argument.

Contributing

With the exception of /bin/md2gslides.js, TypeScript is used throughout and compiled with Babel. Mocha and Chai are used for testing.

Before anything, ensure you have all dependencies:

npm install

To compile:

npm run compile

To run unit tests:

npm run test

To lint/format tests:

npm run lint

See CONTRIBUTING for additional terms.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

More Repositories

1

apps-script-samples

Apps Script samples for Google Workspace products.
JavaScript
4,536
star
2

apps-script-oauth2

An OAuth2 library for Google Apps Script.
JavaScript
1,546
star
3

python-samples

🐍 Python samples for Google Workspace APIs
Python
1,203
star
4

android-samples

Android samples for Google Workspace APIs
Java
636
star
5

google-chat-samples

Google Chat app samples.
JavaScript
494
star
6

node-samples

Node samples for Google Workspace APIs.
JavaScript
467
star
7

browser-samples

Web samples for Google Workspace APIs
HTML
332
star
8

java-samples

β˜• Java samples for Google Workspace APIs.
Java
324
star
9

solutions

Community contributed solutions for Google Workspace
JavaScript
299
star
10

php-samples

PHP samples for Google Workspace APIs
PHP
290
star
11

add-ons-samples

Sample Google Workspace Add-ons
JavaScript
273
star
12

go-samples

Go samples for Google Workspace APIs
Go
214
star
13

drive-quickeditors

A text editor for Android, iOS, and web illustrating how to open and save files with the Google Drive API
Objective-C
213
star
14

drive-utils

Google Drive API utility functions.
JavaScript
189
star
15

dotnet-samples

.NET samples for Google Workspace APIs
C#
168
star
16

sheets-api-codelab

Use Google Sheets as your application's reporting tool
JavaScript
152
star
17

apps-script-oauth1

An OAuth1 library for Google Apps Script.
JavaScript
138
star
18

gmail-add-on-codelab

JavaScript
122
star
19

ruby-samples

πŸ’Ž Ruby samples for Google Workspace APIs
Ruby
79
star
20

apps-script-intro-codelab

JavaScript
59
star
21

cloud-search-samples

Samples for Google Cloud Search
Java
54
star
22

hangouts-chat-apps-script-codelab

JavaScript
54
star
23

ml-integration-samples

This repo contains a collection of code samples and utilities for integrating Google Cloud AI & ML into Google Workspace.
JavaScript
42
star
24

gsuite-apis-intro

Python
32
star
25

chat-framework-nodejs

TypeScript
29
star
26

google-docs-hast

Converts the JSON representation of a Google Docs document into an HTML abstract syntax tree (HAST).
TypeScript
26
star
27

hubot-google-hangouts-chat

Hubot adapter for Google Chat.
JavaScript
24
star
28

awesome-workspace

Awesome list for Google Workspace.
TypeScript
23
star
29

slides-api

Learn How to Use the Google Slides API
JavaScript
22
star
30

gws-genai-addon-sample

A sample Google Workspace add-on for Gmail and Google Drive using Node.js and demonstrating how to use various Generative AI APIs
JavaScript
21
star
31

workspace-guardrails-ps-ca

18
star
32

gws-odo-addon

"Odo" is a Workspace Add-on that lets anyone easily demonstrate the capabilities of Workspace integrations for their customers, all without coding. Simply set the name + logo of the customer you are presenting to, configure Odo's behavior, and do a quick demo. This will help your customers visualize what Workspace extensibility can do for them.
JavaScript
18
star
33

slides-advisor-add-on

JavaScript
16
star
34

ios-samples

iOS samples for Google Workspace APIs
Objective-C
14
star
35

appointment-scheduler-codelab

JavaScript
13
star
36

.github

10
star
37

redriveapp

ReDriveApp (short for "Recommended" or "Replacement" DriveApp). AppsScript class that provides equivalent methods offered by the built-in DriveApp, but that does not require use of full '/drive' OAuth scope (which is a "Restricted" scope"). Instead, uses only these Recommended (non-sensitive) and/or Sensitive scopes.
JavaScript
10
star
38

docs-transcript-codelab

Java
7
star
39

python-oauth-token-manager

Python
6
star
40

meet

TypeScript
5
star
41

drive-picker-element

A web component for Google Drive Picker
TypeScript
4
star
42

.allstar

4
star
43

python-classroom-addon

Reference implementation of a Google Classroom add-on, written in Python and broken into steps corresponding to a walkthrough tutorial https://developers.google.com/classroom/add-ons/walkthroughs/walkthroughs-overview.
Python
3
star
44

oneroster-integration-conformance-tests

Jupyter Notebook
3
star
45

java-classroom-addon

About Reference implementation of a Google Classroom add-on, written in Java and broken into steps corresponding to a walkthrough tutorial https://developers.google.com/classroom/add-ons/walkthroughs/walkthroughs-overview.
Java
2
star
46

group-based-role-assignment-migration-util

Python
2
star
47

python-calendar-insights-demo

Python
2
star
48

drivetocloudbot

Python
1
star
49

drive-cse-upload

Python
1
star