Giter Site home page Giter Site logo

nyable / obsidian-code-block-enhancer Goto Github PK

View Code? Open in Web Editor NEW
68.0 4.0 4.0 5.43 MB

Enhance obsidian markdown code block,provides copy button,linenumber,language name tip and so on.

License: MIT License

TypeScript 80.95% JavaScript 6.58% SCSS 12.47%

obsidian-code-block-enhancer's Introduction

Obsidian Code Block Enhancer

This is a plugin for Obsidian (https://obsidian.md).
Inspired by obsidian-code-block-copy.

Note: The Obsidian API is still in early alpha and is subject to change at any time!

Feature

Enhancer the markdown code block in preview mode.

  • Provide Copy Button.
  • Provide Line Number.
  • Show Language Name.
  • Custom exclusion language.
  • Enhance contextmenu in code block.

Screenshot

Gif

Default Dark theme

Obsidian_Default_Dark_Theme

Default Light theme

Obsidian_Default_Light_Theme

Gruvbox theme

Obsidian_Gruvbox_Dark_Theme

Nord theme

Obsidian_Nord_Dark_Theme

Plugin setting

plugin_settings

How to use

Obsidian

  • Open Obsidian
  • Settings -> Community plugins -> Turn off Safe Mode
  • Browes community plugins and search Code Block Enhancer
  • Install and enable

Releases

  • Download main.js, styles.css, manifest.json in the latest release
  • Copy over main.js, styles.css, manifest.json to your vault VaultFolder/.obsidian/plugins/obsidian-code-block-enhancer/.
  • Enable plugin in Obsidian setting.

Source Code

  • Clone this repo.
  • npm i or yarn to install dependencies
  • npm run build to build file in ./dist.
  • Copy over main.js, styles.css, manifest.json to your vault VaultFolder/.obsidian/plugins/obsidian-code-block-enhancer/.
  • Enable plugin in Obsidian setting.

obsidian-code-block-enhancer's People

Contributors

cito avatar nyable 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

Watchers

 avatar  avatar  avatar  avatar

obsidian-code-block-enhancer's Issues

[REQUEST] Functions in editor

Hi, would it be possible to make the syntax highlighting, language identification, line numbers, and copy button work while in editor view? It's quite jarring having the syntax highlighting change completely from editor to preview.

Thank you.

PLUGIN OUTDATED: Try `Code Styler` Plugin alternative

I just wanted to add this issue to note that the plugin appears to be a couple of years out of date and no longer works correctly out of the box. I know a lot of people will find their way here if they sort by most downloaded plugin, only to find that the plugin is outdated. If you're looking for the features of this plugin, I created a plugin Code Styler which has many of the same features and is currently up to date. Hopefully it should be a suitable alternative and if there is any functionality missing, please just create an issue and I can try and implement it!

(Dear @nyable, please feel free to close/delete this issue at any time if the plugin is still under development or development resumes. I just wanted to signpost people to an alternative.)

[bug] Abnormal function

The function of the real code type often conflicts with the main body, and the font cannot be displayed in full. It is recommended to learn to display the code type to the upper right corner by default, and modify the font to be more appropriate.

use contextMenu does not properly override the default copy button. In many themes there will be two duplicate buttons overlapping each other.

image

Any way to make font size smaller

Love the plug in. So nice to see line numbers in code snippet. My only ask is, is there an easy way to make the font size smaller? I am using the Obsidian Nord theme, and the font size of code blocks when using this plug in is too big โ€” in fact, it's larger than the standard note text.

[REQUEST] Wrap code option

Idea

A new option in the plugin settings to toggle line wrapping.
This would wrap lines in code blocks like this:
image
But the line numbers would match up instead of ignoring the fact that some lines have been wrapped, more like this:
ideal

Possible Implementation Idea

At the moment I can wrap the lines in code blocks with the following snippet:

.code-block-wrap pre[class*=language-] {
	overflow-x: hidden !important;
}

.code-block-wrap pre[class*=language-] > code {
	white-space : pre-wrap;
}

This is what I did for the first screenshot.

Unfortunately I have not had a chance to look at how you implemented line numbers, so I do not have any suggestions for how to make it compatible with wrapped lines.

Huge code-block size

Hi,

I just installed the plugin which looks to be amazing. However, I've run into an issue where the blocks are huge compared to the rest of the text.

Screenshot 2021-12-27 at 16 25 34

I'm running the latest obsidian 0.13.14 with the Minimal Theme, disabling my custom snippets does not change anything with regard to the code blocks.

Any idea of how I can make them smaller? Or does it require a fix of the plugin?

Thank you!

Line numbers appear on top of Python code instead next of it.

Python code is formatted, but when changing to reading mode, line numbers appear on top of the code. Additionally the formatting seems to have changed. Finally, it would be nice if the line numbers already appeared in editing mode, i.e. there is no change between the two views.

image

CSS `!important`

Thanks for the plugin. I was planning to do something like that but didn't have much time :-)
Would be an issue if you remove !important! rules from your CSS code? I can not overwrite them with custom snippets (Especially the one with padding)
Thanks!

How to ignore snippets.css styling

Love the plugin, thanks!
It however isn't playing nicely with a css snippet I have from deathau, the notation-color-blocks snippet.
https://github.com/deathau/obsidian-snippets#notation-colour-blocks

Is there a way to leave this styling unaffected?
To call the styling, you write:
```note-green
green formatted text goes here
```

I tried putting 'note' and 'note-green' into the exclusion field of the code block settings (just in case it was that simple). But it didn't work of course.

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.