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

Add indentation options #68

Open
tdegeus opened this issue Mar 15, 2023 · 2 comments
Open

Add indentation options #68

tdegeus opened this issue Mar 15, 2023 · 2 comments

Comments

@tdegeus
Copy link
Owner

tdegeus commented Mar 15, 2023

  1. default: all normal rules
    • removing > 1 spaces and > 2 white lines: everywhere except comments, noindent, verbatim
    • adding spaces around & (todo): everywhere except comments, noindent, verbatim
    • one sentence per line: everywhere except comments, noindent, verbatim, tabular
    • \begin and \end on separate line: everywhere except comments, noindent, verbatim, tabular
    • { and } (and [ and ]) on separate line if it contains more than one line: everywhere except comments, noindent, verbatim
    • lstrip: everywhere except noindent, verbatim
    • indent: everywhere except noindent, verbatim
    • inline math on one line
  2. minimal Block-indent as a hole (done now for tabular), and otherwise do not touch.
  3. indent Only indent, do nothing else.
  4. align Align at &. Otherwise as default.
  5. no:sentence Default of no one sentence per line.

default

Rule comment verbatim noindent tabular math inline math
remove > 1 spaces x x x v v v
remove > 2 white lines x x x v v v
add spaces around & (todo) x x x v v v
\begin and \end on separate line x x x v v v
{ and } (and [ and ]) on separate line if it contains > 1 line x x x v v v
one sentence per line x x x v v v
lstrip x x x v v v
indent x x x v v v
on one line x x x v v v
Note that oneSentencePerLine should either not be applied to tabular, or the & per line should be restored.

A way to tune within a document is to introduce:

For the following environment

% \texindent{default}
\begin{tubular}
...
\end{tabular}

For specific lines

\begin{tubular}
% \begin{texindent}{default}
...
% \end{texindent}
\end{tabular}

For the n following lines

% \texindent{default}{n}
-DEFAULT-
-DEFAULT-
-DEFAULT-
-NORMAL-
-NORMAL-
...

This should throw when there is a conflict. For example

% \texindent{default}{n}
\begin{tubular}
...
\end{tabular}

should not be possible. Neither should

% \texindent{default}{n}
{
...
}

Furthermore there could be the command line options:

--align="{tabular}"

One sentence per line

This should be optional on a specific line. For example

% \texindent{no:sentence}
This is a 
long sentence.
And here is 
another one.
And a 
closing note.

Should be formatted to

% \texindent{no:sentence}
This is a 
long sentence.
And here is another one.
And a closing note.

Extended options could be.

% \texindent{no:sentence}{3}
This is a 
long sentence.
And here is 
another one.
And a 
closing note.

Should be formatted to

% \texindent{no:sentence}{3}
This is a 
long sentence.
And here is 
another one.
And a closing note.

Extended options could be.

% \begin{texindent}{no:sentence}
This is a 
long sentence.
And here is 
another one.
% \end{texindent}
And a 
closing note.

Should be formatted to

% \begin{texindent}{no:sentence}
This is a 
long sentence.
And here is 
another one.
% \end{texindent}
And a closing note.

In terms of implementation a dummy placeholder could be used to mark the end of each sentence that should not be broken.

Only indentation

Like the previous paragraph but only doing indentation. Nothing else.
See alignment above

% \texindent{minimal}
This   is
a   sentence.
And   another
one.
\begin{figure}
\caption{A figure}
    \label{fig:figure}
    \end{figure}

Should be formatted to

% \texindent{minimal}
This   is
a sentence.
And another one.
\begin{figure}
    \caption{A figure}
    \label{fig:figure}
\end{figure}

Extended options could be.

% \texindent{minimal}{3}
This   is
a   sentence.
And   another
one.
\begin{figure}
\caption{A figure}
    \label{fig:figure}
    \end{figure}

Should be formatted to

% \texindent{minimal}{3}
This   is
a   sentence.
And   another
one.
\begin{figure}
    \caption{A figure}
    \label{fig:figure}
\end{figure}

Extended options could be.

% \begin{texindent}{minimal}
This   is
a   sentence.
And   another
one.
\begin{figure}
\caption{A figure}
    \label{fig:figure}
    \end{figure}
% \end{texindent}

Should be formatted to

% \begin{texindent}{minimal}
This   is
a   sentence.
And   another
one.
\begin{figure}
\caption{A figure}
    \label{fig:figure}
\end{figure}
% \end{texindent}
@tdegeus
Copy link
Owner Author

tdegeus commented Mar 15, 2023

What could be nice is to have

% \texindent{style = default - sentence, lines = 3}

or

% \texindent{style = minimal + align + sentence, lines = 3}

It could also be

% \texindent{style = default, disable = [sentence, lstrip, multispace], enable = align, lines = 3}

similarly

% \begin{texindent}{style = minimal + align + sentence, lines = 3}
....
% \end{texindent}

@tdegeus
Copy link
Owner Author

tdegeus commented Mar 15, 2023

The implementation is simple: just call indent first on those lines, and then continue formatting with these lines as comment-like placeholders. This could involve another placeholder type.

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

1 participant