Git Product home page Git Product logo

rehype-format's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rehype-format's Issues

Customisable initial indent levels

Initial checklist

Problem

I want to align all children of head and body at 0-indent-level. Currently, there in an option only to indent it at the first level.

Solution

Replace indentInitial with initialindentLevel that makes an initialIndent by multiplying to the indent option.

Roughly speaking:

lineIndent = initialIndent + level * indent
// where
initialIndent = initialIndentLevel * indent

The default initialIndentLevel is 1 for backward compatibility.
For indentInitial: false, it would be 0;
and -1 for my case.

Alternatives

Can be solved on the level of text roughly with the following command:

rehype ... | sed -E 's/^\t//'

Format attributes

Hi,
is there an easy way to ident attributes in the same way as with tags? I want to archive something like this but I didn't find a ad-hoc solution to change the way how attributes are rendered. Do I need an own renderer or can it be archived with existing tools? Thank you.

Input:

<my-component disabled name="dede" [(click)]="test" [property]="{ a: 122 }">
</my-component>

Output:

<my-component
  disabled
  name="dede"
  [(click)]="test"
  [property]="{ a: 122 }">
</my-component>

How to deal with fragments?

Hi @wooorm,

currently, I have to manage some forks of your projects in order to deal with attributes in a less strict way. This situation was improved very well but right know I have still the problem to work with <template> nodes. A <template> node create an additional container #document-fragment and does not expose its children through children but content.

Do you have an idea how to deal with that in your util packages? My project based on your https://github.com/rehypejs/rehype-format project which use the parents.length to check the indentation depth but this information is broken since a template node is handled as a new document.

Are you open for an optional flag to handle a template node like any other element? e.g in

  • hastscript
  • hast-util-from-parse5
  • hast-util-to-html

Purpose: for formatter, analyser which doesn't need such context of scoping but for much easier parsing. Problem: simple template nodes or nested template nodes.

What's with update of positional informations after editing the ast?

I'm relative new to the rehype ecosystem and I wonder how to deal with node position updates after content manipulation? As far I see it will just formatted and ignored in all plugin but what is when I need it in order to make decisions based on the column length, row count etc...?

e.g for pretty printer to decide if the element should be wrapped on multiple lines.

Do you have an idea or tip how to solve it ?

Formatting comments

I want to leave comments on their own lines whenever possible, or at lease respect comments which were on their own lines in the input.

Currently , all newlines around comments seem to be eaten. I also note that whitespace around comments seems to be eaten. For example, <foo> <!-- comment --> </foo> is rendered as <foo><!-- comment --></foo>. Doesn't that change the semantics?

Anyway, is there any easy/obvious way to formats comments onto their own lines (in cases where the semantics would be changed by the new lines and leading space characters), or do I just need to fork rehype-format, or is some filter/plug-in that could handle this?

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.