skylighting-extensions (empty) → 1.0.0.0
raw patch · 6 files changed
+277/−0 lines, 6 filesdep +basedep +containersdep +skylighting
Dependencies added: base, containers, skylighting, skylighting-modding, text
Files
- changelog.md +3/−0
- library/Skylighting/Extensions.hs +43/−0
- library/Skylighting/Extensions/GHCi.hs +79/−0
- library/Skylighting/Extensions/Haskell.hs +92/−0
- license.txt +18/−0
- skylighting-extensions.cabal +42/−0
+ changelog.md view
@@ -0,0 +1,3 @@+1.0.0.0++ * Initial release
+ library/Skylighting/Extensions.hs view
@@ -0,0 +1,43 @@+{-# OPTIONS_GHC -Wall #-}++{-# LANGUAGE OverloadedStrings #-}++{- |++Provides a miscellaneous assortment of customized Skylighting syntax+highlighters.++-}++module Skylighting.Extensions (extendedSyntaxMap, applyAll) where++import qualified Skylighting.Extensions.GHCi+import qualified Skylighting.Extensions.Haskell++-- skylighting+import Skylighting (SyntaxMap)+import qualified Skylighting++-- skylighting-modding+import Skylighting.Modding++{- |++The default Skylighting syntax map, plus all of the extensions provided by+the @skylighting-extensions@ library.++-}++extendedSyntaxMap :: SyntaxMap+extendedSyntaxMap = applyAll Skylighting.defaultSyntaxMap++{- |++Apply all of the syntax extensions in the @skylighting-extensions@ library.++-}++applyAll :: SyntaxMap -> SyntaxMap+applyAll =+ addSyntax Skylighting.Extensions.GHCi.syntax .+ modifySyntax "Haskell" Skylighting.Extensions.Haskell.expandKeywordSet
+ library/Skylighting/Extensions/GHCi.hs view
@@ -0,0 +1,79 @@+{-# OPTIONS_GHC -Wall #-}++{-# LANGUAGE OverloadedStrings #-}++{- |++Introduces a new Skylighting syntax highlighter for GHCi (a REPL for Haskell).++-}++module Skylighting.Extensions.GHCi (syntax) where++-- skylighting-core+import Skylighting.Core++-- skylighting-modding+import Skylighting.Modding++-- text+import qualified Data.Text.Encoding as Text++{- |++A Skylighting 'Syntax' for highlighting GHCi sessions. The only thing this does+is highlight prompts. We assume that the prompt is @"λ>"@ and the continuation+prompt is @" >"@.++-}++syntax :: Syntax+syntax =+ Syntax+ { sName = "ghci"+ , sFilename = ""+ , sShortname = "ghci"+ , sContexts = contextMap ghciContext+ , sAuthor = "Typeclass Consulting, LLC"+ , sVersion = "1"+ , sLicense = "MIT"+ , sExtensions = []+ , sStartingContext = "ghci"+ }++ghciContext :: Context+ghciContext =+ Context+ { cName = "ghci"+ , cSyntax = "ghci"+ , cRules = [promptRule]+ , cAttribute = NormalTok+ , cLineEmptyContext = []+ , cLineEndContext = []+ , cLineBeginContext = []+ , cFallthrough = False+ , cFallthroughContext = []+ , cDynamic = False+ }++promptRule :: Rule+promptRule =+ Rule+ { rMatcher = RegExpr promptRE+ , rAttribute = AnnotationTok+ , rIncludeAttribute = True+ , rDynamic = False+ , rCaseSensitive = True+ , rChildren = []+ , rLookahead = False+ , rFirstNonspace = False+ , rColumn = Just 0+ , rContextSwitch = []+ }++promptRE :: RE+promptRE =+ RE+ { reString = Text.encodeUtf8 "[λ ]>"+ , reCaseSensitive = True+ }
+ library/Skylighting/Extensions/Haskell.hs view
@@ -0,0 +1,92 @@+{-# OPTIONS_GHC -Wall #-}++{-# LANGUAGE OverloadedStrings #-}++{- |++Modifications for the default Skylighting syntax highlighter for Haskell.++-}++module Skylighting.Extensions.Haskell (expandKeywordSet, keywords) where++-- containers+import qualified Data.Set as Set++-- skylighting-core+import Skylighting.Core++-- skylighting-modding+import Skylighting.Modding++-- text+import Data.Text (Text)++{- |++Modifies Skylighting's default Haskell syntax so that the list of keywords+includes ones that are introduced by GHC extensions (enumerated by 'keywords').++-}++expandKeywordSet :: Syntax -> Syntax+expandKeywordSet =+ modifySyntaxContexts $+ modifyContext "code" $+ replaceKeywordRule keywordRule++keywordRule :: Rule+keywordRule =+ Rule+ { rMatcher = keywordMatcher+ , rAttribute = KeywordTok+ , rIncludeAttribute = False+ , rDynamic = False+ , rCaseSensitive = True+ , rChildren = []+ , rLookahead = False+ , rFirstNonspace = False+ , rColumn = Nothing+ , rContextSwitch = []+ }++keywordMatcher :: Matcher+keywordMatcher = Keyword keywordAttr (makeWordSet True keywords)++keywordAttr :: KeywordAttr+keywordAttr =+ KeywordAttr+ { keywordCaseSensitive = True+ , keywordDelims = Set.fromList "\t\n !%&()*+,-./:;<=>?[\\]^{|}~"+ }++{- |++A list of keywords for Haskell, including ones introduced by GHC extensions.++-}++keywords :: [Text]+keywords =+ [ "case"+ , "class"+ , "data"+ , "deriving"+ , "do"+ , "else"+ , "forall" -- ExplicitForAll+ , "if"+ , "in"+ , "infixl"+ , "infixr"+ , "instance"+ , "let"+ , "module"+ , "newtype"+ , "of"+ , "primitive"+ , "then"+ , "type"+ , "via" -- DerivingVia+ , "where"+ ]
+ license.txt view
@@ -0,0 +1,18 @@+Copyright 2019 Typeclass Consulting, LLC++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of+the Software, and to permit persons to whom the Software is furnished to do so,+subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ skylighting-extensions.cabal view
@@ -0,0 +1,42 @@+cabal-version: 2.0++name: skylighting-extensions+version: 1.0.0.0++synopsis: Customized Skylighting syntax highlighters+category: Text++description:+ A miscellaneous assortment of customized Skylighting syntax highlighters.++homepage: https://github.com/typeclasses/pandoc-highlighting-ext+bug-reports: https://github.com/typeclasses/pandoc-highlighting-ext/issues++author: Chris Martin+maintainer: Chris Martin, Julie Moronuki++copyright: 2018 Typeclass Consulting, LLC+license: MIT+license-file: license.txt++build-type: Simple+tested-with: GHC==8.6.1++extra-source-files:+ changelog.md++library+ hs-source-dirs: library+ default-language: Haskell2010++ exposed-modules:+ Skylighting.Extensions+ , Skylighting.Extensions.GHCi+ , Skylighting.Extensions.Haskell++ build-depends:+ base >=4.10 && <5+ , containers+ , skylighting+ , skylighting-modding+ , text