Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to specify that a code block is a certain syntax? #321

Unanswered
airtonix asked this question in Q&A
Discussion options

Sometimes i want it to be python, sometimes yaml, js, ts etc.

 class SomeClass:
 """
 Examples:
 
 class MyThing(SomeClass):
 def detect(self):
 return True
 
 def process(self):
 yield Transaction(
 date=datetime.date.today(),
 narration="Test transaction",
 amount=Decimal("10.00"),
 currency="USD",
 )
 """

should be python like:

class MyThing(SomeClass):
 def detect(self):
 return True
 def process(self):
 yield Transaction(
 date=datetime.date.today(),
 narration="Test transaction",
 amount=Decimal("10.00"),
 currency="USD",
 )

or this code block should be yaml

class Thing:
 """
 Examples:
 items:
 - match: "data/*.csv"
 """

like:

items:
- match: "data/*.csv"
You must be logged in to vote

Replies: 1 comment

Comment options

You can use triple-backticks fences with the language name:

class SomeClass:
 """Summary.

 Examples:
 ```python
 print("this is some Python code")
 ```

 ```yaml
 this: is some YAML
 ```
 """
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /