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

How to indent with tabs? #200

Open
hellishvictor opened this issue Dec 12, 2023 · 1 comment
Open

How to indent with tabs? #200

hellishvictor opened this issue Dec 12, 2023 · 1 comment

Comments

@hellishvictor
Copy link

Hi, there's is a way for make the indent option use tabs (0x09) instead of spaces (0x20)?
Cheers.

@gromgit
Copy link

gromgit commented Jan 25, 2024

Yes:

$ pup -h
Usage
    pup [flags] [selectors] [optional display function]
Version
    0.4.0
Flags
    -c --color         print result with color
    -f --file          file to read from
    -h --help          display this help
    -i --indent        number of spaces to use for indent or character
    -n --number        print number of elements selected
    -l --limit         restrict number of levels printed
    -p --plain         don't escape html
    -s --strict        ignore non-standard HTML tags
    --pre              preserve preformatted text
    --charset          specify the charset for pup to use
    --version          display version

Note the explanatory note for the -i option (which could be a bit clearer). If the argument to -i is not a number, pup assumes it's the character you want to use for indenting, so...

$ cat t.html
<div class="c1" id="id1">
 content 1
</div>
<div class="c1 c2" id="id2">
 content 2
</div>

$ pup -i 2 < t.html
<html>
  <head>
  </head>
  <body>
    <div class="c1" id="id1">
      content 1
    </div>
    <div class="c1 c2" id="id2">
      content 2
    </div>
  </body>
</html>

$ pup -i $'\t' < t.html
<html>
	<head>
	</head>
	<body>
		<div class="c1" id="id1">
			content 1
		</div>
		<div class="c1 c2" id="id2">
			content 2
		</div>
	</body>
</html>

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

No branches or pull requests

2 participants