[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-nano] Help with markdown syntax highlighting

From: Sean Hammond
Subject: [Help-nano] Help with markdown syntax highlighting
Date: Tue, 1 Aug 2006 14:24:29 +0100

I've been writing some regexes to enable markdown syntax highlighting
in nano. My regex skill is limited, so I'm looking for some pointers
on perfecting the rule set.

Markdown syntax is explained here:

Here are my highlighting rules from my .nanorc:

syntax "markdown" "\.txt$"
# Quotations
color cyan "^>.*"
# Emphasis
color green "_.*_"
color green "\*.*\*"
# Strong emphasis
color brightgreen "\*\*.*\*\*"
color brightgreen "__.*__"
# Underline headers
color brightblue "^====(=*)"
color brightblue "^----(-*)"
# Hash headers
color brightblue "^#.*"
# Linkified URLs (and inline html tags)
color brightmagenta start="<" end=">"
# Links
color brightmagenta "\[.*\]\(.*\)"
# Reference-style links
color brightmagenta "\[.*\]( )?\[.*\]"
# Link id's:
color brightmagenta "^\[.*\]:( )+.*"
# Code spans
color brightyellow "`.*`"
# Code blocks
color brightyellow "^(    ).*"
# Inline images
color brightmagenta "!\[.*\]\(.*\)"
# Reference-style images
color brightmagenta "!\[.*\]\[.*\]"

They have the following limitations:

Emphasis, strong emphasis and code spans that go over multiple lines
will not be highlighted properly (the highlighting only works within
one line). How can I improve these rules to go over multiple lines?

If you end a line with two spaces in markdown it is meaningful. But
ofcourse it's not easy to see in an editor whether a line ends with
trailing spaces or not. How can I highlight a pair of spaces at the
end of a line?

For underlined headers, it would be nice to colour the actual text of
the header, not just the underline. This means colouring the line
above the line that matches the --- or === pattern. How can this be

I've coloured text that appears in-between < and > characters, which
has the effect of colouring HTML tags. Markdown allows for arbitrary
HTML to be embedded within the markdown code. But is it possible to
highlight the HTML itself, as opposed to only the HTML tags?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]