-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fa57e3
commit 75d1cae
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ configureMiscModes = do | |
addMode gnuMakeMode | ||
addMode ottMode | ||
addMode whitespaceMode | ||
addMode markdownMode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
-- -*- haskell -*- | ||
-- Lexer for Markdown-file | ||
-- This is based off the syntax as described in the github manual: | ||
-- https://guides.github.com/features/mastering-markdown/ | ||
-- Maintainer: Junji Hashimoto | ||
{ | ||
{-# OPTIONS -w #-} | ||
module Yi.Lexer.Markdown ( lexer ) where | ||
import Yi.Lexer.Alex hiding (tokenToStyle) | ||
import Yi.Style | ||
( Style ( .. ) | ||
, StyleName | ||
) | ||
import qualified Yi.Style as Style | ||
} | ||
|
||
$varChar = $printable # [\: \# \= \ \{ \} \( \)] | ||
|
||
|
||
$space = [\ ] | ||
|
||
markdown :- | ||
|
||
<0> | ||
{ | ||
^\`\`\` { m (const InComment) Style.commentStyle } | ||
^\#+ { c Style.keywordStyle } | ||
^$space*[\+\-\*] { c Style.keywordStyle } | ||
^$space*[0-9]+\. { c Style.keywordStyle } | ||
\!\[[^\]]*\]\([^\)]*\) { c Style.quoteStyle } | ||
\[[^\]]*\]\([^\)]*\) { c Style.quoteStyle } | ||
\[[^\]]*\]\[[^\]]*\] { c Style.quoteStyle } | ||
\*[^\*]*\* { c Style.stringStyle } | ||
\_[^\_]*\_ { c Style.stringStyle } | ||
\*\*[^\*]*\*\* { c Style.stringStyle } | ||
\_\_[^\_]*\_\_ { c Style.stringStyle } | ||
\n | ||
{ c Style.defaultStyle } | ||
. | ||
{ c Style.defaultStyle } | ||
} | ||
|
||
<comment> | ||
{ | ||
^\`\`\` { m (const TopLevel) Style.commentStyle } | ||
\n | ||
{ c Style.commentStyle } | ||
. | ||
{ c Style.commentStyle } | ||
} | ||
|
||
{ | ||
data HlState = | ||
TopLevel | ||
| InComment | ||
deriving Show | ||
stateToInit TopLevel = 0 | ||
stateToInit InComment = comment | ||
|
||
initState :: HlState | ||
initState = TopLevel | ||
|
||
type Token = StyleName | ||
|
||
lexer :: StyleLexerASI HlState Token | ||
lexer = StyleLexer | ||
{ _tokenToStyle = id | ||
, _styleLexer = commonLexer alexScanToken initState | ||
} | ||
|
||
#include "common.hsinc" | ||
} |
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
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