Created
January 27, 2014 13:56
-
-
Save jducoeur/8648951 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override def qlApply(invInit:Invocation):QValue = { | |
invInit.ifMatches(sig) { inv => | |
inv.contextAs[URLableType] { pt => | |
inv.context.collect(ParsedTextType) { elemContext => | |
val wikitextOpt = for ( | |
elemV <- elemContext.value.firstOpt; | |
url <- pt.getURL(elemContext)(elemV); | |
label = inv.oldProcessParam(0, elemContext).wikify(elemContext) | |
) | |
yield QWikitext("[") + label + QWikitext(s"]($url)") | |
wikitextOpt match { | |
case Some(wikitext) => QValue.make(ExactlyOne, ParsedTextType, wikitext) | |
case None => Core.emptyListOf(ParsedTextType) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment