Can I highlight some text in a fenced code block?


(Kristen) #1

In a Discourse forum for techies discussing code in a specific language Iā€™d like to be able to highlight something in a code block. For example the O/P posts some, broken, code and I fix it up. The user has to carefully read my improved code to see what I have changed, and putting a comment in the code like:

xxx = yyy <ā€” I MADE A CHANGE HERE

is a bit lame!, particularly on a complex line.

I suppose, ideally, it would just be a background colour to highlight a section, but if it was possible to put some sort of [color=red] or similar tags into the code that would provide more facilities to people which more artistically then me!


#2

What about diff?

diff --git a/pynote/formatting.py b/pynote/formatting.py
index f0d7d53..eda1906 100644
--- a/pynote/formatting.py
+++ b/pynote/formatting.py
@@ -1,5 +1,5 @@
 import click
-from pynote import config
+from . import config
 
 
 def echo(text, no_pager=False):

(Stan Dyck) #3

This is something I am looking for but can you tell me how you did this? That is, how do you format in the editor to get this to display?


(Jeff Atwood) #4
line 1
line 2
+line 3
-line 4
line 5
```diff
line 1
line 2
+line 3
-line 4
line 5
```