17

This question already has an answer here:

-- in a title is collapsed to . This probably isn't so great if the title contains <!-- --> or x--.

Is this intended behavior?


Running this query on data.stackexchange (I don't claim to be good at SQL):

SELECT
    sum(case when Title LIKE '% -- %' then 1 else 0 end) AS [mdash],
    sum(case when Title LIKE '% <!-- %' then 1 else 0 end) AS [comment],
    sum(case when Title LIKE '%[a-z0-9]-- %' then 1 else 0 end) AS [decrement],
    sum(case when Title LIKE '% --[a-z0-9]%' then 1 else 0 end) AS [increment],
    sum(case when (Title LIKE '%-- %' OR Title LIKE '%--- %')
              and Title NOT LIKE '% -- %'
              and Title NOT LIKE '% <!-- %'
              and Title NOT LIKE '%[a-z0-9]-- %'
              and Title NOT LIKE '% --[a-z0-9]%' then 1 else 0 end) AS [uncategorized] FROM Posts

I get the following results:

mdash comment decrement increment uncategorized
7665  34      368       1752      472

The vast majority of valid uses cases would be unaffected by Tim Stone's proposal

marked as duplicate by Eric, yoozer8, Martijn Pieters, ben is uǝq backwards, hims056 Aug 17 '13 at 1:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    <!-- --> shouldn't be in titles. Titles should be descriptive about the problem, not include code snippets. – Michael Irigoyen Aug 16 '13 at 15:10
  • 6
    Yes, it’s intended behaviour. Yes, it’s stupid behaviour. It’s also silly inconsistent. – Ry- Aug 16 '13 at 15:13
  • 1
    @MichaelIrigoyen: What if the question is about this bug? ;) – Ry- Aug 16 '13 at 15:15
  • "Questions containing two dashes in the title collapses to an mdash"? I mean, why in the title did @Eric include -- but spell out mdash? Titles should contain words, not code, IMO. – Michael Irigoyen Aug 16 '13 at 15:19
  • 4
    @Michael, Manual specification of code block with <!— language: python --> fails seems like a fine title to me. – Arjan Aug 16 '13 at 15:20
  • 1
    For one, the double dash is used for -- operator – Old Checkmark Aug 16 '13 at 15:25
  • 3
    And, @Michael, so does Why is i— faster than i++ in loops?... – Arjan Aug 16 '13 at 15:26
  • 2
    What you all need — in my opinion — is a proper compose key… – Ry- Aug 16 '13 at 15:27
  • Unless I'm seeing things, in the example Arjan showed the effect only occured with the first -- in the title. – Bill Woodger Aug 16 '13 at 15:28
  • Despite some legitimate uses, it seems a lot of time they are used for [tag] --... in titles. – Old Checkmark Aug 16 '13 at 15:28
  • @BillWoodger: Yep; see regex below. – Ry- Aug 16 '13 at 15:28
  • @BillWoodger: That's because the other -- is actually a ++ – Eric Aug 16 '13 at 15:28
  • 1
    Or you could add support for backtick quoted code. – CodesInChaos Aug 16 '13 at 15:55
  • As a note, I see "--" in all titles instead of an em dash on my phone's browser (BB10), confused me for a while because both looked identical in the title. – Billy Mailman Aug 16 '13 at 17:17
5

Yes, although obviously it's not perfect in that it can't detect your intent when you actually mean to have double hyphens. Titles are modified based loosely on rules from SmartyPants, which include transforming -- and --- to &mdash; (—).

The regular expression used to do the replacement is just ---?(\s), which may be considered incorrect on the grounds that most style guides frown on putting spaces around en/em dashes…but given that the trailing space is in fact a requirement here, requiring a leading one might be a reasonable way to reduce incorrect conversions (validity of including code snippets in titles aside).

  • 14
    How about letting people type em dashes if they want em dashes? – Ry- Aug 16 '13 at 15:20
  • I'm all for changing the regex to require a leading whitespace character – Eric Aug 16 '13 at 15:22
  • 6
    @minitech People using double minus signs as a pseudo em dash is likely a more common case than there being a legitimate reason to have them literally rendered in the title, with the notable programming-topic exceptions of having something like --i or i--, which tweaking the regex would fully address. – Tim Stone Aug 16 '13 at 15:24
  • So do I retag this as a feature-request, or what? – Eric Aug 16 '13 at 15:52
  • @Eric You could, sure. I think Jeff's counterargument on that other post is a bit weak. – Tim Stone Aug 16 '13 at 16:42
  • 3
  • @minitech: Sure, just surround it in quotes! – Eric Aug 16 '13 at 17:31
  • 1
    @Eric: But that’s yucky! – Ry- Aug 16 '13 at 17:32
  • @minitech: Hey, you're referring to the literal string '--' - seems reasonable to quote it – Eric Aug 16 '13 at 17:32
  • 2
    @Eric: But then I wouldn’t be able to make an annoyed reference to this bug! – Ry- Aug 16 '13 at 17:34
  • How about an escape way ? – Nicolas Barbulesco Dec 7 '13 at 20:21

Not the answer you're looking for? Browse other questions tagged .