2
0
Fork 0
textout/textoutpc/builtin/_Code.py

78 lines
1.6 KiB
Python
Raw Normal View History

2018-01-02 18:57:04 +01:00
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
#******************************************************************************
2018-01-02 18:57:04 +01:00
from .. import BlockTag as _BlockTag, InlineTag as _InlineTag
2018-01-02 18:57:04 +01:00
__all__ = ["CodeTag", "InlineCodeTag", "NoEvalTag"]
2018-01-02 18:57:04 +01:00
2018-08-25 17:38:24 +02:00
class CodeTag(_BlockTag):
2018-01-02 18:57:04 +01:00
""" The basic code tag, for displaying code.
Example uses:
2018-08-25 17:38:24 +02:00
[code]int main()
{
2018-01-02 18:57:04 +01:00
printf("hello, world");
}[/code] """
aliases = ('[code]',)
generic = False
raw = True
2018-07-27 00:53:59 +02:00
notempty = True
2018-01-02 18:57:04 +01:00
def begin_html(self):
return '<div class="code">'
def end_html(self):
return '</div>'
2018-01-02 18:57:04 +01:00
def begin_lightscript(self):
return '```\n'
def end_lightscript(self):
return '```\n'
2018-08-25 17:38:24 +02:00
class InlineCodeTag(_InlineTag):
2018-01-02 18:57:04 +01:00
""" Inline code tag, doesn't display a box, simply doesn't evaluate
the content and uses monospace font.
Example uses:
2018-08-25 17:38:24 +02:00
`some inline code`
2018-01-02 18:57:04 +01:00
[inlinecode][b]The tags will be shown verbatim.[/b][/inlinecode]
[inlinecode][inlinecode][i]This also[/inlinecode] works![/inlinecode]
2018-01-02 18:57:04 +01:00
"""
aliases = ('`', '[inlinecode]')
generic = False
raw = True
2018-01-02 18:57:04 +01:00
def begin_html(self):
2018-07-29 19:51:42 +02:00
return '<span class="inline-code">'
2018-01-02 18:57:04 +01:00
def end_html(self):
return '</span>'
def begin_lightscript(self):
return '`'
def end_lightscript(self):
return '`'
2018-08-25 17:38:24 +02:00
class NoEvalTag(_InlineTag):
""" Inline code tag, simply doesn't evaluate the content.
Example uses:
2018-08-25 17:38:24 +02:00
[noeval][b]wow, and no need for monospace![/b][/noeval]
"""
2018-07-30 14:03:40 +02:00
aliases = ('[noeval]', '[nobbcode]')
generic = False
raw = True
2018-01-02 18:57:04 +01:00
# End of file.