-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add option -no-indent to remove indentation #1856
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
base: master
Are you sure you want to change the base?
add option -no-indent to remove indentation #1856
Conversation
ehuss Hello, Hello :) |
hi thanks. just give us some time we will review this :) |
d67b599
to
bc0f19c
Compare
# Conflicts: # src/utils/string.rs
Hi, I'm also having this problem - did this get merged? Is the idea to remove all indentation from code snippets or only "extra" indentation? Hopefully, the latter. |
No. |
Do you mean that it will remove all indentation, ie.
Becomes:
Or (what I'm hoping):
|
Second option. What you need too :) |
Just pinging this thread to say that I've also run into this problem and would find this PR really useful when merged |
Do we expect this to get merged soon? If not I may create a fork to use in the meantime, this would solve some headaches. |
If you can test it and ensure that it works as |
🤣 I'll try to find some time. |
I would prefer to avoid adding an option for this. I would expect there to be one true behavior. There's also PRs and issues about indentation (#1564, #1565, #1718). Whatever solution is taken, I would like to see a clear description of the issue and why a particular solution was chosen. This particular PR doesn't have much of a description. Another thing to consider is the behavior around hidden lines. |
@ehuss @sanity @Dylan-DPC I added some description! Can you take a look? |
Can you respond to the questions raised in #1856 (comment)? Would it be possible to avoid requiring an option to determine the indentation behavior? Why choose this behavior over the other PRs? |
@Salka1988 - thank you for working on this :) Opt-in makes sense from the perspective of not breaking existing code, although for me I would prefer a way to set this flag globally for all Still, this would be a big improvement over not having this functionality.
I understand there may be internal reasons for it, this is definitely going to generate bug reports without a helpful error message :) |
- Loading with memmap - Loading a sharded tensor - Moved some snippets to `candle-examples/src/lib.rs` This is because managing book specific dependencies is a pain rust-lang/mdBook#706 - This causes a non aligned inclusion rust-lang/mdBook#1856 which we have to ignore fmt to remove. mdbook might need some more love :)
- Loading with memmap - Loading a sharded tensor - Moved some snippets to `candle-examples/src/lib.rs` This is because managing book specific dependencies is a pain rust-lang/mdBook#706 - This causes a non aligned inclusion rust-lang/mdBook#1856 which we have to ignore fmt to remove. mdbook might need some more love :)
- Loading with memmap - Loading a sharded tensor - Moved some snippets to `candle-examples/src/lib.rs` This is because managing book specific dependencies is a pain rust-lang/mdBook#706 - This causes a non aligned inclusion rust-lang/mdBook#1856 which we have to ignore fmt to remove. mdbook might need some more love :)
- Loading with memmap - Loading a sharded tensor - Moved some snippets to `candle-examples/src/lib.rs` This is because managing book specific dependencies is a pain rust-lang/mdBook#706 - This causes a non aligned inclusion rust-lang/mdBook#1856 which we have to ignore fmt to remove. mdbook might need some more love :)
- Loading with memmap - Loading a sharded tensor - Moved some snippets to `candle-examples/src/lib.rs` This is because managing book specific dependencies is a pain rust-lang/mdBook#706 - This causes a non aligned inclusion rust-lang/mdBook#1856 which we have to ignore fmt to remove. mdbook might need some more love :)
Just to add my opinion as a user here. The behaviour described in #1564 and #1626 is clearly incorrect so shouldn't require an option on the part of the user to get correct behaviour. The PR at #1718 implements exactly the solution that #1626 describes. So, if it were up to me, (which it clearly isn't 😄 ) I'd do the following:
|
Any progress on this PR? |
In this PR, I have added support for the new
LinkType::IncludeNoIndent
. This feature can be utilized with theAnchor
syntax, such as{{#include file.rs:anchor_name:-no-indent}}
, or with theRange
syntax,{{#include file.rs::20:-no-indent}}
.Parsing is done in the same way as with the
Range(LineRange)
type. This means that if we use{{#include file.rs::20: 30}}
, the command will not work until the whitespace between 20 and 30 is removed, resulting in 20:30. The same applies to the-no-indent
command,{{#include file.rs::20: -no-indent}}
will not work, while{{#include file.rs::20:-no-indent}}
does.The parsing process begins in the
parse_include_path
function where we check for the presence of the-no-indent
command. Based on this, we returnLinkType::IncludeNoIndent
or onlyLinkType::Include
.If we have returned
LinkType::IncludeNoIndent
, thetake_format_remove_indent
function will find the part of the code closest to the left margin and move it to the left by that much space. The format of the code remains the same, with only the indentation being removed.{{#include file.rs::20:30}}
{{#include file.rs::20:30:-no-indent}}
{{#include ../../../examples/providers/src/lib.rs:setup_test_blockchain}}
{{#include ../../../examples/providers/src/lib.rs:setup_test_blockchain:-no-indent}}