mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Closes #7531: Add Markdown support for strikethrough formatting
This commit is contained in:
		| @@ -6,6 +6,7 @@ | ||||
|  | ||||
| * [#2101](https://github.com/netbox-community/netbox/issues/2101) - Add missing `q` filters for necessary models | ||||
| * [#7424](https://github.com/netbox-community/netbox/issues/7424) - Add virtual chassis filters for device components | ||||
| * [#7531](https://github.com/netbox-community/netbox/issues/7531) - Add Markdown support for strikethrough formatting | ||||
| * [#7542](https://github.com/netbox-community/netbox/issues/7542) - Add optional VLAN group column to prefixes table | ||||
| * [#7803](https://github.com/netbox-community/netbox/issues/7803) - Improve live reloading of custom scripts | ||||
| * [#7810](https://github.com/netbox-community/netbox/issues/7810) - Add IEEE 802.15.1 interface type | ||||
|   | ||||
							
								
								
									
										16
									
								
								netbox/utilities/markdown.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								netbox/utilities/markdown.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| import markdown | ||||
| from markdown.inlinepatterns import SimpleTagPattern | ||||
|  | ||||
| STRIKE_RE = r'(~{2})(.+?)(~{2})' | ||||
|  | ||||
|  | ||||
| class StrikethroughExtension(markdown.Extension): | ||||
|     """ | ||||
|     A python-markdown extension which support strikethrough formatting (e.g. "~~text~~"). | ||||
|     """ | ||||
|     def extendMarkdown(self, md): | ||||
|         md.inlinePatterns.register( | ||||
|             markdown.inlinepatterns.SimpleTagPattern(STRIKE_RE, 'del'), | ||||
|             'strikethrough', | ||||
|             200 | ||||
|         ) | ||||
| @@ -15,6 +15,7 @@ from django.utils.safestring import mark_safe | ||||
| from markdown import markdown | ||||
|  | ||||
| from utilities.forms import get_selected_values, TableConfigForm | ||||
| from utilities.markdown import StrikethroughExtension | ||||
| from utilities.utils import foreground_color | ||||
|  | ||||
| register = template.Library() | ||||
| @@ -54,7 +55,7 @@ def render_markdown(value): | ||||
|     value = re.sub(pattern, '[\\1]: \\3', value, flags=re.IGNORECASE) | ||||
|  | ||||
|     # Render Markdown | ||||
|     html = markdown(value, extensions=['fenced_code', 'tables']) | ||||
|     html = markdown(value, extensions=['fenced_code', 'tables', StrikethroughExtension()]) | ||||
|  | ||||
|     return mark_safe(html) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user