Giter Site home page Giter Site logo

ry8kua / code-blocks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexwforsythe/code-blocks

0.0 0.0 0.0 577 KB

Syntax highlighting for Google Docs

Home Page: https://www.alexwforsythe.com/code-blocks/

License: MIT License

Shell 3.35% JavaScript 88.59% HTML 8.06%

code-blocks's Introduction

img

clasp Donate

Google Workspace Marketplace badge

Usage

Starting the add-on

starting

Formatting inline code

inline-formatting

Formatting code blocks

blocks-formatting

Reformatting code blocks

reformatting-blocks

Previewing themes

Examples of the different color themes applied to various languages can be found on the highlight.js demo page.

Unformatting code

To clear formatting in Docs, highlight the text and select Format > Clear Formatting from the toolbar. The keyboard shortcut is Cmd+/ on OS X and Ctrl+/ on Windows: https://support.google.com/docs/answer/179738

This will not remove the table that the text lives in if it's a "code block". To do that, you'll have to copy the text and paste it outside the table, then right-click the table and select Delete table.

Limitations

Updates to syntax highlighting

Code Blocks is built with highlight.js and can only provide syntax highlighting for languages that are supported by that library.

If you'd like to see Code Blocks support a language that is not yet implemented by highlight.js, please refer to their page on requesting new languages.

If you'd like to see Code Blocks update or fix support for an existing language:

  1. Check if the latest version of highlight.js already includes the update. If it does, submit a PR to this repository that bumps the highlight.js version in package.json.
  2. If highlight.js does not yet include the update, please submit an issue on their issue tracker.

Real-time syntax highlighting

Codes Blocks uses Google's Apps Script, a server-side JavaScript platform, to interact with Docs and format code. Each time the add-on formats a snippet of code, a request is made to the Apps Script backend to modify the current Doc. There are a few limitations of this platform that prevent Code Blocks from formatting code as you type:

  • The onEdit event that fires when a user modifies content is only available in Sheets
  • Time-driven triggers can only be used once per hour at most
  • Each request to modify the current Doc can take multiple seconds, so code formatting cannot be performed in real-time
  • The number of requests needed to update a Doc in near real-time may exceed the service API quotas

Keyboard Shortcuts

Keyboard shortcuts can only be handled by Code Blocks if the add-on sidebar is focused, which would require users to click the sidebar anyway.

Keyboard events in the active document cannot currently be handled by Docs add-ons: https://issuetracker.google.com/issues/79461369

Contributing

Setup

$ npm install

Building

$ npm run build

Pushing Changes

ℹī¸ The following commands only work for the project maintainer because they require Google Drive authorization.

Command Description
npm run push:gas just GAS files
npm run push:js just sidebar.js
npm run push:static just HTML & CSS
npm run push everything

Google Apps Script Resources


Homepage | Google Workspace Marketplace | Privacy Policy | Terms of Service

code-blocks's People

Contributors

alexwforsythe avatar dkelly-sighter avatar saurabhshri avatar abeaclark avatar drcapulet avatar chuck-sys avatar jeroenruiten avatar jimkring avatar maartendesnouck avatar nicolae-stroncea avatar

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.