PageRenderTime 16ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/scalate-wikitext/src/main/scala/org/fusesource/scalate/wikitext/ScalateConfluenceLanguage.scala

http://github.com/scalate/scalate
Scala | 57 lines | 22 code | 7 blank | 28 comment | 0 complexity | c136c1d588f6fcb01dcc680648fd65cd MD5 | raw file
  1. /**
  2. * Copyright (C) 2009-2011 the original author or authors.
  3. * See the notice.md file distributed with this work for additional
  4. * information regarding copyright ownership.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.fusesource.scalate.wikitext
  19. import org.eclipse.mylyn.wikitext.core.parser.markup.Block
  20. import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage
  21. import java.{ util => ju }
  22. import collection.JavaConverters._
  23. /**
  24. * Registry of language extensions
  25. */
  26. object ConfluenceLanguageExtensions {
  27. var extensions: List[Block] = List()
  28. }
  29. /**
  30. * Adds extensions to the Confluence language such as support for a 'pygmentize' macro
  31. *
  32. * The pygmentize macro will use the pygmentize command line tool to syntax highlight the code within the block
  33. *
  34. * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  35. */
  36. class ScalateConfluenceLanguage extends ConfluenceLanguage {
  37. override def addStandardBlocks(blocks: ju.List[Block], paragraphBreakingBlocks: ju.List[Block]) = {
  38. super.addStandardBlocks(blocks, paragraphBreakingBlocks)
  39. blocks.addAll(ConfluenceLanguageExtensions.extensions.asJava)
  40. List(new PygmentsBlock, new SnippetBlock,
  41. new HtmlBlock, new DivBlock,
  42. new SectionBlock, new ColumnBlock,
  43. new CenterBlock,
  44. // tags
  45. new AttributesTag, new IncludeTag, new ChildrenTag).foreach { b =>
  46. blocks.add(b)
  47. paragraphBreakingBlocks.add(b)
  48. }
  49. }
  50. }