Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beautify HTML in .md-files #1729

Open
wottpal opened this issue Jun 19, 2017 · 3 comments
Open

Beautify HTML in .md-files #1729

wottpal opened this issue Jun 19, 2017 · 3 comments

Comments

@wottpal
Copy link

wottpal commented Jun 19, 2017

Description

I use Jekyll as a static-site-generator and often HTML-code in included in my .md-files. I want to auto-indent the HTMl but neither Atoms Auto-Indent function nor atom-beautify seems to work for that..

Input Before Beautification

---
layout: default
permalink: /test.html
title: Test-Site
---

<div>
<div>
</div>
<p>
</p>
</div>

Expected Output

---
layout: default
permalink: /test.html
title: Test-Site
---

<div>
  <div>
  </div>
  <p>
  </p>
</div>

Actual Output

---
layout: default
permalink: /test.html
title: Test-Site
---

<div>
  <div>
</div>
  <p>
</p>
</div>

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/dkerzig/17ce01d9e44acf1c7719f89ca6eb5bf5

Thanks in advance!
Dennis

@issue-manager
Copy link

issue-manager bot commented Jun 19, 2017

This issue looks similar to:

If any of these issues solves your problem, then feel free to close this.

@wottpal
Copy link
Author

wottpal commented Jun 21, 2017

@Glavin001 So if I understand the tag "add-language" correctly I just have to implement a new language maybe with a simple regex with formats everything inside the "--- ... ---" as yaml and everything underneath as HTML. Sounds pretty straightforward and I would be happy to create a PR if you give me some instructions where to begin :) And esp. how to differentiate between these kind of .md-files and normal ones.

Dennis

@Glavin001
Copy link
Owner

Hi @dkerzig. Yes, a new language would need to be added. However, a beautifier which supports this language will also be needed. However, since such a beautifier does not exist the the add-beautifier label has not been added.

I just have to implement a new language maybe with a simple regex with formats everything inside the "--- ... ---" as yaml and everything underneath as HTML.

What you described would actually be the implementation of the beautifier 😃 . This may be a good start: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee
However, you can see it is rather hacked together. Atom-Beautify does not yet support complex languages with multiple types in nested languages (i.e. HTML + YAML front-matter + Markdown).


Update: Instead of adding a new language, maybe you could contribute to one of these other beautifiers to improve their support?

Are these actually Markdown files? They look more like HTML files with YAML Front-Matter.
If you insist these are Markdown files, the beautifier you were using is Tidy Markdown. You could contribute to there and add whatever support you need. Then let me know here once it is merged and we can update the Tidy Markdown dependency in Atom-Beautify's package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants