GithubHelp home page GithubHelp logo

obsidian-plugin-prettier's Introduction

obsidian-plugin-prettier

Format notes using prettier.

This plugin exposes the following commands:

Action Hotkey
Format the entire note Blank by default
Format the just the selection Blank by default

And the following settings:

Setting Default
Format on Save false
Format code block false

Add the following to your note's front-matter to enable this plugin for a specific file.

---
plugin-prettier: true
---

Installing

Either install the latest release from Obsidian directly or unzip the latest release into your <vault>/.obsidian/plugins/ folder.

Once the plugin is installed, you need to make sure that the switch for "Prettier Format" is turned on. After you are all setup you would see this plugins commands in the command palette (CMD + P). You can assign the commands to hotkeys for easy usage.

obsidian-plugin-prettier's People

Contributors

crhallberg avatar hipstersmoothie avatar renmu123 avatar zephraph 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

Watchers

 avatar  avatar  avatar  avatar

obsidian-plugin-prettier's Issues

Add configuration?

Is there a way to configure the Prettier settings? For instance, enable semicolons and use 4 spaces for indentation?

List item bug?

Does the bug mentioned here still exist?

// There is a prettier bug where they add extra space after a list item
const fixListItemIndent = (text: string): string => {

Is there a link to the upstream issue to track it for when it gets resolved?

Saving a file uncollapses all sections

Not sure if it should be here or under obsidian.

But after enabling this extension when I have collapsed sections saving a file when prettier removes some lines.

Video:

prettier.mov

Code Block formatting destroys code even if setting is disabled

If I write a Code Block like this (e.g. a crontab command for my documentation):
image

after I save (and prettier formats) the command gets modyfied to this (first "*" changed to "-" ):
image

The settings for code block aren't working for those multi-line code blocks:
image

Please fix this, so multiline-code blocks don't get formatted at all (extra setting maybe?)
=> otherwise no developer can use this plugin reliably without any risks to destroy their well documented code blocks... :(

Breaks Outliner plugin functionality

Hey not sure if anyone has flagged this with you, but I think that this plugin is responsible for breaking functionality in the Obsidian Outliner plugin. When both plugins are enabled, Outliner doesn't seem to recognize lists correctly until Prettier is run on the file. If prettier is disabled entirely, Outliner works fine.

cc @vslinko

FR: Update custom frontmatter key on Saving the file

Hi, thanks for this amazing plugin. I have been using it for several months now.

Suggestion (Feature Request)

Upon Saving the file, any custom key (as set in Settings of the Plugin) should update itself with the value set in the Settings.

The value can be dynamic. Currently, dateModified works this way. So, it would be great to add any number of custom keys that can accept different values based on Time, File Size, etc. that keeps updating automatically in the background.

Use Case

  • Upon saving the file, the size key in the Frontmatter should delete the already present value, and update it to the new file size from this.app.workspace.getActiveFile().stat.size
  • Once the size is present in the File's content itself (rather having having to access it in Templater or Dataview), the frontmatter can be easily used to deduce a rough Reading Time (e.g., by dividing the size by 600 or so).
  • It can be used to display the children files in Folder-note in basic Dataview table with Reading Time key, without resorting to Dataviewjs for every Folder-note.
  • Having the File size or Reading Time available in the Frontmatter itself can even be used in non-Obsidian case (e.g., publishing blog), without having to install some external node package to display Reading Time.
  • It can even be helpful in GitHub, as the person can immediately know the Reading Time from the frontmatter itself.

Alternative (currently)

Manually scroll up to the Frontmatter whenever you want to update the Size or Reading Time, and delete the already present frontmatter value, and add the value via Templater plugin's modal or Hotkey.

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.