in kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/magic/MagicParser.scala [34:64]
private def isLineMagic(codeLine: String) = codeLine.startsWith("%") &&
!isCellMagic(codeLine)
/**
* Determines whether a given string of code represents a cell magic.
*
* @param codeBlob a string of code separated by newlines
* @return
*/
private def isCellMagic(codeBlob: String) = codeBlob.startsWith("%%")
/**
* Finds the first occurrence of a "magic string" i.e. "%%magic" or "%magic"
* in a given code string, and separates the magic name from the code that
* follows it.
*
* E.g.
* "%magic foo bar" -> ("magic", "foo bar")
*
* @param codeBlob a string of code separated by newlines
* @return (magicName, args)
*/
protected[magic] def parseMagic(codeBlob: String): Option[(String, String)] = {
val matchData =
magicRegex.findFirstMatchIn(codeBlob)
matchData match {
case Some(m) => Some((m.group(1), m.after(1).toString.trim))
case None => None
}
}