Comments (7)
yes! good callout. thanks @alixander
from d2-mode.
@alixander this is actually tricker than it looks.
For .d2
files, it's pretty clear what to do, but there are also d2 regions in emacs mode, which it's less clear. I think we would want to autoformat all the d2 regions as well on save.
I think a few functions are probably required to support this :
- format-buffer
- format-region
- format-file
- format-all-d2-regions ;; goes through all d2 codeblocks and formats them.
from d2-mode.
Example:
from d2-mode.
@avelino yep. I'm aware of hooks you can configure on save with a hook. I think again, the tricky part here is region support. If that's not important for most people, I'm happy to implement a quick format command on the d2-mode. Personally, I tend to use d2 mostly in regions, which is why I've held back on implementing the simple solution.
Proposal here:
- Implement format support with caveat that region's won't be supported for now.
- Region formatting will be a roadmap item. I'm guessing it will be must more involved, as we'll have to write something to scan the file and format appropriately. Not sure what the right solution is there.
Are @avelino and @alixander ok with excluding region support?
from d2-mode.
Is regions like a markdown block? I do mostly edit just the d2 files standalone.
from d2-mode.
@alixander exactly. Regions are blocks.
As an example:
This is a graph
```d2
A --> B
```
Commentary here.Another graph:
```d2
A --> B
```
Commentary here.
I mostly do graphs in regions, so for me ( personally ) unless there's region support it becomes a lot less useful. I didn't know people use standalone files frequently. Might make sense to support this for standalone files.
I'll see about getting a PR started this weekend.
from d2-mode.
Started work on a PR here: #37
from d2-mode.
Related Issues (20)
- Better indenting and syntax support HOT 1
- basic yas-snippets for d2 graphs
- melpa install HOT 4
- Seems Imagemagick didn't handle SVG well as expected. HOT 9
- add to d2 README HOT 5
- void function d2-indent-line HOT 4
- compile file, region, and buffer to location
- use `xdg-open` on Linux and `open` on macOS instead of browse-url HOT 3
- default png output for buffer render
- d2lang syntax highlighting HOT 3
- d2 upgrade
- support d2 sketch flag
- custom layout engine support
- Comment syntax HOT 3
- can this be used with org-mode src-code blocks HOT 7
- Indentation Not Working HOT 2
- New keywords are not recognized HOT 2
- Cask M1 Emacs doesn't ship with SVG render support HOT 8
- Add watch support HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d2-mode.