roop at forwardbias.in
Fri Sep 27 11:15:43 EDT 2013
It's impossible to get that correct unless you know what the user has set
his tab settings to (like :set tabstop in Vim; or Tab Size setting in
TextMate). There's no good default: both 8 and 4 are equally good
candidates, and other values are allowed too. So I chose to go around it.
The 99% scenario is that the user is either using tabs for tabs or spaces
for tabs in his editor/s and not mixing the two up. Mixing spaces and tabs
is not a good practice in any piece of writing, so I think it's okay to not
optimize for that scenario.
Hence, the vfmd syntax guide only says "[The list marker character] must be
followed by one or more spaces", and avoids mentioning tabs altogether.
(The original Markdown syntax guide says: "List markers must be followed by
one or more spaces or a tab.")
Again, for code blocks, the syntax guide says the indentation should be 4
spaces or 1 tab, which should do fine for anyone.
So to summarize:
- It's not possible to solve this correctly without giving the tabstop
number as an input to the parser
- We don't want to get the tabstop as input, therefore we need a way
- If the user is not mixing tabs and spaces, he should be fine
- If the user is mixing tabs and spaces, but has read the syntax guide
and follows it, he should be fine
- If the user hasn't read the syntax and is also mixing spaces and tabs,
sorry, I'm afraid I'm unable to help him
On Fri, Sep 27, 2013 at 8:06 PM, Michel Fortin <michel.fortin at michelf.ca>wrote:
> Le 27-sept.-2013 à 9:04, Roopesh Chander <roop at forwardbias.in> a écrit :
> > Because this is how the syntax is defined (which is not hard or
> > to follow for a user), there's no need to worry about a TAB character
> > interpreted as 1-4 spaces based on it's position. If the user inserted a
> > TAB immediately after the bullet character, he is expected to do that for
> > all the list items anyway.
> > *\tlist 1 item 1
> > * list 1 item 2
> > The above too shall be interpreted as two lists.
> Ok, but what about this:
> *\tlist 1 item 1
> * list 1 item 2
> They will both look unaligned in your editor (unless you set your editor
> to 5 spaces per tab (who does this?)), but they'll be in same list because
> because you're interpreting spaces differently from the editor.
> And what about this:
> *\titem 1 paragraph 1
> \titem 1 paragraph 2
> Also, what happens within code blocks? (I haven't checked your algorithm
> for code blocks, but if you change tabs to four spaces you're going to get
> strange results for any code block with tabs in them not a the beginning of
> the line.)
> Michel Fortin
> michel.fortin at michelf.ca
> Markdown-Discuss mailing list
> Markdown-Discuss at six.pairlist.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Markdown-Discuss