Hacker News new | ask | show | jobs
by ilyt 1117 days ago
> You need a layered mode though - you can have bold, italic, monospaced, header and link all active at the same time - which means you've got 32 states right there

Requiring like, a byte, for state is hardly a complex requirement.

> But also! If you do something like `# Header _bold-italic`, that italic and bold don't apply because the EOL stops the header state and retroactively cancels those bold-italic attributes.

And an IF statement or two.

> But also also! If you mismatch the order, it won't match both. Or, at least in Marked 2, if you mismatch the order on both sides of a non-attributed word, that word will get the wrong styling (`_with mismatched_* middle _attributes_`).

Fair enough, but you can't expect to get correct output if you put wrong data in, you are trying to italicize it twice. If the interpreteation was "either * or _ turns italics on/off" you'd also have not what you expected.

My complaint about markdown here is really that there are 2 ways to make italics and 2 ways to make bold text. "Just" having * for bold and _ for italics would on top of making parsing easy also make it clearer. Less typing too.

1 comments

> Requiring like, a byte, for state is hardly a complex requirement.

Add in table header and table cell to get to 128 states. You can probably get it above 256 quite easily. But the storage requirement isn't the point - it's that you have a complicated state machine where you can't just say "in-bold", "out-bold" as suggested because you also need "in-bold-whilst-italic", "in-bold-whilst-header", "in-bold-whilst-header-italic", etc. with the associated transitions.

Or you have a state machine for each attribute. But then `\n` can affect multiple of them at the same time and also require unwinding your state over a bunch of characters. You can say "this isn't beyond a competent developer", yes, but it is a long way from trivial to get correct.

> you are trying to italicize it twice.

Ah, HN mangled my example markdown. I should have remembered that happens.