[ANN] vfmd

Michel Fortin michel.fortin at michelf.ca
Tue Oct 1 10:41:33 EDT 2013


Le 1-oct.-2013 à 8:15, Roopesh Chander <roop at forwardbias.in> a écrit :


> I think I was being biased towards the expandtab-way of text editing, in my

> previous mails on this topic. Thinking from the point of view of a

> keep-tabs-as-tabs text editor, another solution becomes possible, which I

> describe below:

>

> This is how the user documentation would look like:

> --- snip ---

> The list bullet char should be followed by one or more spaces or a tab

> character.

>

> For multi-paragraph list items, the subsequent paragraphs should be

> indented to vertically align with the first paragraph of the list item,

> using either spaces or a tab. If you are using tabs for indentation, you

> should use the same number of tab characters to indent all paragraphs of

> the list item, including the first paragraph.

> --- snip ---

>

> The parser would operate as follows:

> --- snip ---

> - Let t be the number of tab characters occurring after the bullet

> character of a list item

> - If t > 0, then

> - First, look for t tab characters (with optional interspersed spaces) as

> indentation for subsequent paragraphs

> - If previous step didn't match, look for tabs+spaces as indentation

> using the modulo-4 method

> - If t = 0, then

> - Look for tabs+spaces as indentation using the modulo-4 method

> --- snip ---

>

> Advantage:

> - If the user doesn't mix space-indentation and tab-indentation, it would

> work for almost all cases (see below for the not-working case),

> irrespective of the tabstop setting he uses

> - If the user uses space-indentation in some parts of the list and

> tab-indentation in other parts of the list, things are only as bad as the

> modulo-4 method

>

> Disadvantage:

> - Even if the user doesn't mix space-indentation and tab-indentation, it

> doesn't work for the case where the (number of spaces before the bullet

> char) = (tabstop - 1). For example, with tabstop=4 (_ being tab and . being

> space):

>

> ...*____list item para 1

>

> ________list item para 2

>

> will be parsed unintuitively. This is why the user documentation above

> says: "If you are using tabs for indentation, you should use the same

> number of tab characters to indent all paragraphs of the list item,

> including the first paragraph."

>

> What are your thoughts on this option?


Seems more complicated than just replacing tabs with spaces in the input. More complicated because now you have to handle tabs everywhere in the parser. This means more things can go wrong: there's many more edge cases to deal with and that will require a bigger test suite. And more complicated logic means more code to maintain/debug and potentially a slower parser. That's for the inconveniences, on the plus side we can deal with arbitrary tab-stop lengths in some cases.

I think it's a good idea, but I'm not convinced it is worth the trouble.

--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca



More information about the Markdown-Discuss mailing list