How to add a tab or space in docs?

hello,

I could not find things about how to add a tab (or space) in docs markdown. Anyone could please help? Thanks.


"""
a new line after this \\\n is ok.

a tab after this \\\t is NOT ok.
"""
function f()
  1
end

help?> f
search: f fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor float first findn filt!

  a new line after this
   is ok.

  a tab after this \ is NOT ok.

Why do you need tabs in Markdown? I think they are just equivalent to space. If you want to use them in code blocks, no special syntax is required:

julia> """
       `A\tA`
       
       `A A`
       """
       f()
f

help?> f
search: f fd for fma fld fld1 fill fdio frexp foldr foldl flush floor float first fill! fetch fldmod filter falses finally foreach fldmod1 findmin findmax findall filter! function Float64

  A     A

  A A

using v0.7.0, I could not produce what like u did:

julia> """
       `a\nb`

       `a\tb`

       `a b`


       """
       function f()
         1
       end
f

help?> f
search: f fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor float first findn filt!

  a b

  a b

  a b

for the needs of tabs … I mean, it’s always good to have better control of spacing and indentation…

also, the behavior of escape-tab (not within a code block) is kind of weird, consider the following:

  • \\\t produces \
  • \\t produces \t
  • \t produces nothing

is it a “bug”? If it is, where should I go? Is it related to the codes in stdlib/Markdown? Also noted that the official documentation (v0.7.0, v1.0.0, v1) is empty on Markdown.

For me everything works fine on 0.7 and 1.0 (which should be the same, of course):

julia> """
       `a\nb`
       
       `a\tb`
       
       `a b`
       """
       function f()
         1
       end
f

help?> f
search: f fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor

  a b

  a     b

  a b

julia> VERSION
v"0.7.0"

It may be something with the interface you are using (is it the REPL directly)?

You shouldn’t ever user tabs, especially in Julia, only spaces, and your editor should help you with indentation.

Using TABs for formatting can lead to unexpected spacing.

You don’t believe me? Look at this thread :wink: Just avoid them, as @Tamas_Papp already said. Spaces are fixed size, no matter what editor or viewer use use, thus they are totally predictable and consistent.

1 Like

I mean, tab could be (or should be) avoided in coding. But what about for docs?

Now, markdown is used inside a doc (i.e. between """s), and multiple spaces are simply ignored! In HTML, I could use things like <br>, &nbsp; or &#09; to control spacing.

Somehow, in my (mac version) of v0.7.0, only \\\n works so far…

The same. Especially within fenced code in Markdown.

If this comes as a surprise, perhaps you should invest in learning Markdown first. The manual is a reasonable start.

ok. thanks… I mean, HTML provides control over spaces, so should Markdown… anyway, it’s not a big issue.

the last question to ask is: are these docs formatting related to the codes in stdlib/Markdown ?

I think so, but it is not overdocumented :wink:

1 Like

update: everything (space, tab, newline) is fine inside triple backticks (not single) for my mac v0.7.0. For example:


julia> """
       ```
       a   b c
           efg
         hij
       zzz
       ```
       """
       function f()
        1
       end
f

help?> f
search: f fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor float first findn filt!

  a   b c
      efg
    hij
  zzz
1 Like

That’s because triple backticks indicate a preformatted code block in markdown. Just like here on discourse (which uses markdown as well).

3 Likes

Yes, as @Sukera said, this is part of the syntax :slight_smile: Instead of discovering Markdown experimentally, just looking at some short introduction may be a good investment.

2 Likes