code-syntax

Support Guide

Development of this add-on is done on GitHub. Please open an issue if you have any questions or suggestions.

Google Docs

The Code Syntax add-on for Google Docs allows you to write code in Markdown and have it syntax-highlighted.


There are three primary functions accessible from the add-on menu:

  1. Colorize
  2. Colorize selection as
  3. Change mode to

Colorize

“Colorize” processes the entire document, seeking sections enclosed in backticks (`).

The add-on also converts ‘#’ to Google Docs headers, depending on the number of ‘#’ used (for example, ‘#’, ‘##’, ‘###’).

Example:

Before After

The add-on uses the background color of the generated code blocks to remember the programming language of the code block. If you run “Colorize” again, it will use this information to re-colorize the code blocks according to the remembered language.

Colorize selection as

“Colorize selection as” allows you to manually select a piece of text and colorize it as a code segment in a specific language. You can use this feature to highlight your code snippets with appropriate syntax coloring.

To use it, simply select a text and then go to the add-on menu, choose “Colorize selection as” and pick the desired programming language.

Note that the syntax highlighting is done without adding a background box. Future calls to Colorize will not affect the selected text. If you change the code, you need to re-colorize the selection.

Example:

Before After

Change mode to

“Change mode to” modifies the syntax highlighting of a rendered code section where the cursor is currently located.

For example, say you wrote a code section without specifying the programming language, and it was rendered as plain text:

Before After

If you now want to change the highlighting to Python, proceed as follows:

Before After

This menu option does nothing if the cursor is not in a code section.

Google Slides

The Code Syntax add-on for Google Slides allows you to write code in Markdown and have it syntax-highlighted.

Note: code blocks in Google Slides only work on full text boxes. That is, there is no way to have a code block in the middle of a text box. A code section is only recognized as such if the text box starts with and ends with.


There are four primary functions accessible from the add-on menu:

  1. Colorize
  2. Colorize Slide
  3. Colorize selection as
  4. Change mode to

Colorize and Colorize Slide

“Colorize” processes the entire document, seeking text boxes for code spans and code sections. “Colorize Slide” does the same, but only for the current slide.

Example:

Before After

The add-on uses the background color of the generated code blocks to remember the programming language of the code block. If you run “Colorize” again, it will use this information to re-colorize the code blocks according to the remembered language.

Colorize selection as

“Colorize selection as” allows you to manually select a piece of text and colorize it as a code segment in a specific language. You can use this feature to highlight your code snippets with appropriate syntax coloring.

To use it, simply select a text and then go to the add-on menu, choose “Colorize selection as” and pick the desired programming language.

Note that the syntax highlighting is done without adding a background box. Future calls to Colorize or Colorize Slide will not affect the selected text. If you change the code, you need to re-colorize the selection.

Example:

Before After

Change mode to

“Change mode to” modifies the syntax highlighting of a rendered code section where the cursor is currently located.

For example, say you wrote a code section without specifying the programming language, and it was rendered as plain text:

Before After

If you now want to change the highlighting to Python, proceed as follows:

Before After

This menu option does nothing if the cursor is not in a code section.