-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommend snippet syntax #1209
Merged
Merged
Recommend snippet syntax #1209
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
08c1d8f
update template to recommend code snippets
BillWagner cc7d580
Fix contributing link
BillWagner 75fc4b4
update list of languages to the correct smaller set.
BillWagner f20769a
respond to feedback
BillWagner 2f9a094
respond to feedback.
BillWagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -202,7 +202,35 @@ You can use a [Markdown table generator tool](http://www.tablesgenerator.com/mar | |
|
||
## Code | ||
|
||
### Code blocks with language identifier | ||
The best way to include code is to include snippets from a working sample. Create your | ||
sample following the instructions in the [contributing guide](../CONTRIBUTING.md#contributing-to-samples). | ||
|
||
You can include the code using include syntax: | ||
|
||
``` | ||
[!code-csharp[<title>](<pathToFile>#<RegionName)] | ||
``` | ||
|
||
The example above shows C# syntax, but other languages are supported. | ||
Use `code-fsharp` for F# samples; use `code-vbnet` for Visual Basic samples. | ||
Any language supported by [highlight.js](http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases) | ||
is supported. | ||
|
||
The text you place for `<title>` shows up as a rollover on the text. The `<pathToFile>` | ||
is the path to the source file. The `<RegionName>` should be a region in your source | ||
code that should be included. Use the `#region` and `#endregion` preprocessor syntax | ||
to specify the region of code to include. | ||
|
||
For cases where regions don't work, you can specify the start and end of a region | ||
using a triple-slash comment and an XML element name. Finally, you can use line | ||
numbers: `#L1-L10` would include lines 1 through 10. We discourage line numbers | ||
because they are very brittle. | ||
|
||
Including snippets from full programs ensures that all code runs through our CI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI -> Continuous Integration (CI) |
||
system. However, if you need to show something that causes compile time or | ||
runtime errors, you can use inline code blocks. | ||
|
||
### Inline code blocks with language identifier | ||
|
||
Use three backticks (\`\`\`) + a language ID to apply language-specific color coding to a code block. Here is the entire list of [GFM language IDs](https://github.com/jmm/gfm-lang-ids/wiki/GitHub-Flavored-Markdown-(GFM)-language-IDs). | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"For cases where regions don't work, you can specify the start and end of a region" ->
For cases where regions don't work, you can specify the start and end of your snippet? it's a bit confusing to say regions don't work, so specify a region