mp4096 / indentex

An indentation-based superset of LaTeX
MIT License
9 stars 2 forks source link

Indentation with tabs does not work #16

Closed syxolk closed 7 years ago

syxolk commented 7 years ago

Indentation with tabs does not seem work.

This indentex file:

# a:
    # b:
        c

is transpiled to this:

\begin{a}
    # b:
        c
\end{a}

Update: Indentation with a single space works perfectly:

# a:
 # b:
  c

->

\begin{a}
 \begin{b}
  c
 \end{b}
\end{a}
mp4096 commented 7 years ago

Concerning tabs, the short answer: This is intended behaviour. Tabs are not allowed in indentex.

The long answer: I think that enforcing hard tabs was one of golang's wisest design choices (for the record, I abhor hard tabs). Compare this to Python: PEP8 suggests using soft tabs, so everybody would do this, right? Well, no:

I used to work for Yelp. For historical reasons — probably “the initial developers preferred it” — their mostly-Python codebase had always been indented with tabs.

Hence, I decided to allow only soft tabs in indentex so that everybody's on the same page. Indentex source files must be indented using soft tabs, preferably two characters wide.

There is a further aspect to it, however. Indentex cannot detect mixed tabs and spaces. This can lead to very subtle and nasty edge cases. E.g. a user has configured tabs to be two chars wide and has accidentally written this:

# equation:
····a
»··b

This would be transpiled to

\begin{equation}
····a
\end{equation}
»··b

although visually there is no dedent after a.


As for the indentation with a single space being valid: It's another story. Maybe it might be better to require at least two whitespace chars for a valid indentation. I have to sleep on it.

syxolk commented 7 years ago

Ok, can we consider this as another silently ignored edge case #8 that could be fixed together with #9 ?

mp4096 commented 7 years ago

What exactly, tabs or single-space indentation?

Probably it's a good idea to generate transpilation errors for both of them!

mp4096 commented 7 years ago

Superseded by #24 and #25