3

I came across a question that was weirdly formatted with ``` to indent code. As the output was unsexy, it tried to edit it with no luck, here's the question:


I have a Scala regex which does match with pattern.findFirstMatchIn() but not with a match ... case unpacking statement:

val pattern = "\"(\\d+?)\",\"(.*?)\",(.+)$".r val line = "\"1795\",\"title\",\"desc
 " println(pattern.findFirstMatchIn(line).isDefined) val pattern2Unpacking = line match { case pattern( category_id, title, description) => true case _ => false } println(pattern2Unpacking)


I'm familiar with the bullet list issue but I can't find information on this one, how to format it correctly and why does it occurs?

Note: Feel free to try to edit this post

2
  • I think you can just remove the backticks and indent to (at least) 4 spaces on each line, as long as it's not part of a bullet list, right? That's what I've been doing when I encounter this type of formatting error, anyway.
    – Mage Xy
    Commented Mar 22, 2016 at 14:15
  • 1
    @MageXy It doesn't work. Commented Mar 22, 2016 at 14:19

1 Answer 1

10

Someone is attempting to use GitHub flavored Markdown to format their code blocks, which is unsupported on Stack Exchange. See this feature request. What results are a series of <code> elements and not a single <pre> in sight.

The problem with this specific code block is unrelated to that, though. There is a U+2028 LINE SEPARATOR after the \"desc portion of the code that's preventing the entire thing from being formatted as a code block even when you remove the ``` bits (which is probably why the author put them there in the first place). Removing that allows the code block to render correctly.

Here is the sanitized Markdown source, with the triple backticks and the control character removed (I don't know if the whitespace between "\desc and the last " should also be removed):

I have a Scala regex which does match with `pattern.findFirstMatchIn()` but not with a `match ... case` unpacking statement:

          val pattern = "\"(\\d+?)\",\"(.*?)\",(.+)$".r
          val line = "\"1795\",\"title\",\"desc        "
          println(pattern.findFirstMatchIn(line).isDefined)
          val pattern2Unpacking = line match {
            case pattern( category_id, title, description) =>
              true
            case _ => false
          }
          println(pattern2Unpacking)
1
  • 1
    Thanks for U+2028 I didn't know about it. Commented Mar 22, 2016 at 14:46

You must log in to answer this question.

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