Giter VIP home page Giter VIP logo

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

abeaclark avatar alexwforsythe avatar chuck-sys avatar dkelly-sighter avatar drcapulet avatar jeroenruiten avatar jimkring avatar maartendesnouck avatar nicolae-stroncea avatar saurabhshri 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

code-blocks's Issues

Some themes cause a failure to insert to the document

Some themes have invalid background color values in their CSS, which makes them fail to render in the document. This can be fixed by adapting them to hex using the same function we use for regular color values.

Eats a line of code

When I try to use codeblocks, sometimes instead of highlighting properly, it deletes the last line of the code I'm trying to format. For reference, the snippet is in C++ and I'm highlighting with the settings language: cpp and theme: googlecode.

Javadoc comments

First, great plugin, thanks.

Second, In Java, I'm wondering if it's possible to have the plugin distinguish normal block comments;

    /*
    Block comment
    */

from Javadoc comments:

    /**
     *
     * Javadoc Comment
     */

I think this is an important distinction because, at least in the darcula theme on IntelliJ, they are different colors:

color example

Addon returning 'ScriptError' when pressing the 'Preview' or 'Highlight' button

I used this really nice Google Docs addon yesterday for a highlighting a few code examples in documentation I'm writing. Alas, today it isn't working and returns the following error:

ScriptError: Invalid argument: .hljs{display:block;overflow-x:auto;padding:.5em;background:#f0f0f0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#bc6060}.hljs-literal{color:#78a960}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

I've also tried using the addon in an entirely empty Google doc, but that would not solve the issue either.

How to reset and change the code block theme. Can't insert here.

OS: macOS v 10.12.6
Google Chrome: 61

What I did:
I have applied one code-block theme now want to change or remove the theme .

What i Tried

  1. Select the text block
  2. Now select Add-ons > Code-Block > Start in Google Docs menu and change theme from drop down

language : auto
Theme : monokai-sublime

Now I want to change the theme only so again select the text block and tried change theme

sometime it give error Can't insert here. below the preview box.

Will someone please specify how to apply or change theme or revert back to previous position of document

What I do right now is to copy the content within code-bloc , delete the code-block and paste the text with clear formatting option.

Couldn't get theme.

When I try to select a portion of the text and click preview, I get:

Couldn't get theme.

I tried:

• reinstalling the add-on
• selecting a different theme
• changing the language
• selecting different text

The results are the same. Any suggestions?

Question: Unformating Text

This isn't an issue, just a question:

If I format something as code, close the doc or do a bunch of other changes in the doc, how do I unformat the code block back to standard text?

Thank you!

Add line numbers

Could this add-on have an option to select display line number or Not.

Browser hangs when highlighting large blocks

Some blocks cause the browser to hang when the preview or highlight button is pressed. So far, I've only seen it with large blocks (multiple pages), but it might have to do with the content of the code itself.

different words formatting in a paragraph is not working

If you select a single word and try to format one after another, e.g. "you will need gcc if you want to make ", where gcc and make are the words to format, it simply won't work. The plugin resets the previously formatted word to the original.

Matlab syntax?

Great work! Just thought I'd suggest adding syntax highlighting for Matlab :)

No syntax highlighting mode

Can you add no syntax highlighting mode? It's a great fallback for unsupported languages or short snippets of language-agnostic values.

Insert Button Missing

Hi,

I'd like to first thank the author for making such a helpful tool.
I was using it early this week and everything worked pretty well.
But today when I opened the add-on in my Google Doc, I found that I can no longer find the Insert button in the GUI. I tried different browsers and they all had the same problem. Besides, if I use the Highlight button, my code in the doc will be deleted instead of being highlighted. Is this supposed to be a bug? Please let me know how to fix it.

Thanks,
Jie

Add support for setting table/cell padding

It would be useful to allow an option to specify the table padding so that when a background is not used one can line the text up in the code block with other paragraphs in the document.

Please add robotC and gml

For users who use the RobotC language for Vex Robotics or equivalents, and for those who use Game Maker's custom language. This would be incredibly helpful.

Couldn't get theme

It was working few weeks back. now when i try to preview or highlight it it says "couldn't get theme"

Script error no authorisation..

Getting this error, reinstalled and still have the same error (allowed application permission when installing).

ScriptError: Authorization is required to perform that action.

Screen grab:

image

CodeBlocks does not open the next day.

Hello.
I've installed code blocks last night and it worked nicely. However, this morning the option to start the app is not there. I cannot open code blocks to keep working on my document.

Terms of Service / Privacy Policy

I was looking at installing this for our development team, but our security team is nervous about exposing our Google docs to a third-party add on. Do you have any official policy in place stating that you don't store any text that you operate on? Thanks!

Indentation for cpp

I have a block of cpp code that I'm trying to format with Code Blocks. When I format it, the color/font changes apply, but with no indentation. Not sure if this functionality hasn't been added yet or if I'm doing something wrong.

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.