GithubHelp home page GithubHelp logo

jonschlinkert / sublime-markdown-extended Goto Github PK

View Code? Open in Web Editor NEW
660.0 17.0 96.0 161 KB

Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.

Home Page: https://github.com/jonschlinkert

License: MIT License

sublime-text syntax-highlighting gfm markdown language package syntax st3 sublime

sublime-markdown-extended's Introduction

Extends Soda's Monokai and the default markdown styles with additional syntax highlighting for YAML Front Matter, GitHub Flavored Markdown (GFM) and language-specific syntax highlighting inside GFM "fenced" code blocks

Although substantial changes have been made, thank you @aziz and other contributors to Knockdown, for the code for the fenced code blocks.

Get Monokai Extended for better highlighting.

Getting Started

1. Installation

Package Control

If you already have Package Control installed in Sublime Text:

  • Select "Install Package" from the Command Palette: Ctrl+Shift+P on Windows and Linux or ⇧⌘P on OS X)
  • Search for "Markdown Extended" and click enter.

Manual Installation

Go to Preferences -> Browse Packages, and then either download and unzip this plugin into that directory, or:

git clone https://github.com/jonschlinkert/sublime-markdown-extended.git "sublime-markdown-extended"

2. Activate this Language

After installing this package, open a markdown file and switch the language to Markdown Extended, using one of the following methods:

  • Select from the list of supported languages in your status bar at the bottom right corner of your editor
  • ctrl + shift + p and search for "Markdown Extended"

3. Make "Markdown Extended" the default

To make Markdown Extended the default highlighting for the current extension:

  1. Open a file with the extension you want to set a default for (i.e. .md)
  2. Navigate through the following menus in Sublime Text: View -> Syntax -> Open all with current extension as... -> Markdown Extended

Features:

  • Support for YAML Front Matter
  • Support for GFM "fenced" code blocks
  • Language-specific syntax highlighting support inside GFM "fenced" code blocks for most popular languages (see below for the list of supported languages)
  • Syntax highlighting for URLs in text which is auto-linked by GFM
  • Proper syntax highlighting for bullets and numbers in ordered/unordered lists
  • Proper syntax highlighting for bold and italics by ignoring multiple underscores in words

Markdown Enhancements

The following examples use the Monokai Extended theme.

Whitespace

Significant whitespace

Whitespace is significant only directly before and directly after fenced code blocks! Following these instructions will ensure that highlighting works properly and consistently._

This is very simple:

  • Add a newline before and after clode blocks
  • No trailing spaces after the last code block

If you don't, it won't break your code but it won't always look awesome.

Comparisons with and without proper whitespace

Whitespace before the block

You will need to keep a space above and below fenced code blocks for predictable results with syntax highlighting. For example, this is what it looks like when there is no space before a fenced code block:

image

This is what it looks like with proper spacing:

image

Whitespace after the block

Also add a new line after code blocks, but make sure that there is no trailing whitespace next to the bottom fence.

With a trailing whitespace

image

Without a trailing whitespace

image

Supported languages

The following languages are highlighted inside fenced code blocks:

Note that in order for a language to be highlighted properly, you must have the language installed in Sublime Text.

  • coffee|coffeescript
  • coffee front matter
  • cpp
  • csharp
  • css
  • c
  • c++
  • diff
  • ejs
  • erlang
  • underscore
  • go
  • graphql
  • lodash
  • handlebars|hbs: requires the Sublime Text Handlebars package
  • html|html5
  • ini
  • jade
  • java
  • javascript|js
  • json
  • json front matter
  • julia
  • less
  • ls|livescript|LiveScript
  • lua
  • md|markdown
  • nginx
  • objective-c
  • objective-c++
  • perl
  • r
  • ruby
  • sass
  • scala
  • scss
  • shell
  • bash
  • sql|ddl|dml
  • postgresql|postgres|pgsql
  • styl
  • swift
  • swig
  • liquid
  • xml
  • yaml
  • yaml front matter

CSS

Before

image

After

image

LESS

Before

image

After

image

HTML

Before

image

After

image

JavaScript

Before

image

After

image

Coffee

Before

image

After

image

LiveScript

Before

image

After

image

Shell

Before

image

After

image

YAML Front Matter

See gray-matter

Before

image

After

image

Coffee Front Matter

See gray-matter

Before

image

After

image

Authors

Jon Schlinkert

Alexander Krivoshhekov

Copyright and license

Copyright 2013-2015 Jon Schlinkert

MIT License

sublime-markdown-extended's People

Contributors

acusti avatar alfyboza avatar arkkimaagi avatar bachue avatar bycedric avatar choffmeister avatar davidcelis avatar gkemmey avatar gridsane avatar houshuang avatar jonschlinkert avatar karelv avatar l8d avatar leakymirror avatar ma-schmidt avatar master-lincoln avatar nineclue avatar oliverseal avatar randy3k avatar raphinesse avatar sandyarmstrong avatar simov avatar superpaintman avatar tomchentw avatar twidi avatar warmwaffles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublime-markdown-extended's Issues

strange bug

I've been getting this lately:

image

Basically the formatting looks like that until I save (e.g. ctrl+s), then it returns to normal:

image

This just started recently, so I'm pretty sure it's not this package... but, just in case others are having problems with this - as a result of installing this package - I'd like to know so I can hunt down the problem and fix it.

Multiline bold is not highlighted

Hi, thanks for the nice plugin. One thing I noticed

In Sublime Text:

__highlighted__

__not
highlighted__

In GitHub:
bold

multiline
bold

Syntax highlighting breaks specifically with 3 dashes

Take the following markdown:


---
## Smaller Header

```javascript
var add = function (a, b) {
  return a + b;
};
```\

Ignore the backslash, that's only there so I can type the example into this issue

With three dashes --- for an hr, the code block no longer has correct syntax. However, with 4+ dashes, the code block works fine.

Adding another set of three dashes seems to "undo" the problem:


---
## Smaller Header

```javascript
var add = function (a, b) {
  return a + b;
};
```\

---

```javascript
var multiply = function (a, b) {
  return a * b;
};
```\

Is the plugin perhaps trying to use three dashes as some kind of block?

Doesn’t work.

I use ST build 3065.
I’ve installed markdown extended via package control.
I’ve restarted sublime.
Still I have (no italics, no bold):
image

IDK, maybe it conflicts somehow with other packages?
Tried to turn off DocBlockr, Markdown, Sublime Linter - no success.

dd in shell fenced block causes wrong highlighting

Try this with the highlighting set to bash:

$ dd if=/dev/zero of=swapfile bs=1M count=512
$ mkswap swapfile

The if in the dd command is interpreted as a conditional keyword, so now I guess the grammar is looking for the matching fi. As a result, the fenced block doesn't end at the second set of backticks (it thinks the backticks are a command substitution string). You can see GitHub's syntax highlighter is actually making the same mistake, since the if is bolded, but the fenced block doesn't end up consuming this entire issue, so it's not quite as bad.

Not sure if there's an easy solution to this problem. From what I know, dd's command syntax is quite specific, and doesn't allow for a space before the equals sign. Maybe that can be used to solve this issue (check for a space after if before interpreting it as a keyword`, but I wouldn't be surprised if that was insufficient.

SQL syntax highlighting

Hi,
Thanks for the great extension. Would you be able to add SQL syntax highlighting for fenced code blocks?

Cheers,
Nick

Support for inline HTML statements

It would be great if this style could also support inline html lines much like the default markdown style that comes with Sublime Text as I like to use it quite often to include image tags with specific properties and other such nice things.

Default Markdown Syntax Style:

screen shot 2013-12-07 at 14 25 31

Current Markdown Extended Syntax Style:

screen shot 2013-12-07 at 14 25 39

Can't highlight Ruby code

screen shot 2013-07-12 at 10 14 57 am
In the README, it says it supports Ruby(of course Ruby is installed), but in the screenshot, you can see there's no ruby code is highlighted.

Trailing spaces

There are lots of trailing spaces in Syntaxes/Markdown Extended.JSON-tmLanguage file. My Sublime removes them automatically so I spent lots of time trying to understand, why git diff was showing so much edits it that file. So are those spaces left on purpose or just by accident?

HTML and fenced blocks conflict

It seems you only get highlight for one of them. If you only use a couple of <img> and <a> then fenced blocks work, but html tags look like mere text. If you through in <table> like here then blocks stop working but table, images and links are highlighted.

Monokai Extended Light

Using Monokai Extended Light theme GFM fenced blocks look like this:

tisuuth1

The background color should be adjusted to light background color.

Negative indenting for Headings

Any chance to get negative indenting for # Headings? Writer and Ulysses do this and it increases readability a great deal. Thanks!

screen shot 2015-02-10 at 3 35 50 pm

Indexing yaml front matter

It's possible to make Sublime Text index symbols, values inside YAML front matter ? So that when using project it can be possible to use go to any symbol feature.

Bash syntax highlighting

First of all thanks so much for putting this extension together. It makes working with code in markdown much easier and less error prone

One thing that would be nice is support for bash syntax highlighting

Current Highlighting (none)

The following content inside a markdown document has no syntax highlighting

echo "hello world"

Desired Highlighting

If the example above could by highlighted inside a markdown document like it is below that would be really nice

echo "hello world"

Ignore syntax highlighting inside dollar signs

When writing Markdown with Mathjax content you often use single underscores inside dollar signs like

Some text
...
$\int_a^b f(x) dx$
...

It would be very nice if the syntax highlighter would recognize this since otherwise your whole content looks kinda wierd. As there is no standard format for defining equations in markdown syntax (at least what i know) i would be desirable that this would be configurable in the settings of the plugin. This is most likely a feature request and not a bug but since i'm not capable of changing this i would really appreciate it if someone could implement/fix this :-)

Typewriter scrolling?

Great extension, but for some reason, when I click anywhere, that line scrolls to the center of the ST window, a la typewriter scrolling. Am I correct that this is caused by this extension? If so, how do I disable it?

Tks!

"Fenced" code blocks in lists

It would be great if you could add support for indented code blocks in the list.

For example:

  1. Test

    echo "Test code"
  2. Test 2

in GFM this is interpreded as code for list item 1. but it is not recognized in your code.

Thanks in advance.

Problem with Java 8 "Object::new"

Someone, doing a "::new" notation on something like "Object::new" breaks the code block. Not sure if it comes from this extension or of the java syntax parser.

Object::new

Crash inserting empty HTML element between 'bold' delimiters **

I'm using Sublime Text 2.0.2, build 2221 on Windows 8.
Markdown Extended version: v2013.10.17.14.22.26

Steps to reproduce:

  1. Open a new tab in Sublime Text 2
  2. Copy this text into the tab: **Bold text paste inside here**
  3. Set the syntax to 'Markdown Extended'
  4. Copy the following into your clipboard: <span id='hello'></span>
  5. Paste this between 'paste' and 'inside' in the tab.
  6. Observe the bug: window becomes unresponsive, Windows tells you the program is not responding.

sublime-markdown-extended started taking 100% cpu

I have no idea what happened, I have been using the addon for days and enjoying it. Now if I enable it and open any markdown file, it starts taking loads of CPU and I have to kill Sublime Text.

If I disable the package (using package manager, as I installed trough it using the "add repositiory" feature), everything goes back to normal, but I nolonger have the cool features of this addon.

Is there any way to debug what's going on?

'Toggle comment' doesn't work correctly in GFM code blocks

This would be more of an extra feature, I was wondering whether it would be possible. Would be up for having a look myself if no one's tried it already.

Basically if you select 'toggle comment' within a GFM code block, the comment syntax will be HTML, not the language the code block is written in. E.g. see below for an example of what happens when you 'toggle comment' on a line in an SQL code block

<!-- select * from clients -->

Desired behaviour would be for what sublime does in an sql file:

-- select * from clients

javascript next

Any chance support could be added for JavaScript Next? This is a superset of current JS so it should work for all JS code blocks.

Currently if I have ES6 in my code blocks, things like export mess up syntax highlighting for the rest of document.

Variable underscore mistaken as emphasize

It is very common to use _ in the names of variables. Is it possible to fix it so that variables names that start with _ or use it within the variable name are not highlighted as emphasis (italic). Example

screenshot

c++ highlighting not working

Hi,

I can't get code fencing for c++ code to work correctly. It's working for javascript, html, css and shell.

I'm using ```cpp like the other syntaxes. Just to make sure, I switched to view syntax as c++ to make sure ST3 is configured correctly.

Thanks in advance.

Higlighting the entire code block

Would it be possible to higlight the entire fenced code block, similar to what RStudio does? Even if this was just an option, or if there was an easy way to do this I could make the edit myself... I find it much cleaner to have the Markdown visually separated from the code.

Thanks!

Package Control support?

First of all, great job, I like it already. :)

Could this addon be integrated with package control, so that installation would be easier and updates automatic?

combine latex and markdown highlighting

Using inline latex is a pretty common pattern in markdown documents destined for conversion with pandoc.

For example, one might include the command \textsc{small caps text} in a pandoc markdown doc because markdown has no native syntax for small caps.

However at present I can't work out how to get both markdown and latex syntax highlighting active at the same time. It would also be nice if the document tree (for ctrl-R) recognised both markdown headings and \part{} \chapter{} and \section{} commands.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.